So apparently webpack will follow the module property of package.json files over the main entry. Since microbundle uses this property to point to the un-processed source file, webpack will pull the raw source file whenever you try to import a microbundled package, entirely defeating the point of processing the file in the first place.
I'm not entirely sure what the right fix is for this - ultimately, you likely want webpack to pull the xxx.m.js version which has been processed by babel but is still using es modules, but this is impossible without breaking microbundle's entry point.
I guess my gut would be to use a different property for microbundle's entry point - happy to PR to help fix this if you have any suggestions.
You should use "module" to point to the processed source, and "source" to point to your unprocessed source:
{
"main": "dist/foo.js",
"module": "dist/foo.mjs",
"source": "src/index.js"
}
Got it, this is great, but wasn't present in the docs. About to submit a PR to correct this!
Most helpful comment
Got it, this is great, but wasn't present in the docs. About to submit a PR to correct this!