diff --git a/packages/multi-entry/src/index.js b/packages/multi-entry/src/index.js index dec066ac4..c53f6e8fd 100755 --- a/packages/multi-entry/src/index.js +++ b/packages/multi-entry/src/index.js @@ -60,7 +60,9 @@ export default function multiEntry(conf = {}) { buildStart(options) { const patterns = config.include.concat(config.exclude.map((pattern) => `!${pattern}`)); const entries = patterns.length - ? matched(patterns, { realpath: true }).then((paths) => paths.map(exporter).join('\n')) + ? matched(patterns, { realpath: true }).then((paths) => + paths.sort().map(exporter).join('\n') + ) : Promise.resolve(''); virtualisedEntry = virtual({ [options.input]: entries }); diff --git a/packages/multi-entry/test/test.mjs b/packages/multi-entry/test/test.mjs index 9addd6dad..399062053 100755 --- a/packages/multi-entry/test/test.mjs +++ b/packages/multi-entry/test/test.mjs @@ -131,3 +131,19 @@ test('makes a bundle with entryFileName as the output.entryFileName when preserv t.truthy(nonVirtualFiles.find(({ fileName }) => fileName === 'entry-0.js')); t.truthy(nonVirtualFiles.find(({ fileName }) => fileName === 'entry-1.js')); }); + +test('deterministic output, regardless of input order', async (t) => { + const bundle1 = await rollup({ + input: 'test/fixtures/{0,1}.js', + plugins: [multiEntry()] + }); + const code1 = await getCode(bundle1); + + const bundle2 = await rollup({ + input: 'test/fixtures/{1,0}.js', + plugins: [multiEntry()] + }); + const code2 = await getCode(bundle2); + + t.is(code1, code2); +});