Skip to content

Commit d01ac68

Browse files
committed
chore(client): add comments to test and make test work
1 parent fea8d93 commit d01ac68

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

test/client/bundle.test.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ const isWebpack5 = require('../helpers/isWebpack5');
99

1010
describe('bundle', () => {
1111
// the ES5 check test for the bundle will not work on webpack@5,
12-
// because webpack@5 bundle output uses some ES6 syntax
12+
// because webpack@5 bundle output uses some ES6 syntax that can
13+
// only be avoided with babel-loader
1314
const runBundleTest = isWebpack5 ? describe.skip : describe;
1415

1516
runBundleTest('bundled output', () => {
@@ -34,19 +35,23 @@ describe('bundle', () => {
3435
acorn.parse(text, {
3536
ecmaVersion: 5,
3637
onToken: (token) => {
38+
// a webpack bundle is a series of evaluated JavaScript
39+
// strings like this: eval('...')
40+
// if we want the bundle to work using ES5, we need to
41+
// check that these strings are good with ES5 as well
42+
43+
// this can be done by waiting for tokens during the main parse
44+
// then when we hit a string in an 'eval' function we also try
45+
// to parse that string with ES5
3746
if (token.type.label === 'name' && token.value === 'eval') {
3847
evalStep += 1;
3948
} else if (token.type.label === '(' && evalStep === 1) {
4049
evalStep += 1;
4150
} else if (token.type.label === 'string' && evalStep === 2) {
4251
const program = token.value;
43-
try {
44-
acorn.parse(program, {
45-
ecmaVersion: 5,
46-
});
47-
} catch (e) {
48-
console.log(program);
49-
}
52+
acorn.parse(program, {
53+
ecmaVersion: 5,
54+
});
5055

5156
evalStep = 0;
5257
}

0 commit comments

Comments
 (0)