Skip to content

Commit 33cd373

Browse files
GauBenshellscape
andauthored
feat(multi-entry)!: ensure deterministic order (#1879)
* feat: ensure multi-entry is deterministic * bump workflows * undo bump change --------- Co-authored-by: Andrew Powell <[email protected]>
1 parent 7ad5057 commit 33cd373

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

packages/multi-entry/src/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ export default function multiEntry(conf = {}) {
6060
buildStart(options) {
6161
const patterns = config.include.concat(config.exclude.map((pattern) => `!${pattern}`));
6262
const entries = patterns.length
63-
? matched(patterns, { realpath: true }).then((paths) => paths.map(exporter).join('\n'))
63+
? matched(patterns, { realpath: true }).then((paths) =>
64+
paths.sort().map(exporter).join('\n')
65+
)
6466
: Promise.resolve('');
6567

6668
virtualisedEntry = virtual({ [options.input]: entries });

packages/multi-entry/test/test.mjs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,19 @@ test('makes a bundle with entryFileName as the output.entryFileName when preserv
131131
t.truthy(nonVirtualFiles.find(({ fileName }) => fileName === 'entry-0.js'));
132132
t.truthy(nonVirtualFiles.find(({ fileName }) => fileName === 'entry-1.js'));
133133
});
134+
135+
test('deterministic output, regardless of input order', async (t) => {
136+
const bundle1 = await rollup({
137+
input: 'test/fixtures/{0,1}.js',
138+
plugins: [multiEntry()]
139+
});
140+
const code1 = await getCode(bundle1);
141+
142+
const bundle2 = await rollup({
143+
input: 'test/fixtures/{1,0}.js',
144+
plugins: [multiEntry()]
145+
});
146+
const code2 = await getCode(bundle2);
147+
148+
t.is(code1, code2);
149+
});

0 commit comments

Comments
 (0)