Microbundle: Not compatible with webpack

Created on 14 Dec 2017  路  2Comments  路  Source: developit/microbundle

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.

question

Most helpful comment

Got it, this is great, but wasn't present in the docs. About to submit a PR to correct this!

All 2 comments

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!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

omgovich picture omgovich  路  16Comments

pascalduez picture pascalduez  路  12Comments

Conaclos picture Conaclos  路  11Comments

artemtam picture artemtam  路  19Comments

prateekbh picture prateekbh  路  17Comments