Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Migrate to named exports and provide node esm support#241

Open
TrySound wants to merge3 commits intojson5:main
base:main
Choose a base branch
Loading
fromTrySound:named-exports

Conversation

TrySound
Copy link

In this diff I added new entry point to compile es modules with named
exports to solve this problem (#240).

It's a breaking change so we can drop legacy node support (newer
versions of rollup and many other tools requires this) and add native
node es modules support.

shrpne reacted with thumbs up emoji
In this diff I added new entry point to compile es modules with namedexports to solve this problem (json5#240).It's a breaking change so we can drop legacy node support (newerversions of rollup and many other tools requires this) and add nativenode es modules support.
@jordanbtucker
Copy link
Member

Thank you for this PR, but I think it adds too much complexity compared to#243. Instead of one entry point (lib/index.js) there are now two (lib/index.js andlib/esm.js) as well asdist/index.mjs which is redundant. Removingdist/index.mjs is a breaking change, so you end up with two ESM compatible entry points that do the same thing, one used by Node.js and the other used by webpack.

There is also amodule field and anexports field that each point to different entry points, which confuses things further.

You've also removed thebrowser field frompackage.json, which ensures that certain polyfills are included. Andlib/esm.js cannot be used by browsers because bothparse.js andstringify.jsrequireutil.js.

@TrySound
Copy link
Author

TrySound commentedOct 13, 2020
edited
Loading

esm.js is used only for building proper exports in dist/index.mjs because generating exports from commonjs is not reliable and may change with rollup upgrade. I do not suggest to remove dist/index.mjs.

"module" is bundler specific field. "exports" is node specific way to support es modules natively. Probably only webpack 5 support both them yet.
https://nodejs.org/api/packages.html#packages_conditional_exports

Here's example
https://unpkg.com/browse/nanoid@3.1.12/package.json

"browser" field should not just point to umd. Bundlers prefer "browser" field over over "module" when specified as a string. This makes "module" field useless in this case. See the correct use case for "browser" fieldhttps://github.com/visgl/react-map-gl/blob/master/package.json#L17-L25

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees

@jordanbtuckerjordanbtucker

Labels
None yet
Projects
None yet
Milestone
v3.0.0
Development

Successfully merging this pull request may close these issues.

2 participants
@TrySound@jordanbtucker

[8]ページ先頭

©2009-2025 Movatter.jp