Skip to content

Commit 9f117f4

Browse files
author
Michael Dowse
committed
fix: Output both cjs and esm modules
1 parent 629ff92 commit 9f117f4

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

package.json

+6-3
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,20 @@
22
"name": "@michaeldowseza/hello-world",
33
"version": "1.0.0",
44
"description": "Hello world",
5-
"main": "lib/index.js",
6-
"types": "lib/index.d.ts",
75
"files": [
86
"lib/"
97
],
108
"scripts": {
119
"lint": "eslint . --ext .ts",
1210
"test": "jest --coverage",
1311
"prepublishOnly": "npm run build",
14-
"build": "tsc -p tsconfig.json"
12+
"build": "npm run build:esm && npm run build:cjs",
13+
"build:esm": "tsc",
14+
"build:cjs": "tsc --module commonjs --outDir lib/cjs"
1515
},
16+
"main": "./lib/cjs/index.js",
17+
"module": "./lib/esm/index.js",
18+
"types": "./lib/esm/index.d.ts",
1619
"repository": {
1720
"type": "git",
1821
"url": "git+https://github.com/michaeldowseza/hello-world.git"

tsconfig.json

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
{
22
"compilerOptions": {
3-
"target": "ESNext",
4-
"module": "CommonJS",
3+
"outDir": "lib/esm",
4+
"target": "es5",
5+
"lib": ["es6", "es2016", "es2017"],
6+
"module": "esnext",
57
"strict": true,
68
"esModuleInterop": true,
79
"forceConsistentCasingInFileNames": true,
810
"declaration": true,
9-
"outDir": "lib",
1011
"moduleResolution": "node",
1112
"types": ["node", "jest"]
1213
},
13-
"include": ["src"]
14+
"include": ["src"],
15+
"exclude": ["node_modules", "lib"]
1416
}

0 commit comments

Comments
 (0)