@@ -1081,7 +1081,24 @@ Generated by [AVA](https://avajs.dev).
1081
1081
> Snapshot 1
1082
1082
1083
1083
{
1084
- 'generated-lib2.js': `'use strict';␊
1084
+ 'main.js': `'use strict';␊
1085
+ ␊
1086
+ var main2 = require('./main2.js');␊
1087
+ ␊
1088
+ /* eslint-disable import/no-dynamic-require, global-require */␊
1089
+ ␊
1090
+ let message;␊
1091
+ ␊
1092
+ for (const index of [1, 2]) {␊
1093
+ try {␊
1094
+ message = main2.createCommonjsRequire("/fixtures/function/dynamic-require-code-splitting")(\`./target${index}.js\`);␊
1095
+ } catch (err) {␊
1096
+ ({ message } = err);␊
1097
+ }␊
1098
+ t.is(message, index.toString());␊
1099
+ }␊
1100
+ `,
1101
+ 'main2.js': `'use strict';␊
1085
1102
␊
1086
1103
var target1;␊
1087
1104
var hasRequiredTarget1;␊
@@ -1211,28 +1228,6 @@ Generated by [AVA](https://avajs.dev).
1211
1228
␊
1212
1229
exports.createCommonjsRequire = createCommonjsRequire;␊
1213
1230
`,
1214
- 'main.js': `'use strict';␊
1215
- ␊
1216
- var lib2 = require('./generated-lib2.js');␊
1217
- ␊
1218
- /* eslint-disable import/no-dynamic-require, global-require */␊
1219
- ␊
1220
- let message;␊
1221
- ␊
1222
- for (const index of [1, 2]) {␊
1223
- try {␊
1224
- message = lib2.createCommonjsRequire("/fixtures/function/dynamic-require-code-splitting")(\`./target${index}.js\`);␊
1225
- } catch (err) {␊
1226
- ({ message } = err);␊
1227
- }␊
1228
- t.is(message, index.toString());␊
1229
- }␊
1230
- `,
1231
- 'main2.js': `'use strict';␊
1232
- ␊
1233
- require('./generated-lib2.js');␊
1234
- ␊
1235
- `,
1236
1231
}
1237
1232
1238
1233
## dynamic-require-different-loader
@@ -1511,6 +1506,7 @@ Generated by [AVA](https://avajs.dev).
1511
1506
␊
1512
1507
/* eslint-disable import/no-dynamic-require, global-require */␊
1513
1508
␊
1509
+ ␊
1514
1510
t.is(result, 'submodule');␊
1515
1511
`,
1516
1512
}
@@ -3454,6 +3450,9 @@ Generated by [AVA](https://avajs.dev).
3454
3450
const getGlobalPollution = () => 'foo';␊
3455
3451
␊
3456
3452
// this test makes sure that "submodule" is not wrapped in commonjs␊
3453
+ // helper due to its use of "typeof module", given that "submodule" has es6 exports.␊
3454
+ // any attempt to wrap it in a function will just fail as it's invalid syntax.␊
3455
+ ␊
3457
3456
␊
3458
3457
t.is(getGlobalPollution(), global.pollution);␊
3459
3458
`,
@@ -4023,11 +4022,11 @@ Generated by [AVA](https://avajs.dev).
4023
4022
{
4024
4023
'main.js': `'use strict';␊
4025
4024
␊
4026
- var other = require('./other-77ad7026 .js');␊
4025
+ var other = require('./other.js');␊
4027
4026
␊
4028
- t.is(other.foo , 'foo');␊
4027
+ t.is(other, 'foo');␊
4029
4028
`,
4030
- 'other-77ad7026 .js': `'use strict';␊
4029
+ 'other.js': `'use strict';␊
4031
4030
␊
4032
4031
function getDefaultExportFromCjs (x) {␊
4033
4032
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;␊
@@ -4037,15 +4036,7 @@ Generated by [AVA](https://avajs.dev).
4037
4036
␊
4038
4037
var foo = /*@__PURE__*/getDefaultExportFromCjs(other);␊
4039
4038
␊
4040
- exports.foo = foo;␊
4041
- `,
4042
- 'other.js': `'use strict';␊
4043
- ␊
4044
- var other = require('./other-77ad7026.js');␊
4045
- ␊
4046
- ␊
4047
- ␊
4048
- module.exports = other.foo;␊
4039
+ module.exports = foo;␊
4049
4040
`,
4050
4041
}
4051
4042
@@ -5124,6 +5115,16 @@ Generated by [AVA](https://avajs.dev).
5124
5115
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;␊
5125
5116
}␊
5126
5117
␊
5118
+ var foo;␊
5119
+ var hasRequiredFoo;␊
5120
+ ␊
5121
+ function requireFoo () {␊
5122
+ if (hasRequiredFoo) return foo;␊
5123
+ hasRequiredFoo = 1;␊
5124
+ foo = 1;␊
5125
+ return foo;␊
5126
+ }␊
5127
+ ␊
5127
5128
var multiply;␊
5128
5129
var hasRequiredMultiply;␊
5129
5130
␊
@@ -5136,16 +5137,6 @@ Generated by [AVA](https://avajs.dev).
5136
5137
return multiply;␊
5137
5138
}␊
5138
5139
␊
5139
- var foo;␊
5140
- var hasRequiredFoo;␊
5141
- ␊
5142
- function requireFoo () {␊
5143
- if (hasRequiredFoo) return foo;␊
5144
- hasRequiredFoo = 1;␊
5145
- foo = 1;␊
5146
- return foo;␊
5147
- }␊
5148
- ␊
5149
5140
/* eslint-disable global-require */␊
5150
5141
␊
5151
5142
var main = function () {␊
@@ -5930,45 +5921,31 @@ Generated by [AVA](https://avajs.dev).
5930
5921
> Snapshot 1
5931
5922
5932
5923
{
5933
- '_virtual/_commonjsHelpers .js': `'use strict';␊
5924
+ 'main .js': `'use strict';␊
5934
5925
␊
5935
5926
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};␊
5936
5927
␊
5937
5928
function getDefaultExportFromCjs (x) {␊
5938
5929
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;␊
5939
5930
}␊
5940
5931
␊
5941
- exports.commonjsGlobal = commonjsGlobal;␊
5942
- exports.getDefaultExportFromCjs = getDefaultExportFromCjs;␊
5943
- `,
5944
- 'main.js': `'use strict';␊
5945
- ␊
5946
- var _commonjsHelpers = require('./_virtual/_commonjsHelpers.js');␊
5947
- var main$1 = require('./main2.js');␊
5948
- ␊
5949
- var mainExports = main$1.__require();␊
5950
- var main = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(mainExports);␊
5951
- ␊
5952
- module.exports = main;␊
5953
- `,
5954
- 'main2.js': `'use strict';␊
5955
- ␊
5956
- var _commonjsHelpers = require('./_virtual/_commonjsHelpers.js');␊
5957
- ␊
5958
- var main;␊
5932
+ var main$1;␊
5959
5933
var hasRequiredMain;␊
5960
5934
␊
5961
5935
function requireMain () {␊
5962
- if (hasRequiredMain) return main;␊
5936
+ if (hasRequiredMain) return main$1 ;␊
5963
5937
hasRequiredMain = 1;␊
5964
- _commonjsHelpers. commonjsGlobal.main = 'main';␊
5938
+ commonjsGlobal.main = 'main';␊
5965
5939
console.log('main');␊
5966
5940
␊
5967
- main = 'main';␊
5968
- return main;␊
5941
+ main$1 = 'main';␊
5942
+ return main$1 ;␊
5969
5943
}␊
5970
5944
␊
5971
- exports.__require = requireMain;␊
5945
+ var mainExports = requireMain();␊
5946
+ var main = /*@__PURE__*/getDefaultExportFromCjs(mainExports);␊
5947
+ ␊
5948
+ module.exports = main;␊
5972
5949
`,
5973
5950
}
5974
5951
0 commit comments