@@ -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