fix: issue where esm did not build with fully specified extensions #171
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.
Summary & Motivation
Previously using a tsconfig.esm.json would compile output for esm, however paths were relative with no extensions.
Typically this is solved by using fully specified extensions in imports in TS files. However, this will not work in a dual output module (cjs and esm).
To resolve this,
rollup
is used to compile and export both cjs and esm as well as types.Additionally, by default rollup will bundle everything into one file. To preserve file structure, this is disabled.
Additionally, without specifiying
type: module
in the package json all ES modules need themjs
extension to be interpreted by downstream compilers as ES modules.How I Tested These Changes
Did you add a changeset?
To add a changeset for your pr run
pnpm changeset
.pnpm changest
will generate a file where you should write a human friendly message about the changes. Note how this (example) includes the package name (should be auto added by the command) along with the type of semver change (major.minor.patch) (which you should set).These changes will be used at release time to determine what packages to publish and how to bump their version. For more context see this comment.