By default bundlers resolve a packages import from the
modulefield over the
package.json(webpack and rollup, for example) which points to a projects ES6 module entry.
By default bundlers ignore transformations on anything from
Aren't these two behaviors contradictory?
There are solutions to this:
- Change the mainFields option to import
- Change your exclude option to transpile specific package(s).
- Use an es-check and only transpile packages that need it.
But yeah, this has always confused me. Am I missing something? Why do they do this?
Top comments (2)
Well, sometimes you want to bundle but don't want to transpile. The best thing about webpack is that you can configure it however you like.
Yeah, totally. I love webpack too and have found ways to configure a bundle and resolve the issue in both webpack and rollup. I guess my general question is why does it act this way by default? It feels very counter-intuitive and while I was searching for solutions I noticed A LOT of similar posts of people trying to resolve that same issue.