Skip to content

Commit 0f5c921

Browse files
filipesilvahansl
authored andcommitted
fix(@angular-devkit/build-optimizer): remove enum regexes
They were computationally expensive and returning false negatives. Fix angular#10605
1 parent 49690a6 commit 0f5c921

File tree

1 file changed

+2
-25
lines changed
  • packages/angular_devkit/build_optimizer/src/transforms

1 file changed

+2
-25
lines changed

packages/angular_devkit/build_optimizer/src/transforms/wrap-enums.ts

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,8 @@ import { drilldownNodes } from '../helpers/ast-utils';
1010

1111

1212
export function testWrapEnums(content: string) {
13-
const ts22EnumVarDecl = /var (\S+) = \{\};/;
14-
// tslint:disable-next-line:max-line-length
15-
const ts22EnumIife = /(\1\.(\S+) = \d+;\r?\n)+\1\[\1\.(\S+)\] = "\4";\r?\n(\1\[\1\.(\S+)\] = "\S+";\r?\n*)+/;
16-
const ts23To26VarDecl = /var (\S+);(\/\*@__PURE__\*\/)*/;
17-
// tslint:disable-next-line:max-line-length
18-
const ts23To26Iife = /\(function \(\1\) \{\s+(\1\[\1\["(\S+)"\] = (\S+)\] = "\4";(\s+\1\[\1\["\S+"\] = (\S+)\] = "\S+";)*\r?\n)\}\)\(\1 \|\| \(\1 = \{\}\)\);/;
19-
const enumComment = /\/\*\* @enum \{\w+\} \*\//;
20-
const multiLineComment = /\s*(?:\/\*[\s\S]*?\*\/)?\s*/;
21-
const newLine = /\s*\r?\n\s*/;
22-
23-
const regexes = [
24-
[
25-
ts22EnumVarDecl,
26-
newLine, multiLineComment,
27-
ts22EnumIife,
28-
],
29-
[
30-
ts23To26VarDecl,
31-
newLine, multiLineComment,
32-
ts23To26Iife,
33-
],
34-
[enumComment],
35-
].map(arr => new RegExp(arr.map(x => x.source).join(''), 'm'));
36-
37-
return regexes.some((regex) => regex.test(content));
13+
// TODO: remove this method, it's not doing anything anymore.
14+
return true;
3815
}
3916

4017
function isBlockLike(node: ts.Node): node is ts.BlockLike {

0 commit comments

Comments
 (0)