From 0129e9efd36477bbe6956992f88a444b979b6df9 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 20 Mar 2023 10:11:28 +0800 Subject: [PATCH] test: emit file in a random order --- .../emit-file/deduplicate-assets/_config.js | 35 ++++++------------- 1 file changed, 10 insertions(+), 25 deletions(-) diff --git a/test/chunking-form/samples/emit-file/deduplicate-assets/_config.js b/test/chunking-form/samples/emit-file/deduplicate-assets/_config.js index 53e5831b4e7..7fdfc9c6913 100644 --- a/test/chunking-form/samples/emit-file/deduplicate-assets/_config.js +++ b/test/chunking-form/samples/emit-file/deduplicate-assets/_config.js @@ -1,33 +1,18 @@ -function asyncify(callback) { - const time = Math.round(Math.random() * 100); - - return new Promise(resolve => { - setTimeout(() => { - callback(); - resolve(); - }, time); - }); -} module.exports = { description: 'deduplicates asset that have the same source', options: { input: ['main.js'], plugins: { - async buildStart() { - await Promise.all([ - asyncify(() => this.emitFile({ type: 'asset', name: 'string1.txt', source: 'string' })), - asyncify(() => this.emitFile({ type: 'asset', name: 'string2.txt', source: 'string' })), - asyncify(() => - this.emitFile({ type: 'asset', name: 'stringSameSource.txt', source: 'string' }) - ), - asyncify(() => - this.emitFile({ - type: 'asset', - name: 'sameStringAsBuffer.txt', - source: Buffer.from('string') // Test cross Buffer/string deduplication - }) - ) - ]); + buildStart() { + // emit 'string' source in a random order + this.emitFile({ type: 'asset', name: 'stringSameSource.txt', source: 'string' }); + this.emitFile({ type: 'asset', name: 'string2.txt', source: 'string' }); + this.emitFile({ type: 'asset', name: 'string1.txt', source: 'string' }); + this.emitFile({ + type: 'asset', + name: 'sameStringAsBuffer.txt', + source: Buffer.from('string') // Test cross Buffer/string deduplication + }); // Different string source this.emitFile({ type: 'asset', name: 'otherString.txt', source: 'otherString' });