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

Feat: Add exports map for Native ESM #293

Merged
merged 2 commits into from
Aug 16, 2020
Merged

Conversation

lukeed
Copy link
Contributor

@lukeed lukeed commented Aug 7, 2020

Closes #292

Used the "loose" variant so that this won't be accidentally breaking for users who are spelunking into the dist or lib directories for specific file(s).

There's an issue with Node 13.0 through 13.6 that shipped early, now-deprecated versions of the exports map syntax.
Any users on those versions should have already abandoned them, since any odd major release (especially early versions of it) are always experimental.

The current exports map works in all 12.x and 14.x versions (and 13.7+).
It's completely ignored by older versions of Node since they don't know what it is.


While completely unrelated, I also added the unpkg key so that developers can do this, if they want:

<script src="https://unpkg.com/diff"></script>

}, {
format: 'esm',
file: pkg['exports']['.'].import
}
Copy link

@calebeby calebeby Aug 13, 2020

Choose a reason for hiding this comment

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

@lukeed What is the advantage of having two separate ESM builds and output files?

Copy link
Contributor Author

@lukeed lukeed Aug 13, 2020

Choose a reason for hiding this comment

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

Two things:

  1. I'm primarily preserving diff's existing output files, so that anyone who was import/requiring into the module (eg, require('diff/lib/index.es6.js')) doesn't find a surprise.

  2. I did not add "type": "module" (nor do I want to) since that'd be a breaking change. Without that, need .mjs extension for ESM to be activated.

Choose a reason for hiding this comment

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

Thanks, that makes sense!

@kpdecker kpdecker merged commit 8aea9cf into kpdecker:master Aug 16, 2020
@lukeed
Copy link
Contributor Author

lukeed commented Aug 23, 2020

Hey thanks for merge :) Any idea when next release will happen? Thanks!

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.

Native ESM
4 participants