Skip to content

Commit 79ed658

Browse files
committed
Fix hybrid module setup #65
1 parent d24b9fd commit 79ed658

File tree

5 files changed

+31
-5
lines changed

5 files changed

+31
-5
lines changed

fix-hybrid-module.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
cat >dist/cjs/package.json <<!EOF
2+
{
3+
"type": "commonjs"
4+
}
5+
!EOF
6+
7+
cat >dist/esm/package.json <<!EOF
8+
{
9+
"type": "module"
10+
}
11+
!EOF

package.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
"lint": "eslint --ext .ts . && prettier --config .prettierrc 'src/**/*.ts' --check",
1010
"lint:fix": "eslint --ext .ts . --fix && prettier --config .prettierrc 'src/**/*.ts' --write",
1111
"clean": "rimraf dist/*",
12-
"build": "npm run build:esm && npm run build:cjs",
12+
"build": "npm run build:esm && npm run build:cjs && ./fix-hybrid-module.sh",
1313
"build:esm": "tsc -p ./tsconfig.esm.json",
14-
"build:cjs": "tsc -p ./tsconfig.json",
14+
"build:cjs": "tsc -p ./tsconfig.cjs.json",
1515
"test": "npm run lint && npm run testonly",
1616
"testonly": "mocha --check-leaks --exit --full-trace --require ts-node/register/transpile-only 'src/**/__tests__/**/*-test.{ts,tsx}'",
17-
"dist": "npm run clean && tsc && npm run build",
17+
"dist": "npm run clean && npm run build",
1818
"prepare": "npm run clean && npm run dist"
1919
},
2020
"directories": {
@@ -40,6 +40,12 @@
4040
"complexity",
4141
"analysis"
4242
],
43+
"exports": {
44+
".": {
45+
"import": "./dist/esm/index.js",
46+
"require": "./dist/cjs/index.js"
47+
}
48+
},
4349
"author": "Ivo Meißner",
4450
"license": "MIT",
4551
"devDependencies": {

tsconfig.cjs.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"sourceMap": false
5+
},
6+
"exclude": ["**/__tests__/**"]
7+
}

tsconfig.esm.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
{
22
"extends": "./tsconfig.json",
33
"compilerOptions": {
4+
"sourceMap": false,
45
"target": "ES2015",
56
"module": "ES2015",
67
"outDir": "dist/esm"
7-
}
8+
},
9+
"exclude": ["**/__tests__/**"]
810
}

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"paths": {
1313
"*": ["node_modules/*", "src/types/*"]
1414
},
15-
"lib": ["es2015", "es2018", "esnext.asynciterable", "dom"]
15+
"lib": ["esnext", "esnext.asynciterable"]
1616
},
1717
"include": ["src/**/*"]
1818
}

0 commit comments

Comments
 (0)