feat(pluginutils): add native node es modules support#419
Conversation
|
|
||
| import pkg from './package.json'; | ||
|
|
||
| function emitModulePackageFile() { |
There was a problem hiding this comment.
let's export this output plugin from https://github.com/rollup/plugins/blob/master/shared/rollup.config.js so we can reuse it
A blocker for rollup/plugins#419 emitModulePackageFile is used to avoid .mjs extension.
|
Looks like there is a blocker |
|
@shellscape Bundling estree-walker would eliminate the problem. What do you think? |
|
@TrySound it's got a pretty small bundle footprint of 2.9kb raw. That should be fine. |
| "exports": { | ||
| "require": "./dist/cjs/index.js", | ||
| "import": "./dist/es/index.js" | ||
| }, | ||
| "module": "./dist/es/index.js", |
There was a problem hiding this comment.
question about the choice to nest these within a directory: our prior file format was index.[format].[extension] for output files. e.g. index.es.js. what's the reasoning behind the choice to put them into directories?
There was a problem hiding this comment.
es/package.json with {type:module}
There was a problem hiding this comment.
As an alternative to .mjs extension.
There was a problem hiding this comment.
OK. Can you explain in the PR description why we need mjs alternative? I've added a bunch more people to review. We're going to need to get majority buy-in to move forward with this since it's a pretty big paradigm shift.
|
@TrySound can you please explain why we need to shift from |
|
I just don't like it. And to be consistent with rollup. So no strong opinion. |
That seems the most compelling reason. I really don't like how it litters If we're going to adopt this, we should also revisit comments by @Andarist where |
|
I'll be following up with a PR to address the comment from above:
|
* feat(pluginutils): add native node es modules support Ref rollup#412 rollup#413 Enable native node es modules via "exports" field in package.json. Added custom plugin to generate nested package.json with `{"type": "module"}` to prevent mjs extension usage. * Export emitModulePackageFile from shared config * Bundle estree-walker * Swap options
Rollup Plugin Name:
pluginutilsThis PR contains:
Are tests included?
Breaking Changes?
If yes, then include "BREAKING CHANGES:" in the first commit message body, followed by a description of what is breaking.
List any relevant issue numbers:
Description
Enable native node es modules via "exports" field in package.json.
Added custom plugin to generate nested package.json with
{"type": "module"}as an alternative to mjs extension usage. This works similar to rollup distribution.
https://unpkg.com/browse/[email protected]/dist/es/
This change is necessary before migrating all other plugins.