Skip to content

Commit

Permalink
feat: Package ECMAScript Modules too (enisdenjo#87)
Browse files Browse the repository at this point in the history
* chore: provide esm mjs files

* refactor: simplify by building esm first
  • Loading branch information
enisdenjo authored Dec 17, 2020
1 parent 2aa9c41 commit 2108174
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"node": ">=10"
},
"main": "lib/index.js",
"module": "lib/index.mjs",
"types": "lib/index.d.ts",
"browser": "umd/graphql-ws.js",
"files": [
Expand All @@ -42,9 +43,10 @@
"lint": "eslint 'src'",
"type-check": "tsc --noEmit",
"test": "jest",
"build:lib": "tsc -b tsconfig.build.json",
"build:esm": "tsc -b tsconfig.esm.json && find ./lib -name \"*.js\" -exec sh -c 'mv \"$0\" \"${0%.js}.mjs\"' \"{}\" \\;",
"build:cjs": "tsc -b tsconfig.cjs.json",
"build:umd": "rollup -c && gzip umd/graphql-ws.min.js -c > umd/graphql-ws.min.js.gz",
"build": "yarn build:lib && yarn build:umd",
"build": "yarn build:esm && yarn build:cjs && yarn build:umd",
"release": "semantic-release"
},
"peerDependencies": {
Expand Down
9 changes: 9 additions & 0 deletions tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"outDir": "./lib",
"declaration": false // already built by `tsconfig.esm.json`
},
"exclude": ["src/tests", "lib"]
}
2 changes: 1 addition & 1 deletion tsconfig.build.json → tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"module": "es2015",
"outDir": "./lib",
"declaration": true
},
Expand Down

0 comments on commit 2108174

Please sign in to comment.