Skip to content

Commit 68ce330

Browse files
committed
Merge branch 'master' of https://github.com/rollup/rollup into sync-7759f568
2 parents 39dc46a + 7759f56 commit 68ce330

File tree

138 files changed

+286
-154
lines changed

Some content is hidden

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

138 files changed

+286
-154
lines changed

test/cli/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,18 @@ async function runTest(config) {
5959
killSignal: 'SIGKILL'
6060
};
6161
const childProcess = config.spawnArgs
62-
? spawn('node', [rollupBinary, ...config.spawnArgs], spawnOptions)
62+
? spawn('node', [config.spawnScript || rollupBinary, ...config.spawnArgs], spawnOptions)
6363
: exec(config.command.replace(/(^| )rollup($| )/g, ` node ${rollupBinary} `), spawnOptions);
6464

6565
childProcess.stdout.on('data', data => {
66-
stdout += data;
66+
stdout += String(data);
6767
});
6868

6969
childProcess.stderr.on('data', async data => {
70-
stderr += data;
70+
stderr += String(data);
7171
if (config.abortOnStderr) {
7272
try {
73-
if (await config.abortOnStderr(data)) {
73+
if (await config.abortOnStderr(String(data))) {
7474
childProcess.kill('SIGTERM');
7575
}
7676
} catch (error) {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module.exports = defineTest({
22
description: 'allows output options to be prefixed with "output."',
3-
command: 'rollup main.js --output.format es --output.footer "console.log(\'Rollup!\')"'
3+
spawnArgs: ['main.js', '--output.format', 'es', '--output.footer', "console.log('Rollup!')"]
44
});

test/cli/samples/amd/_config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module.exports = defineTest({
22
description: 'sets AMD module ID and define function',
3-
command: 'rollup -i main.js -f amd --amd.id foo --amd.define defn'
3+
spawnArgs: ['-i', 'main.js', '-f', 'amd', '--amd.id', 'foo', '--amd.define', 'defn']
44
});
Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
module.exports = defineTest({
22
description: 'adds banner/intro/outro/footer',
3-
command:
4-
'rollup -i main.js -f iife --indent --banner "// banner" --intro "// intro" --outro "// outro" --footer "// footer"'
3+
spawnArgs: [
4+
'-i',
5+
'main.js',
6+
'-f',
7+
'iife',
8+
'--indent',
9+
'--banner',
10+
'// banner',
11+
'--intro',
12+
'// intro',
13+
'--outro',
14+
'// outro',
15+
'--footer',
16+
'// footer'
17+
]
518
});

test/cli/samples/code-splitting-named-default-inputs/_config.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,15 @@ const assert = require('node:assert');
22

33
module.exports = defineTest({
44
description: 'allows defining names via CLI',
5-
command:
6-
'rollup entry1=main1.js "Entry 2"="main 2.js" "main3.js" --entryFileNames [name]-[hash].js -f es',
5+
spawnArgs: [
6+
'entry1=main1.js',
7+
'Entry 2=main 2.js',
8+
'main3.js',
9+
'--entryFileNames',
10+
'[name]-[hash].js',
11+
'-f',
12+
'es'
13+
],
714
result(code) {
815
assert.equal(
916
code,

test/cli/samples/code-splitting-named-inputs/_config.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,18 @@ const assert = require('node:assert');
22

33
module.exports = defineTest({
44
description: 'allows defining names via CLI',
5-
command:
6-
'rollup --entryFileNames [name]-[hash].js --input entry1=main1.js -i "Entry 2"="main 2.js" -i "main3.js" -f es',
5+
spawnArgs: [
6+
'--entryFileNames',
7+
'[name]-[hash].js',
8+
'--input',
9+
'entry1=main1.js',
10+
'-i',
11+
'Entry 2=main 2.js',
12+
'-i',
13+
'main3.js',
14+
'-f',
15+
'es'
16+
],
717
result(code) {
818
assert.equal(
919
code,
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module.exports = defineTest({
22
description: 'supports using an async function as config',
3-
command: 'rollup -c'
3+
spawnArgs: ['-c']
44
});
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module.exports = defineTest({
22
description: 'does not transpile cjs configs and provides correct __filename',
3-
command: 'rollup -c'
3+
spawnArgs: ['-c']
44
});

test/cli/samples/config-cwd-case-insensitive-es6/_config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ function toggleCase(s) {
55
module.exports = defineTest({
66
onlyWindows: true,
77
description: "can load ES6 config with cwd that doesn't match realpath",
8-
command: 'rollup -c',
8+
spawnArgs: ['-c'],
99
cwd: __dirname.replace(/^[a-z]:\\/i, toggleCase),
1010
execute: true
1111
});

test/cli/samples/config-cwd-case-insensitive/_config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ function toggleCase(s) {
55
module.exports = defineTest({
66
onlyWindows: true,
77
description: "can load config with cwd that doesn't match realpath",
8-
command: 'rollup -c',
8+
spawnArgs: ['-c'],
99
cwd: __dirname.replace(/^[a-z]:\\/i, toggleCase),
1010
execute: true
1111
});
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = defineTest({
22
description: 'uses cjs config file which return config wrapped by defineConfig',
3-
command: 'rollup --config rollup.config.js',
3+
spawnArgs: ['--config', 'rollup.config.js'],
44
execute: true
55
});

test/cli/samples/config-defineConfig-mjs/_config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ const { hasEsBuild } = require('../../../testHelpers');
44
module.exports = defineTest({
55
skip: !hasEsBuild,
66
description: 'uses mjs config file which return config wrapped by defineConfig',
7-
command: 'rollup --config rollup.config.mjs',
7+
spawnArgs: ['--config', 'rollup.config.mjs'],
88
execute: true
99
});
Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
module.exports = defineTest({
22
description: 'passes environment variables to config file via multiple --environment values',
3-
command:
4-
'rollup --config --environment PRODUCTION,FOO:bar --environment SECOND,KEY:value --environment FOO:foo',
3+
spawnArgs: [
4+
'--config',
5+
'--environment',
6+
'PRODUCTION,FOO:bar',
7+
'--environment',
8+
'SECOND,KEY:value',
9+
'--environment',
10+
'FOO:foo'
11+
],
512
execute: true
613
});
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = defineTest({
22
description: 'passes environment variables to config file',
3-
command: 'rollup --config --environment PRODUCTION,FOO:bar,HOST:http://localhost:4000',
3+
spawnArgs: ['--config', '--environment', 'PRODUCTION,FOO:bar,HOST:http://localhost:4000'],
44
execute: true
55
});
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = defineTest({
22
description: 'uses ES6 module config file',
3-
command: 'rollup --config rollup.config.js --bundleConfigAsCjs',
3+
spawnArgs: ['--config', 'rollup.config.js', '--bundleConfigAsCjs'],
44
execute: true
55
});
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module.exports = defineTest({
22
description: 'external option gets passed from config',
3-
command: 'rollup -c -e assert,external-module'
3+
spawnArgs: ['-c', '-e', 'assert,external-module']
44
});
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module.exports = defineTest({
22
description: 'external option gets passed from config',
3-
command: 'rollup -c'
3+
spawnArgs: ['-c']
44
});
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = defineTest({
22
description: 'allows cleaning up and modifying the command args in the config file',
3-
command: 'rollup --config rollup.config.mjs --some-option="foo" --another-option=42',
3+
spawnArgs: ['--config', 'rollup.config.mjs', '--some-option="foo"', '--another-option=42'],
44
execute: true
55
});
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = defineTest({
22
description:
33
'if the config file returns a function then this will be called with the command args',
4-
command: 'rollup --config rollup.config.mjs --silent',
4+
spawnArgs: ['--config', 'rollup.config.mjs', '--silent'],
55
execute: true
66
});
Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
module.exports = defineTest({
22
description: 'supports modify the import attributes key in the config file',
3-
command:
4-
'rollup --config rollup.config.ts --configPlugin typescript --configImportAttributesKey with',
3+
spawnArgs: [
4+
'--config',
5+
'rollup.config.ts',
6+
'--configPlugin',
7+
'typescript',
8+
'--configImportAttributesKey',
9+
'with'
10+
],
511
minNodeVersion: 22
612
});
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module.exports = defineTest({
22
description: 'uses correct import.meta.{url,filename,dirname} in config files',
3-
command: 'rollup -c --bundleConfigAsCjs'
3+
spawnArgs: ['-c', '--bundleConfigAsCjs']
44
});
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = defineTest({
22
description: 'allows config file to import json',
3-
command: 'rollup --config rollup.config.js --bundleConfigAsCjs',
3+
spawnArgs: ['--config', 'rollup.config.js', '--bundleConfigAsCjs'],
44
execute: true
55
});

test/cli/samples/config-missing-export/_config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const assert = require('node:assert');
22

33
module.exports = defineTest({
44
description: 'throws error if config does not export an object',
5-
command: 'rollup -c',
5+
spawnArgs: ['-c'],
66
error(error) {
77
assert.ok(/Config file must export an options object/.test(error.message));
88
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module.exports = defineTest({
22
description: 'supports native esm as well as CJS plugins when using .mjs in Node 13+',
3-
command: 'rollup -c'
3+
spawnArgs: ['-c']
44
});
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = defineTest({
22
description: 'uses config file (.mjs)',
3-
command: 'rollup --config rollup.config.mjs',
3+
spawnArgs: ['--config', 'rollup.config.mjs'],
44
execute: true
55
});
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module.exports = defineTest({
22
description: 'returns correct file names for multiple outputs (#3467)',
3-
command: 'rollup -c'
3+
spawnArgs: ['-c']
44
});
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module.exports = defineTest({
22
description: 'correctly generates sourcemaps for multiple outputs',
3-
command: 'rollup -c --bundleConfigAsCjs'
3+
spawnArgs: ['-c', '--bundleConfigAsCjs']
44
});

test/cli/samples/config-no-output/_config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const { readFileSync, unlinkSync } = require('node:fs');
33

44
module.exports = defineTest({
55
description: 'uses -o from CLI',
6-
command: 'rollup -c -o output.js',
6+
spawnArgs: ['-c', '-o', 'output.js'],
77
test() {
88
const output = readFileSync('output.js', 'utf8');
99
assert.equal(output.trim(), 'console.log(42);');
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = defineTest({
22
description: 'overrides config file with command line arguments',
3-
command: 'rollup -c -i main.js -f cjs',
3+
spawnArgs: ['-c', '-i', 'main.js', '-f', 'cjs'],
44
execute: true
55
});
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module.exports = defineTest({
22
description: 'allows plugins to set options.entry',
3-
command: 'rollup -c --bundleConfigAsCjs'
3+
spawnArgs: ['-c', '--bundleConfigAsCjs']
44
});
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = defineTest({
22
description: 'uses cjs config file which returns a Promise',
3-
command: 'rollup --config rollup.config.cjs',
3+
spawnArgs: ['--config', 'rollup.config.cjs'],
44
execute: true
55
});
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = defineTest({
22
description: 'uses mjs config file which returns a Promise',
3-
command: 'rollup --config rollup.config.mjs',
3+
spawnArgs: ['--config', 'rollup.config.mjs'],
44
execute: true
55
});
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = defineTest({
22
description: 'uses config file which returns a Promise',
3-
command: 'rollup --config rollup.config.mjs',
3+
spawnArgs: ['--config', 'rollup.config.mjs'],
44
execute: true
55
});
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = defineTest({
22
description: 'defaults to rollup.config.js',
3-
command: 'rollup -c --bundleConfigAsCjs',
3+
spawnArgs: ['-c', '--bundleConfigAsCjs'],
44
execute: true
55
});

test/cli/samples/config-ts/_config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = defineTest({
22
description: 'supports loading TypeScript config files via plugin option',
3-
command: 'rollup --config rollup.config.ts --configPlugin typescript',
3+
spawnArgs: ['--config', 'rollup.config.ts', '--configPlugin', 'typescript'],
44
execute: true
55
});

test/cli/samples/config-warnings/_config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const { assertIncludes } = require('../../../testHelpers.js');
22

33
module.exports = defineTest({
44
description: 'displays warnings when a config is loaded',
5-
command: 'rollup -c --bundleConfigAsCjs',
5+
spawnArgs: ['-c', '--bundleConfigAsCjs'],
66
stderr: stderr =>
77
assertIncludes(
88
stderr,

test/cli/samples/config/_config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = defineTest({
22
description: 'uses config file',
3-
command: 'rollup --config rollup.config.js',
3+
spawnArgs: ['--config', 'rollup.config.js'],
44
execute: true
55
});

test/cli/samples/context/_config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module.exports = defineTest({
22
description: 'Uses --context to set `this` value',
3-
command: 'rollup main.js --format commonjs --context window'
3+
spawnArgs: ['main.js', '--format', 'commonjs', '--context', 'window']
44
});

test/cli/samples/custom-frame-with-pos/_config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const { assertIncludes } = require('../../../testHelpers.js');
22

33
module.exports = defineTest({
44
description: 'custom (plugin generated) code frame taking priority over pos generated one',
5-
command: 'rollup -c',
5+
spawnArgs: ['-c'],
66
error: () => true,
77
stderr: stderr =>
88
assertIncludes(

test/cli/samples/custom-frame/_config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const { assertIncludes } = require('../../../testHelpers.js');
22

33
module.exports = defineTest({
44
description: 'errors with plugin generated code frames also contain stack',
5-
command: 'rollup -c',
5+
spawnArgs: ['-c'],
66
error: () => true,
77
stderr: stderr => {
88
assertIncludes(
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module.exports = defineTest({
22
description: 'deconflict entry points with the same name in different directories',
3-
command: 'rollup --input main.js --input sub/main.js --format es --dir _actual'
3+
spawnArgs: ['--input', 'main.js', '--input', 'sub/main.js', '--format', 'es', '--dir', '_actual']
44
});

test/cli/samples/duplicate-import-options/_config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const { assertIncludes } = require('../../../testHelpers.js');
22

33
module.exports = defineTest({
44
description: 'throws if different types of entries are combined',
5-
command: 'rollup main.js --format es --input main.js',
5+
spawnArgs: ['main.js', '--format', 'es', '--input', 'main.js'],
66
error: () => true,
77
stderr(stderr) {
88
assertIncludes(stderr, '[!] Either use --input, or pass input path as argument');
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module.exports = defineTest({
22
description: 'writes files emitted by plugins in different output dirs',
3-
command: 'rollup -c'
3+
spawnArgs: ['-c']
44
});

test/cli/samples/empty-chunk-multiple/_config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const { assertIncludes } = require('../../../testHelpers.js');
22

33
module.exports = defineTest({
44
description: 'shows warning when multiple chunks empty',
5-
command: 'rollup -c',
5+
spawnArgs: ['-c'],
66
error: () => true,
77
stderr: stderr => assertIncludes(stderr, '(!) Generated empty chunks\n"main1" and "main2"')
88
});

test/cli/samples/empty-chunk/_config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const { assertIncludes } = require('../../../testHelpers.js');
22

33
module.exports = defineTest({
44
description: 'shows warning when chunk empty',
5-
command: 'rollup -c',
5+
spawnArgs: ['-c'],
66
error: () => true,
77
stderr: stderr => assertIncludes(stderr, '(!) Generated an empty chunk\n"main"')
88
});

0 commit comments

Comments
 (0)