Upgrade TypeScript (and related) to 5.0, and start using package.json
conditional exports
#10
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.
Somewhat surprisingly, this all seems to be working.
Basically:
verbatimModuleSyntax
(but continue usingisolatedModules: true
)exports
field ofpackage.json
, and specifically "conditional exports," so that published modules point to CJS or ESM (only usinges2020
for ESM atm, although we buildesnext
) based on consumer, e.g.:and
Each
package.json
now includes this:dev
which is not consumed by external tools (and therefore will not interfere with downstream packages), and use the new TypeScript 5.0 featurecustomConditions
to make sure that TypeScript can resolve usingmoduleResolution: nodenext
by seeingindex.ts
(instead of something in./build
for each package). Similarly, use a config flagresolutions.conditions
in vitest, which passes it to vite, which passes it tonode --conditions
(see: Vitest doesn't handle package.jsonexports
conditions likebrowser
vitest-dev/vitest#2603 (comment))Once this is merged I'll publish the latest versions to npm.
Unfortunately I think skypack will still be broken, since it doesn't install dependencies of a package. But we'll see, maybe it will magically work too (doubt it).