Created
March 11, 2021 16:24
-
-
Save whoisryosuke/1ccfe297f04c7c651ae352c0a4ee3f51 to your computer and use it in GitHub Desktop.
Typescript/NPM - How to build both ESM and CJS in project. @see https://www.sensedeep.com/blog/posts/2021/how-to-create-single-source-npm-module.html
This file contains 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
tsc -p tsconfig.json && tsc -p tsconfig-cjs.json |
This file contains 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
{ | |
"extends": "./tsconfig-base.json", | |
"compilerOptions": { | |
"module": "commonjs", | |
"outDir": "dist/cjs", | |
"target": "es2015" | |
} | |
} |
This file contains 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
{ | |
"extends": "./tsconfig-base.json", | |
"compilerOptions": { | |
"module": "esnext", | |
"outDir": "dist/mjs", | |
"target": "esnext" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment