Skip to content

Commit fab597c

Browse files
committed
Merge branch 'master' of https://github.com/rollup/rollup into sync-f224690e
2 parents ba134c8 + f224690 commit fab597c

File tree

76 files changed

+169
-93
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+169
-93
lines changed

test/chunking-form/index.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ const path = require('node:path');
55
// @ts-expect-error not included in types
66
const { rollup } = require('../../dist/rollup');
77
const { compareLogs } = require('../testHelpers');
8-
const { runTestSuiteWithSamples, assertDirectoriesAreEqual } = require('../testHelpers.js');
8+
const {
9+
runTestSuiteWithSamples,
10+
assertDirectoriesAreEqual,
11+
shuffle
12+
} = require('../testHelpers.js');
913

1014
const FORMATS = ['es', 'cjs', 'amd', 'system'];
1115

@@ -25,12 +29,12 @@ runTestSuiteWithSamples(
2529
after(config.after);
2630
}
2731
const logs = [];
32+
const warnings = [];
2833
after(() => config.logs && compareLogs(logs, config.logs));
2934

30-
for (const format of config.formats || FORMATS) {
35+
for (const format of shuffle(config.formats || FORMATS)) {
3136
it('generates ' + format, async () => {
3237
process.chdir(directory);
33-
const warnings = [];
3438
bundle =
3539
bundle ||
3640
(await rollup({
@@ -62,10 +66,10 @@ runTestSuiteWithSamples(
6266
for (const { code } of warnings) {
6367
codes.add(code);
6468
}
69+
const messages = warnings.map(({ message }) => `${message}\n\n`).join('');
70+
warnings.length = 0;
6571
throw new Error(
66-
`Unexpected warnings (${[...codes].join(', ')}): \n${warnings
67-
.map(({ message }) => `${message}\n\n`)
68-
.join('')}` +
72+
`Unexpected warnings (${[...codes].join(', ')}): \n${messages}` +
6973
'If you expect warnings, list their codes in config.expectedWarnings'
7074
);
7175
}

test/form/index.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ const path = require('node:path');
88
const { rollup } = require('../../dist/rollup');
99
const {
1010
compareLogs,
11+
getRandomElement,
1112
normaliseOutput,
1213
runTestSuiteWithSamples,
14+
shuffle,
1315
verifyAstPlugin
1416
} = require('../testHelpers.js');
1517

@@ -29,9 +31,9 @@ runTestSuiteWithSamples(
2931
() => {
3032
let bundle;
3133
const logs = [];
34+
const warnings = [];
3235

3336
const runRollupTest = async (inputFile, bundleFile, format, fromCache) => {
34-
const warnings = [];
3537
if (config.before) {
3638
await config.before();
3739
}
@@ -83,10 +85,11 @@ runTestSuiteWithSamples(
8385
for (const { code } of warnings) {
8486
codes.add(code);
8587
}
88+
const messages = warnings.map(({ message }) => `${message}\n\n`).join('');
89+
warnings.length = 0;
8690
throw new Error(
87-
`Unexpected warnings (${[...codes].join(', ')}): \n${warnings
88-
.map(({ message }) => `${message}\n\n`)
89-
.join('')}` + 'If you expect warnings, list their codes in config.expectedWarnings'
91+
`Unexpected warnings (${[...codes].join(', ')}): \n${messages}` +
92+
'If you expect warnings, list their codes in config.expectedWarnings'
9093
);
9194
}
9295
};
@@ -101,7 +104,8 @@ runTestSuiteWithSamples(
101104
.then(() => config.logs && compareLogs(logs, config.logs));
102105
}
103106

104-
for (const format of config.formats || FORMATS) {
107+
const formats = shuffle(config.formats || FORMATS);
108+
for (const format of formats) {
105109
after(() => config.logs && compareLogs(logs, config.logs));
106110

107111
it(`generates ${format}`, () =>
@@ -113,13 +117,13 @@ runTestSuiteWithSamples(
113117
));
114118
}
115119

116-
const format = (config.formats || FORMATS)[0];
120+
const format = getRandomElement(formats);
117121
it(`generates ${format} from the cache`, () =>
118122
runRollupTest(
119123
`${directory}/_actual/${format}.js`,
120124
`${directory}/_expected/${format}.js`,
121125
format,
122-
false
126+
true
123127
));
124128
}
125129
);

test/form/samples/amd-keep-extension/_config.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ module.exports = defineTest({
22
description: 'keep extension for AMD modules',
33
options: {
44
external: ['./relative', 'abso/lute', './relative.js', 'abso/lute.js'],
5-
output: { amd: { forceJsExtensionForImports: true }, interop: 'default' }
5+
output: {
6+
amd: { forceJsExtensionForImports: true },
7+
globals: id => id.split(/[/\\]/).pop().replace('.', '_'),
8+
interop: 'default'
9+
}
610
}
711
});

test/form/samples/amd-keep-extension/_expected/iife.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33

44
console.log(relative, absolute, relativeExtension, absoluteExtension);
55

6-
})(relative, absolute, relativeExtension, absoluteExtension);
6+
})(relative, lute, relative_js, lute_js);

test/form/samples/amd-keep-extension/_expected/umd.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
(function (global, factory) {
22
typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('./relative'), require('abso/lute'), require('./relative.js'), require('abso/lute.js')) :
33
typeof define === 'function' && define.amd ? define(['./relative.js', 'abso/lute', './relative.js', 'abso/lute.js'], factory) :
4-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.relative, global.absolute, global.relativeExtension, global.absoluteExtension));
4+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.relative, global.lute, global.relative_js, global.lute_js));
55
})(this, (function (relative, absolute, relativeExtension, absoluteExtension) { 'use strict';
66

77
console.log(relative, absolute, relativeExtension, absoluteExtension);

test/form/samples/arbitrary-module-namespace-identifiers/_config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ module.exports = defineTest({
44
expectedWarnings: ['CIRCULAR_DEPENDENCY'],
55
options: {
66
external: ['external'],
7-
output: { name: 'bundle' }
7+
output: {
8+
globals: { external: 'external' },
9+
name: 'bundle'
10+
}
811
}
912
});

test/form/samples/arbitrary-module-namespace-identifiers2/_config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ module.exports = defineTest({
44
options: {
55
external: ['external'],
66
output: {
7+
globals: { external: 'external' },
78
name: 'myBundle'
89
}
910
}

test/form/samples/dynamic-import-this-arrow/_config.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ module.exports = defineTest({
33
options: {
44
external: ['input', 'output'],
55
output: {
6+
dynamicImportInCjs: false,
67
generatedCode: { arrowFunctions: true },
7-
name: 'bundle',
8-
dynamicImportInCjs: false
8+
globals: { input: 'input', output: 'output' },
9+
name: 'bundle'
910
}
1011
}
1112
});

test/form/samples/dynamic-import-this-function/_config.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ module.exports = defineTest({
33
options: {
44
external: ['input', 'output'],
55
output: {
6+
dynamicImportInCjs: false,
67
generatedCode: { arrowFunctions: false },
7-
name: 'bundle',
8-
dynamicImportInCjs: false
8+
globals: { input: 'input', output: 'output' },
9+
name: 'bundle'
910
}
1011
}
1112
});

test/form/samples/generated-code-compact/arrow-functions-false/_config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ module.exports = defineTest({
1111
strictDeprecations: false,
1212
output: {
1313
compact: true,
14+
dynamicImportInCjs: false,
1415
generatedCode: { arrowFunctions: false },
1516
interop(id) {
1617
if (id === 'externalDefault') {
@@ -24,9 +25,9 @@ module.exports = defineTest({
2425
}
2526
return 'compat';
2627
},
28+
globals: id => id,
2729
name: 'bundle',
2830
noConflict: true,
29-
dynamicImportInCjs: false,
3031
systemNullSetters: false
3132
}
3233
},

0 commit comments

Comments
 (0)