fix(packaging): Don't advertise non-existent ESM entrypoints #2022
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The basics
The details
Resolves
Fixes #1877.
Proposed Changes
Don't advertise
module
entrypoints on packages that are implemented in TypeScript as at the moment our webpack configuration does not generate any file calledsrc/index.js
.Reason for Changes
For JS packages, we point bundlers looking for an ESM entrypoint at
src/index.js
, thereby letting them ingest the package source code, but TypeScript packages have ansrc/index.ts
instead.Some bundlers (webpack, notably, when suitably configured) might actually be quite happy to ingest that instead, but AFAIK it's not valid to have the
package.json
module
entrypoint point to anything except an actual ES module.We have discussed publishing either the TSC output (unbundled JS "sources" one-for-one translated from TS) or a bundled ESM, but we haven't quite figured out the best way to do that yet, so in the meantime let's at least remove the false advertising that is causing errors for certain developer's builds.
Test Coverage
I ran
npm test
but I don't think that actually tested this change in any meaningful way. :-(