Skip to content

Commit 5896fd5

Browse files
committed
Add cjs cupport as conditional exports
1 parent c53e475 commit 5896fd5

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

package.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818
"license": "MIT",
1919
"type": "module",
2020
"main": "lib/dateformat.js",
21+
"exports": {
22+
"node": {
23+
"import": "./lib/dateformat.js",
24+
"require": "./lib/dateformat.cjs"
25+
}
26+
},
2127
"devDependencies": {
2228
"@babel/cli": "^7.14.8",
2329
"@babel/core": "^7.15.0",
@@ -29,7 +35,9 @@
2935
"node": ">=12.20"
3036
},
3137
"scripts": {
32-
"build": "./node_modules/.bin/babel src --out-dir lib && uglifyjs lib/dateformat.js -o lib/dateformat.js",
38+
"build": "npm run build:esm && npm run build:cjs",
39+
"build:esm": "./node_modules/.bin/babel src --out-dir lib && uglifyjs lib/dateformat.js -o lib/dateformat.js",
40+
"build:cjs": "./node_modules/.bin/babel src/dateformat.js -o lib/dateformat.cjs && uglifyjs lib/dateformat.cjs -o lib/dateformat.cjs",
3341
"test": "npm run build && mocha",
3442
"benchmark": "npm run build && node ./benchmark/benchmark.js"
3543
},

0 commit comments

Comments
 (0)