Skip to content

Commit

Permalink
Support double-publishing of both ESM and CJS modules
Browse files Browse the repository at this point in the history
Closes #65
  • Loading branch information
eirslett committed May 16, 2021
1 parent 2339355 commit 76fb434
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
9 changes: 7 additions & 2 deletions .babelrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
// babel-preset-env: `false` means ESM modules, `undefined` means CJS modules
const modules = process.env.BABEL_ESM === 'true' ? false : undefined;

module.exports = {
presets: [
'@babel/preset-env',
['@babel/preset-env', {
modules
}],
'@babel/preset-typescript',
],
};
};
10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,16 @@
"license": "MIT",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"module": "dist/index.mjs",
"exports": {
"import": "./dist/index.mjs",
"require": "./dist/index.js"
},
"scripts": {
"build": "babel src --out-dir dist --extensions \".ts\" && tsc --emitDeclarationOnly",
"build:cjs": "babel src --out-dir dist --extensions \".ts\" --out-file-extension .js",
"build:esm": "BABEL_ESM=true babel src --out-dir dist --extensions \".ts\" --out-file-extension .mjs",
"build:tsc": "tsc --emitDeclarationOnly",
"build": "yarn build:cjs && yarn build:esm && yarn build:tsc",
"lint": "eslint src --ext .js,.ts",
"prepublish": "yarn build",
"test": "yarn test-node && yarn test-browser",
Expand Down

0 comments on commit 76fb434

Please sign in to comment.