Skip to content

Commit 4af841b

Browse files
committed
feat: export an esm module
1 parent e0fe1ee commit 4af841b

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

package.json

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,28 @@
4242
],
4343
"license": "ISC",
4444
"main": "index.js",
45+
"module": "index.esm.mjs",
46+
"exports": {
47+
"require": "./index.js",
48+
"import": "./index.esm.mjs"
49+
},
50+
"files": [
51+
"bin",
52+
"index.js",
53+
"index.esm.mjs"
54+
],
4555
"repository": {
4656
"type": "git",
4757
"url": "https://github.com/ungoldman/changelog-parser.git"
4858
},
4959
"scripts": {
5060
"release": "gh-release && npm publish",
51-
"test": "standard && node test | tap-spec"
61+
"test": "standard && node test | tap-spec",
62+
"build:imports:named": "sed -i \"s/const\\ \\(.*\\)\\ =\\ require('\\(.*\\)')\\.\\(.*\\)/import {\\3 as \\1} from '\\2'/g\" index.esm.mjs",
63+
"build:imports:defaults": "sed -i \"s/const\\ \\(.*\\)\\ =\\ require('\\(.*\\)')/import \\1 from '\\2'/g\" index.esm.mjs",
64+
"build:imports": "npm run build:imports:named && npm run build:imports:defaults",
65+
"build:exports": "sed -i 's/module.exports =/export default/' index.esm.mjs",
66+
"build": "cp index.js index.esm.mjs && npm run build:imports && npm run build:exports",
67+
"prepublishOnly": "npm build && npm test"
5268
}
5369
}

0 commit comments

Comments
 (0)