-
Notifications
You must be signed in to change notification settings - Fork 43
Feature: Dual-goal packages #93
Comments
I had a idea about how to achieve this, for the use case where my package is already fully migrated into ESM syntax. So the easy way, that doesn’t fulfill all the goals of the feature request, would be to have my app include a build step that transpiles it into CommonJS. The CommonJS version is what I publish to NPM and have So how to achieve this without a build step? Well, what if we borrow some ideas from #81 and #101 and nodejs/node#18392 and https://github.com/rollup/rollup/wiki/pkg.module?
The polyfill in the CommonJS entry point doesn’t need to be Babel, and it doesn’t (necessarily) need to transpile, if other solutions can be found. But let’s say that at least the above approach works. The downside of this is that for non-ESM-supporting runtimes, whatever the polyfill is (transpilation, etc.), it’ll surely be slower than if we had transpiled the package ahead of time and published it as native CommonJS. That’s the disadvantage of polyfills in general. But as ESM support becomes more common, this performance hit for legacy runtimes will become less important. |
you can just do |
I would prefer to have two keys and drop |
@GeoffreyBooth two keys doesn’t address deep paths; mjs will be necessary for ensuring that all files can be consumed by all consumers. |
Use cases 2, 10, 39, 41.
The text was updated successfully, but these errors were encountered: