-
-
Notifications
You must be signed in to change notification settings - Fork 591
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(pluginutils): add native node es modules support #419
Conversation
@@ -4,6 +4,19 @@ import typescript from '@rollup/plugin-typescript'; | |||
|
|||
import pkg from './package.json'; | |||
|
|||
function emitModulePackageFile() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
es/package.json with {type:module}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As an alternative to .mjs extension.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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:
pluginutils
This 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/rollup@2.10.9/dist/es/
This change is necessary before migrating all other plugins.