Skip to content

Commit f051377

Browse files
authored
Do not inline RegExp literals in loop assignment
Do not inline RegExp literals in loop assignment
2 parents 1ad7838 + 2209048 commit f051377

File tree

9 files changed

+1769
-2070
lines changed

9 files changed

+1769
-2070
lines changed

package.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@
1919
"watch": "gulp watch"
2020
},
2121
"devDependencies": {
22-
"@babel/core": "^7.1.0",
23-
"@babel/plugin-transform-block-scoping": "^7.0.0",
24-
"@babel/preset-env": "^7.1.0",
25-
"babel-core": "^7.0.0-bridge.0",
26-
"babel-jest": "^23.6.0",
22+
"@babel/core": "^7.9.0",
23+
"@babel/plugin-transform-block-scoping": "^7.8.3",
24+
"@babel/preset-env": "^7.9.0",
25+
"babel-jest": "^24.9.0",
2726
"butternut": "^0.4.6",
2827
"bytes": "^3.0.0",
2928
"chalk": "^2.4.1",
@@ -39,7 +38,7 @@
3938
"gulp": "github:gulpjs/gulp#4.0",
4039
"gulp-babel": "^8.0.0",
4140
"gulp-newer": "^1.4.0",
42-
"jest-cli": "^23.6.0",
41+
"jest-cli": "^24.9.0",
4342
"lerna": "^3.4.0",
4443
"lerna-changelog": "^0.8.0",
4544
"lint-staged": "^7.3.0",

packages/babel-plugin-minify-dead-code-elimination/__tests__/fixtures/issue-691-binary-in/expected.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
function foo(props) {
2-
let bar = "width" in props;
2+
let bar = ("width" in props);
33
delete props.width;
44

55
if (bar) {
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
function f(query) {
2+
var r = /./g,
3+
part;
4+
while (part = r.exec(query));
5+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
function f(query) {
2+
var r = /./g,
3+
part;
4+
5+
while (part = r.exec(query));
6+
}

packages/babel-plugin-minify-dead-code-elimination/src/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,8 @@ module.exports = ({ types: t, traverse }) => {
421421
const isObj = n =>
422422
t.isFunction(n) ||
423423
t.isObjectExpression(n) ||
424-
t.isArrayExpression(n);
424+
t.isArrayExpression(n) ||
425+
t.isRegExpLiteral(n);
425426

426427
const isReplacementObj =
427428
isObj(replacement) || some(replacement, isObj);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
for (let i = 0; i < 0; i++) {
2-
var i = 0;
2+
{ let i = 0 };
33
}
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
for (let i = 0; i < 0; i++) {
2-
var i = 0;
2+
{
3+
let i = 0;
4+
}
5+
;
36
}

packages/babel-preset-minify/__tests__/minify-env-tests.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,10 @@ describe("preset along with env", () => {
212212
`,
213213
`
214214
function foo() {
215-
var b = console;
215+
var a = console;
216216
return {
217-
a: function d(c) {
218-
b.log(c);
217+
a: function a(b) {
218+
a.log(b);
219219
}
220220
};
221221
}

yarn.lock

Lines changed: 1742 additions & 2057 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)