Skip to content

Commit b79a123

Browse files
authored
Update build script (#2235)
1 parent 7c993aa commit b79a123

File tree

4 files changed

+234
-220
lines changed

4 files changed

+234
-220
lines changed

build/rollup.config.js

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
1-
import { resolve, dirname } from "path";
21
import url from "url";
32

43
import nodeResolve from "@rollup/plugin-node-resolve";
54
import commonjs from "@rollup/plugin-commonjs";
6-
import alias from "rollup-plugin-alias";
7-
import inject from "rollup-plugin-inject";
8-
import replace from "rollup-plugin-replace";
9-
import babel from "rollup-plugin-babel";
10-
import json from "rollup-plugin-json";
11-
import { terser } from "rollup-plugin-terser";
5+
import alias from "@rollup/plugin-alias";
6+
import inject from "@rollup/plugin-inject";
7+
import replace from "@rollup/plugin-replace";
8+
import babel from "@rollup/plugin-babel";
9+
import json from "@rollup/plugin-json";
10+
import terser from "@rollup/plugin-terser";
1211

13-
const __dirname = dirname(url.fileURLToPath(import.meta.url));
14-
const SRC_DIR = resolve(__dirname, "..", "src");
15-
const BUILD_DIR = resolve(__dirname, "..", "build");
12+
const getPath = (file) => url.fileURLToPath(new URL(file, import.meta.url));
1613

1714
export default {
18-
input: resolve(SRC_DIR, "index.js"),
15+
input: getPath("../src/index.js"),
1916
output: {
2017
file: "standalone.js",
2118
format: "umd",
@@ -35,18 +32,18 @@ export default {
3532
}),
3633
commonjs(),
3734
alias({
38-
entries: [
39-
{ find: "assert", replacement: resolve(BUILD_DIR, "shims/assert.js") },
40-
],
35+
entries: [{ find: "assert", replacement: getPath("./shims/assert.js") }],
4136
}),
4237
inject({
43-
Buffer: resolve(BUILD_DIR, "shims/buffer.js"),
38+
Buffer: getPath("./shims/buffer.js"),
4439
}),
4540
replace({
41+
preventAssignment: true,
4642
"process.arch": JSON.stringify("x32"),
4743
}),
4844
json(),
4945
babel({
46+
babelHelpers: "bundled",
5047
babelrc: false,
5148
plugins: [],
5249
compact: false,

package.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,15 @@
2626
"php-parser": "^3.1.5"
2727
},
2828
"devDependencies": {
29-
"@babel/preset-env": "^7.22.10",
29+
"@babel/preset-env": "^7.22.14",
30+
"@rollup/plugin-alias": "^5.0.0",
31+
"@rollup/plugin-babel": "^6.0.3",
3032
"@rollup/plugin-commonjs": "^25.0.4",
31-
"@rollup/plugin-node-resolve": "^15.1.0",
33+
"@rollup/plugin-inject": "^5.0.3",
34+
"@rollup/plugin-json": "^6.0.0",
35+
"@rollup/plugin-node-resolve": "^15.2.1",
36+
"@rollup/plugin-replace": "^5.0.2",
37+
"@rollup/plugin-terser": "^0.4.3",
3238
"codecov": "3.8.3",
3339
"cross-env": "^7.0.2",
3440
"eslint": "8.47.0",
@@ -42,13 +48,7 @@
4248
"jest-light-runner": "^0.5.0",
4349
"jest-snapshot-serializer-raw": "^1.1.0",
4450
"prettier": "^3.0.1",
45-
"rollup": "^2.75.7",
46-
"rollup-plugin-alias": "^2.0.0",
47-
"rollup-plugin-babel": "^4.3.2",
48-
"rollup-plugin-inject": "^3.0.1",
49-
"rollup-plugin-json": "^4.0.0",
50-
"rollup-plugin-replace": "^2.1.0",
51-
"rollup-plugin-terser": "^7.0.2",
51+
"rollup": "^3.28.1",
5252
"strip-ansi": "^7.1.0"
5353
},
5454
"peerDependencies": {
@@ -63,10 +63,10 @@
6363
"fix:prettier": "prettier . --write",
6464
"test": "yarn test:node && yarn test:standalone",
6565
"test:node": "jest",
66-
"test:standalone": "yarn run build-standalone && cross-env RUN_STANDALONE_TESTS=true yarn jest",
66+
"test:standalone": "yarn run build && cross-env RUN_STANDALONE_TESTS=true yarn jest",
6767
"prepublishOnly": "yarn test",
6868
"prettier": "prettier --plugin=src/index.js --parser=php",
69-
"build-standalone": "rollup -c build/rollup.config.js",
69+
"build": "rollup --config build/rollup.config.js",
7070
"debug": "node --inspect-brk node_modules/.bin/jest --runInBand"
7171
}
7272
}

src/needs-parens.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import assert from "assert";
21
import { getPrecedence, shouldFlatten, isBitwiseOperator } from "./util.js";
32

43
function needsParens(path) {
@@ -92,8 +91,6 @@ function needsParens(path) {
9291
}
9392

9493
if (pp === np && key === "right") {
95-
assert.strictEqual(parent.right, node);
96-
9794
return true;
9895
}
9996

0 commit comments

Comments
 (0)