Add nodeNext and node16 support#147
Closed
cuppachino wants to merge 10 commits intogvergnaud:mainfrom
Closed
Conversation
Also expose "types/" and "internal/" folders with the "exports" field in package.json
Author
|
there might be working solution now with |
Owner
|
@cuppachino I didn't look at the new |
Author
|
@gvergnaud I just checked the PR for it, and I think if we want to hit both module systems for both browser and node we have to use From a bunch of experimentation, this seems to be the easiest way to do it: Use esm by default
tsconfig.json{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"target": "ES2020",
"module": "NodeNext",
"moduleResolution": "nodenext",
"outDir": "./dist/esm"
}
}tsconfig.cjs.json{
"compilerOptions": {
"target": "ES2015",
"module": "CommonJS",
"moduleResolution": "nodenext",
"outDir": "./dist/cjs"
},
"extends": "./tsconfig.base.json"
}
{
"type": "module",
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
"exports": {
"types": "./dist/index.d.ts",
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.cjs",
"browser": "./dist/esm/index.js",
"default": "./dist/cjs/index.cjs"
}
} |
Author
|
Just tried this out in another popular project with success. Here's the conversion commit. I'd suggest using microbundle on JavaScript after compilation with tsc (+ the steps previously mentioned) or not at all. |
Owner
|
Thanks for opening this PR! Closing in favor of #160 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This branch potentially fixes #110. I used tsup to quickly try out a few common configs, but this change needs more testing.
changes
jest.config.cjs.jsto.tsduring testing.package.json.d.tsexports & usetsconfig.prod.jsonin scriptssrc/**/*.(ts|mts|cts).jsto importstsconfig.json.jsduring developmenttsconfig.prod.json