Skip to content
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

docs: use "exports" key in all examples #794

Merged
merged 3 commits into from
May 5, 2021

Conversation

ludofischer
Copy link
Contributor

I think having two fields in the examples is confusing, especially since I could not find recent sources recommending esmodule any more.
Related to #781

@changeset-bot
Copy link

changeset-bot bot commented Jan 31, 2021

⚠️ No Changeset found

Latest commit: 07ce5b8

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Owner

@developit developit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, but I need to check if it actually works without using a .mjs file extension for the "import" field value. If not, it might be better to recommend using .cjs for the CommonJS and UMD variants, with "type":"module" in the package.json.

README.md Outdated Show resolved Hide resolved
ludofischer and others added 2 commits February 14, 2021 17:51
Replace a leftover 'esmodule' key with the current recommendation.
Co-authored-by: Jason Miller <developit@users.noreply.github.com>
@ludofischer
Copy link
Contributor Author

I've had another go at this to at least make the docs internally consistent. But looking at issues like rollup/plugins#695, I get the feeling that there is not 'one' way to organize the package.json field that will guarantee every tool will pick up the correct exports.

Merge the two microbundle build examples and refer
to Node.js docs for more information on the different fields.
@developit developit merged commit 2c9eaa1 into developit:master May 5, 2021
@ludofischer ludofischer deleted the update-readme branch May 5, 2021 15:26
@hanayashiki
Copy link

hanayashiki commented Oct 20, 2021

"exports": "dist/foo.modern.js", // Modern ES Modules bundle

This probably won't work for node. We'll need to use conditional export for import and require since node doesn't support the field "module".
Per node documentation, exports overrides main for entry resolution. That means, if you are using commonjs, you'll end up importing an es module with 'require', which throws an error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants