Skip to content

Commit 62fc67c

Browse files
committed
refactor: switch to native ESM with exports
Removes unneeded devDeps. and `module` property; switches to cjs extension for CommonJS build
1 parent cb6d03e commit 62fc67c

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
/node_modules
22
/package-lock.json
3-
index.cjs.js
3+
index.cjs

constructor/build.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import path from "path";
22
import { rollup } from "rollup";
33

4-
const PATH_ROOT = path.resolve(__dirname, "../");
4+
const PATH_ROOT = path.resolve(import.meta.dirname, "../");
55

66
let inputOptions = {
77
input: path.resolve(PATH_ROOT, "index.js"),
@@ -10,10 +10,10 @@ let inputOptions = {
1010

1111
let outputOptions = {
1212
output: {
13-
file: path.resolve(PATH_ROOT, "index.cjs.js"),
13+
file: path.resolve(PATH_ROOT, "index.cjs"),
1414
format: "cjs",
15-
banner: "// DO NOT edit this file, it's auto generate from 'constructor/build.js', any changes will be overwrite. \n"
15+
banner: "// DO NOT edit this file, it's auto-generated from 'constructor/build.js'; any changes will be overwritten. \n"
1616
}
1717
}
1818

19-
rollup(inputOptions).then(bundle => bundle.write(outputOptions));
19+
rollup(inputOptions).then(bundle => bundle.write(outputOptions));

package.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@
33
"description": "Modern, fast React.js JSX parser",
44
"homepage": "https://github.com/acornjs/acorn-jsx",
55
"version": "5.3.2",
6+
"type": "module",
67
"main": "index.cjs.js",
7-
"module": "index.js",
8+
"exports": {
9+
"import": "./index.js",
10+
"require": "./index.cjs"
11+
},
812
"maintainers": [
913
{
1014
"name": "Ingvar Stepanyan",
@@ -18,16 +22,14 @@
1822
},
1923
"license": "MIT",
2024
"scripts": {
21-
"test": "node -r esm test/run.js",
22-
"prepublishOnly": "node -r esm constructor/build.js"
25+
"test": "node test/run.js",
26+
"prepublishOnly": "node constructor/build.js"
2327
},
2428
"peerDependencies": {
2529
"acorn": "^6.0.0 || ^7.0.0 || ^8.0.0"
2630
},
2731
"devDependencies": {
28-
"@rollup/plugin-commonjs": "^12.0.0",
2932
"acorn": "^8.0.1",
30-
"esm": "^3.2.25",
3133
"rollup": "^2.12.0"
3234
}
3335
}

0 commit comments

Comments
 (0)