From 89ee52cab11f0a35f05393bf119cf611ef029e83 Mon Sep 17 00:00:00 2001 From: dnalborczyk Date: Sun, 6 Feb 2022 23:59:14 -0500 Subject: [PATCH] refactor: use fs.promises in resolve id, Part 4 (#4386) * refactor: use fs.promises in resolve id * Make chunk variable names deterministic, sort watchfiles in tests * Fix order of mixed export warnings * Make tests Node 10 compatible * remove test generated file Co-authored-by: Lukas Taegert-Atkinson Co-authored-by: Lukas Taegert-Atkinson --- cli/run/batchWarnings.ts | 1 + src/Chunk.ts | 19 +- src/Module.ts | 7 +- src/ModuleLoader.ts | 38 +-- src/utils/resolveId.ts | 21 +- ...d-secondName.js => generated-firstName.js} | 0 .../_expected/amd/mainChunk.js | 4 +- .../_expected/amd/other.js | 2 +- ...d-secondName.js => generated-firstName.js} | 0 .../_expected/cjs/mainChunk.js | 4 +- .../_expected/cjs/other.js | 2 +- ...d-secondName.js => generated-firstName.js} | 0 .../_expected/es/mainChunk.js | 2 +- .../_expected/es/other.js | 2 +- ...d-secondName.js => generated-firstName.js} | 0 .../_expected/system/mainChunk.js | 2 +- .../_expected/system/other.js | 2 +- .../warn-mixed-exports-multiple/_config.js | 2 +- test/cli/samples/watch/bundle-error/main.js | 1 - .../watch/watch-config-error/_config.js | 3 +- .../circular-missed-reexports-2/_config.js | 4 +- .../named-import/_config.js | 2 +- .../samples/default-not-reexported/_config.js | 4 +- .../chunk-filename-not-available/_config.js | 5 +- .../deprecated/manual-chunks-info/_config.js | 198 ++++++++-------- .../deprecated/plugin-module-ids/_config.js | 4 +- .../samples/double-default-export/_config.js | 2 +- .../samples/double-named-export/_config.js | 2 +- .../samples/double-named-reexport/_config.js | 2 +- .../chunk-filename-not-available/_config.js | 5 +- .../set-asset-source-chunk/_config.js | 5 +- .../_config.js | 2 +- .../samples/error-parse-json/_config.js | 2 +- .../error-parse-unknown-extension/_config.js | 2 +- .../_config.js | 4 +- .../_config.js | 4 +- .../dependant-not-part-of-graph/_config.js | 4 +- .../import-of-unexported-fails/_config.js | 2 +- .../max-parallel-file-reads-error/_config.js | 2 +- .../plugin-module-information/_config.js | 221 +++++++++--------- .../samples/reassign-import-fails/_config.js | 2 +- .../_config.js | 2 +- .../samples/reexport-missing-error/_config.js | 2 +- .../circular-synthetic-exports/_config.js | 2 +- .../synthetic-exports-need-default/_config.js | 2 +- .../_config.js | 2 +- .../_config.js | 2 +- test/utils.js | 3 + 48 files changed, 312 insertions(+), 293 deletions(-) rename test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/amd/{generated-secondName.js => generated-firstName.js} (100%) rename test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/cjs/{generated-secondName.js => generated-firstName.js} (100%) rename test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/es/{generated-secondName.js => generated-firstName.js} (100%) rename test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/system/{generated-secondName.js => generated-firstName.js} (100%) delete mode 100644 test/cli/samples/watch/bundle-error/main.js diff --git a/cli/run/batchWarnings.ts b/cli/run/batchWarnings.ts index 742196da31c..a18e2e87197 100644 --- a/cli/run/batchWarnings.ts +++ b/cli/run/batchWarnings.ts @@ -142,6 +142,7 @@ const deferredHandlers: { title('Mixing named and default exports'); info(`https://rollupjs.org/guide/en/#outputexports`); stderr(bold('The following entry modules are using named and default exports together:')); + warnings.sort((a, b) => (a.id! < b.id! ? -1 : 1)); const displayedWarnings = warnings.length > 5 ? warnings.slice(0, 3) : warnings; for (const warning of displayedWarnings) { stderr(relativeId(warning.id!)); diff --git a/src/Chunk.ts b/src/Chunk.ts index 2b6d2e7279a..1f743577fe4 100644 --- a/src/Chunk.ts +++ b/src/Chunk.ts @@ -329,9 +329,14 @@ export default class Chunk { } } for (const module of entryModules) { - const requiredFacades: FacadeName[] = Array.from(module.userChunkNames, name => ({ - name - })); + const requiredFacades: FacadeName[] = Array.from( + new Set( + module.chunkNames.filter(({ isUserDefined }) => isUserDefined).map(({ name }) => name) + ), + name => ({ + name + }) + ); if (requiredFacades.length === 0 && module.isUserDefinedEntryPoint) { requiredFacades.push({}); } @@ -959,7 +964,7 @@ export default class Chunk { this.dynamicEntryModules[0] || this.orderedModules[this.orderedModules.length - 1]; if (moduleForNaming) { - return moduleForNaming.chunkName || getAliasName(moduleForNaming.id); + return getChunkNameFromModule(moduleForNaming); } return 'chunk'; } @@ -1398,7 +1403,11 @@ export default class Chunk { } function getChunkNameFromModule(module: Module): string { - return module.chunkName || getAliasName(module.id); + return ( + module.chunkNames.find(({ isUserDefined }) => isUserDefined)?.name ?? + module.chunkNames[0]?.name ?? + getAliasName(module.id) + ); } const QUERY_HASH_REGEX = /[?#]/; diff --git a/src/Module.ts b/src/Module.ts index d9f454bd853..056217768e5 100644 --- a/src/Module.ts +++ b/src/Module.ts @@ -189,7 +189,11 @@ export default class Module { readonly alternativeReexportModules = new Map(); ast: Program | null = null; readonly chunkFileNames = new Set(); - chunkName: string | null = null; + chunkNames: { + isUserDefined: boolean; + name: string; + priority: number; + }[] = []; readonly cycles = new Set(); readonly dependencies = new Set(); readonly dynamicDependencies = new Set(); @@ -222,7 +226,6 @@ export default class Module { declare sourcemapChain: DecodedSourceMapOrMissing[]; readonly sources = new Set(); declare transformFiles?: EmittedFile[]; - readonly userChunkNames = new Set(); usesTopLevelAwait = false; private allExportNames: Set | null = null; diff --git a/src/ModuleLoader.ts b/src/ModuleLoader.ts index ca347b60e5f..efa402f6a80 100644 --- a/src/ModuleLoader.ts +++ b/src/ModuleLoader.ts @@ -70,6 +70,7 @@ export class ModuleLoader { private latestLoadModulesPromise: Promise = Promise.resolve(); private readonly moduleLoadPromises = new Map(); private readonly modulesWithLoadedDependencies = new Set(); + private nextChunkNamePriority = 0; private nextEntryModuleIndex = 0; private readonly readQueue: Queue; @@ -104,27 +105,38 @@ export class ModuleLoader { }> { const firstEntryModuleIndex = this.nextEntryModuleIndex; this.nextEntryModuleIndex += unresolvedEntryModules.length; + const firstChunkNamePriority = this.nextChunkNamePriority; + this.nextChunkNamePriority += unresolvedEntryModules.length; const newEntryModules = await this.extendLoadModulesPromise( Promise.all( unresolvedEntryModules.map(({ id, importer }) => this.loadEntryModule(id, true, importer, null) ) ).then(entryModules => { - let moduleIndex = firstEntryModuleIndex; for (let index = 0; index < entryModules.length; index++) { const entryModule = entryModules[index]; entryModule.isUserDefinedEntryPoint = entryModule.isUserDefinedEntryPoint || isUserDefined; - addChunkNamesToModule(entryModule, unresolvedEntryModules[index], isUserDefined); + addChunkNamesToModule( + entryModule, + unresolvedEntryModules[index], + isUserDefined, + firstChunkNamePriority + index + ); const existingIndexedModule = this.indexedEntryModules.find( indexedModule => indexedModule.module === entryModule ); if (!existingIndexedModule) { - this.indexedEntryModules.push({ index: moduleIndex, module: entryModule }); + this.indexedEntryModules.push({ + index: firstEntryModuleIndex + index, + module: entryModule + }); } else { - existingIndexedModule.index = Math.min(existingIndexedModule.index, moduleIndex); + existingIndexedModule.index = Math.min( + existingIndexedModule.index, + firstEntryModuleIndex + index + ); } - moduleIndex++; } this.indexedEntryModules.sort(({ index: indexA }, { index: indexB }) => indexA > indexB ? 1 : -1 @@ -207,10 +219,11 @@ export class ModuleLoader { unresolvedModule: UnresolvedModule, implicitlyLoadedAfter: readonly string[] ): Promise { + const chunkNamePriority = this.nextChunkNamePriority++; return this.extendLoadModulesPromise( this.loadEntryModule(unresolvedModule.id, false, unresolvedModule.importer, null).then( async entryModule => { - addChunkNamesToModule(entryModule, unresolvedModule, false); + addChunkNamesToModule(entryModule, unresolvedModule, false, chunkNamePriority); if (!entryModule.info.isEntry) { this.implicitEntryModules.add(entryModule); const implicitlyLoadedAfterModules = await Promise.all( @@ -688,17 +701,16 @@ function normalizeRelativeExternalId(source: string, importer: string | undefine function addChunkNamesToModule( module: Module, { fileName, name }: UnresolvedModule, - isUserDefined: boolean + isUserDefined: boolean, + priority: number ): void { if (fileName !== null) { module.chunkFileNames.add(fileName); } else if (name !== null) { - if (module.chunkName === null) { - module.chunkName = name; - } - if (isUserDefined) { - module.userChunkNames.add(name); - } + // Always keep chunkNames sorted by priority + let namePosition = 0; + while (module.chunkNames[namePosition]?.priority < priority) namePosition++; + module.chunkNames.splice(namePosition, 0, { isUserDefined, name, priority }); } } diff --git a/src/utils/resolveId.ts b/src/utils/resolveId.ts index 02fc9d496bb..d2848d13acd 100644 --- a/src/utils/resolveId.ts +++ b/src/utils/resolveId.ts @@ -1,6 +1,6 @@ import type { CustomPluginOptions, Plugin, ResolvedId, ResolveIdResult } from '../rollup/types'; import type { PluginDriver } from './PluginDriver'; -import { lstatSync, readdirSync, realpathSync } from './fs'; +import { promises as fs } from './fs'; import { basename, dirname, isAbsolute, resolve } from './path'; import { resolveIdViaPlugins } from './resolveIdViaPlugins'; @@ -45,23 +45,26 @@ export async function resolveId( ); } -function addJsExtensionIfNecessary(file: string, preserveSymlinks: boolean): string | undefined { +async function addJsExtensionIfNecessary( + file: string, + preserveSymlinks: boolean +): Promise { return ( - findFile(file, preserveSymlinks) ?? - findFile(file + '.mjs', preserveSymlinks) ?? - findFile(file + '.js', preserveSymlinks) + (await findFile(file, preserveSymlinks)) ?? + (await findFile(file + '.mjs', preserveSymlinks)) ?? + (await findFile(file + '.js', preserveSymlinks)) ); } -function findFile(file: string, preserveSymlinks: boolean): string | undefined { +async function findFile(file: string, preserveSymlinks: boolean): Promise { try { - const stats = lstatSync(file); + const stats = await fs.lstat(file); if (!preserveSymlinks && stats.isSymbolicLink()) - return findFile(realpathSync(file), preserveSymlinks); + return await findFile(await fs.realpath(file), preserveSymlinks); if ((preserveSymlinks && stats.isSymbolicLink()) || stats.isFile()) { // check case const name = basename(file); - const files = readdirSync(dirname(file)); + const files = await fs.readdir(dirname(file)); if (files.includes(name)) return file; } diff --git a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/amd/generated-secondName.js b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/amd/generated-firstName.js similarity index 100% rename from test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/amd/generated-secondName.js rename to test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/amd/generated-firstName.js diff --git a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/amd/mainChunk.js b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/amd/mainChunk.js index c36d0e045b0..8322726fdc0 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/amd/mainChunk.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/amd/mainChunk.js @@ -1,5 +1,5 @@ -define(['./generated-name', './generated-secondName', './generated-name2'], (function (name, secondName, name$1) { 'use strict'; +define(['./generated-name', './generated-firstName', './generated-name2'], (function (name, firstName, name$1) { 'use strict'; - console.log('main', name, secondName, name$1); + console.log('main', name, firstName, name$1); })); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/amd/other.js b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/amd/other.js index 91a53506629..c23d5e088b7 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/amd/other.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/amd/other.js @@ -1,4 +1,4 @@ -define(['./generated-name', './generated-secondName', './generated-name2', './mainChunk'], (function (name, secondName, name$1, mainChunk) { 'use strict'; +define(['./generated-name', './generated-firstName', './generated-name2', './mainChunk'], (function (name, firstName, name$1, mainChunk) { 'use strict'; diff --git a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/cjs/generated-secondName.js b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/cjs/generated-firstName.js similarity index 100% rename from test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/cjs/generated-secondName.js rename to test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/cjs/generated-firstName.js diff --git a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/cjs/mainChunk.js b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/cjs/mainChunk.js index 5f0a2cff6ec..a6322eefe1c 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/cjs/mainChunk.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/cjs/mainChunk.js @@ -1,7 +1,7 @@ 'use strict'; var name = require('./generated-name.js'); -var secondName = require('./generated-secondName.js'); +var firstName = require('./generated-firstName.js'); var name$1 = require('./generated-name2.js'); -console.log('main', name, secondName, name$1); +console.log('main', name, firstName, name$1); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/cjs/other.js b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/cjs/other.js index 5f69e2c8c3a..18822f29013 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/cjs/other.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/cjs/other.js @@ -1,7 +1,7 @@ 'use strict'; require('./generated-name.js'); -require('./generated-secondName.js'); +require('./generated-firstName.js'); require('./generated-name2.js'); require('./mainChunk.js'); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/es/generated-secondName.js b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/es/generated-firstName.js similarity index 100% rename from test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/es/generated-secondName.js rename to test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/es/generated-firstName.js diff --git a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/es/mainChunk.js b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/es/mainChunk.js index bae9f17e008..b0afa0148bb 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/es/mainChunk.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/es/mainChunk.js @@ -1,5 +1,5 @@ import value1 from './generated-name.js'; -import value2 from './generated-secondName.js'; +import value2 from './generated-firstName.js'; import value3 from './generated-name2.js'; console.log('main', value1, value2, value3); diff --git a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/es/other.js b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/es/other.js index c236d86e897..fb128693d8a 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/es/other.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/es/other.js @@ -1,4 +1,4 @@ import './generated-name.js'; -import './generated-secondName.js'; +import './generated-firstName.js'; import './generated-name2.js'; import './mainChunk.js'; diff --git a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/system/generated-secondName.js b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/system/generated-firstName.js similarity index 100% rename from test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/system/generated-secondName.js rename to test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/system/generated-firstName.js diff --git a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/system/mainChunk.js b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/system/mainChunk.js index 11058497608..b6e7a4ed013 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/system/mainChunk.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/system/mainChunk.js @@ -1,4 +1,4 @@ -System.register(['./generated-name.js', './generated-secondName.js', './generated-name2.js'], (function () { +System.register(['./generated-name.js', './generated-firstName.js', './generated-name2.js'], (function () { 'use strict'; var value1, value2, value3; return { diff --git a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/system/other.js b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/system/other.js index c3a776d8a49..c178f99c8f6 100644 --- a/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/system/other.js +++ b/test/chunking-form/samples/emit-file/emit-chunk-name-conflict/_expected/system/other.js @@ -1,4 +1,4 @@ -System.register(['./generated-name.js', './generated-secondName.js', './generated-name2.js', './mainChunk.js'], (function () { +System.register(['./generated-name.js', './generated-firstName.js', './generated-name2.js', './mainChunk.js'], (function () { 'use strict'; return { setters: [function () {}, function () {}, function () {}, function () {}], diff --git a/test/cli/samples/warn-mixed-exports-multiple/_config.js b/test/cli/samples/warn-mixed-exports-multiple/_config.js index 7fc2b822221..45b131800d1 100644 --- a/test/cli/samples/warn-mixed-exports-multiple/_config.js +++ b/test/cli/samples/warn-mixed-exports-multiple/_config.js @@ -9,9 +9,9 @@ module.exports = { '(!) Mixing named and default exports\n' + 'https://rollupjs.org/guide/en/#outputexports\n' + 'The following entry modules are using named and default exports together:\n' + - 'main.js\n' + 'lib1.js\n' + 'lib2.js\n' + + 'lib3.js\n' + '...and 3 other entry modules\n' + '\n' + "Consumers of your bundle will have to use chunk['default'] to access their default export, which may not be what you want. Use `output.exports: 'named'` to disable this warning\n" diff --git a/test/cli/samples/watch/bundle-error/main.js b/test/cli/samples/watch/bundle-error/main.js deleted file mode 100644 index a4012bff06c..00000000000 --- a/test/cli/samples/watch/bundle-error/main.js +++ /dev/null @@ -1 +0,0 @@ -export default 42; \ No newline at end of file diff --git a/test/cli/samples/watch/watch-config-error/_config.js b/test/cli/samples/watch/watch-config-error/_config.js index 15ac4f74345..e0d0807f068 100644 --- a/test/cli/samples/watch/watch-config-error/_config.js +++ b/test/cli/samples/watch/watch-config-error/_config.js @@ -22,7 +22,8 @@ module.exports = { ); }, after() { - unlinkSync(configFile); + // synchronous sometimes does not seem to work, probably because the watch is not yet removed properly + setTimeout(() => unlinkSync(configFile), 300); }, abortOnStderr(data) { if (data.includes(`created _actual${path.sep}main1.js`)) { diff --git a/test/function/samples/circular-missed-reexports-2/_config.js b/test/function/samples/circular-missed-reexports-2/_config.js index acd6155794c..7bcba6b92ce 100644 --- a/test/function/samples/circular-missed-reexports-2/_config.js +++ b/test/function/samples/circular-missed-reexports-2/_config.js @@ -12,9 +12,9 @@ module.exports = { message: '"doesNotExist" cannot be exported from dep1.js as it is a reexport that references itself.', watchFiles: [ - path.join(__dirname, 'main.js'), path.join(__dirname, 'dep1.js'), - path.join(__dirname, 'dep2.js') + path.join(__dirname, 'dep2.js'), + path.join(__dirname, 'main.js') ] } }; diff --git a/test/function/samples/conflicting-reexports/named-import/_config.js b/test/function/samples/conflicting-reexports/named-import/_config.js index 7f116153a8e..751c3eb90a2 100644 --- a/test/function/samples/conflicting-reexports/named-import/_config.js +++ b/test/function/samples/conflicting-reexports/named-import/_config.js @@ -21,9 +21,9 @@ module.exports = { pos: 9, url: 'https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module', watchFiles: [ + path.join(__dirname, 'first.js'), ID_MAIN, path.join(__dirname, 'reexport.js'), - path.join(__dirname, 'first.js'), path.join(__dirname, 'second.js') ] } diff --git a/test/function/samples/default-not-reexported/_config.js b/test/function/samples/default-not-reexported/_config.js index 9849876b116..cfb7296fad2 100644 --- a/test/function/samples/default-not-reexported/_config.js +++ b/test/function/samples/default-not-reexported/_config.js @@ -8,9 +8,9 @@ module.exports = { id: path.join(__dirname, 'main.js'), pos: 7, watchFiles: [ - path.join(__dirname, 'main.js'), + path.join(__dirname, 'bar.js'), path.join(__dirname, 'foo.js'), - path.join(__dirname, 'bar.js') + path.join(__dirname, 'main.js') ], loc: { file: path.join(__dirname, 'main.js'), diff --git a/test/function/samples/deprecated/emit-chunk/chunk-filename-not-available/_config.js b/test/function/samples/deprecated/emit-chunk/chunk-filename-not-available/_config.js index b9f7b03693f..52a5ee32ae1 100644 --- a/test/function/samples/deprecated/emit-chunk/chunk-filename-not-available/_config.js +++ b/test/function/samples/deprecated/emit-chunk/chunk-filename-not-available/_config.js @@ -1,5 +1,3 @@ -const path = require('path'); - module.exports = { description: 'Throws when accessing the filename before it has been generated', options: { @@ -19,7 +17,6 @@ module.exports = { message: 'Plugin error - Unable to get file name for chunk "chunk.js". Ensure that generate is called first.', plugin: 'test-plugin', - pluginCode: 'CHUNK_NOT_GENERATED', - watchFiles: [path.join(__dirname, 'chunk.js')] + pluginCode: 'CHUNK_NOT_GENERATED' } }; diff --git a/test/function/samples/deprecated/manual-chunks-info/_config.js b/test/function/samples/deprecated/manual-chunks-info/_config.js index f3f097c77b1..229693d5f28 100644 --- a/test/function/samples/deprecated/manual-chunks-info/_config.js +++ b/test/function/samples/deprecated/manual-chunks-info/_config.js @@ -13,42 +13,39 @@ module.exports = { output: { manualChunks(id, { getModuleIds, getModuleInfo }) { assert.deepStrictEqual( - [...getModuleIds()], - [getId('main'), 'external', getId('lib'), getId('dynamic')] - ); - assert.deepStrictEqual( - JSON.parse(JSON.stringify([...getModuleIds()].map(id => getModuleInfo(id)))), + JSON.parse(JSON.stringify([...getModuleIds()].sort().map(id => getModuleInfo(id)))), [ { + id: getId('dynamic'), ast: { type: 'Program', start: 0, - end: 123, + end: 88, body: [ { type: 'ExportNamedDeclaration', start: 0, - end: 43, + end: 42, declaration: { type: 'VariableDeclaration', start: 7, - end: 43, + end: 42, declarations: [ { type: 'VariableDeclarator', start: 13, - end: 42, + end: 41, id: { type: 'Identifier', start: 13, end: 20, name: 'promise' }, init: { type: 'ImportExpression', start: 23, - end: 42, + end: 41, source: { type: 'Literal', start: 30, - end: 41, - value: './dynamic', - raw: "'./dynamic'" + end: 40, + value: 'external', + raw: "'external'" } } } @@ -60,60 +57,37 @@ module.exports = { }, { type: 'ExportNamedDeclaration', - start: 44, - end: 85, - declaration: null, - specifiers: [ - { - type: 'ExportSpecifier', - start: 53, - end: 69, - local: { type: 'Identifier', start: 53, end: 60, name: 'default' }, - exported: { type: 'Identifier', start: 64, end: 69, name: 'value' } - } - ], - source: { type: 'Literal', start: 77, end: 84, value: './lib', raw: "'./lib'" } - }, - { - type: 'ExportNamedDeclaration', - start: 86, - end: 122, + start: 43, + end: 87, declaration: null, specifiers: [ { type: 'ExportSpecifier', - start: 95, - end: 103, - local: { type: 'Identifier', start: 95, end: 103, name: 'external' }, - exported: { type: 'Identifier', start: 95, end: 103, name: 'external' } + start: 52, + end: 71, + local: { type: 'Identifier', start: 52, end: 59, name: 'default' }, + exported: { type: 'Identifier', start: 63, end: 71, name: 'internal' } } ], - source: { - type: 'Literal', - start: 111, - end: 121, - value: 'external', - raw: "'external'" - } + source: { type: 'Literal', start: 79, end: 86, value: './lib', raw: "'./lib'" } } ], sourceType: 'module' }, - code: "export const promise = import('./dynamic');\nexport { default as value } from './lib';\nexport { external } from 'external';\n", + code: "export const promise = import('external');\nexport { default as internal } from './lib';\n", dynamicallyImportedIdResolutions: [ { - external: false, - id: getId('dynamic'), + external: true, + id: 'external', meta: {}, moduleSideEffects: true, syntheticNamedExports: false } ], - dynamicallyImportedIds: [getId('dynamic')], - dynamicImporters: [], + dynamicallyImportedIds: ['external'], + dynamicImporters: [getId('main')], hasDefaultExport: false, moduleSideEffects: true, - id: getId('main'), implicitlyLoadedAfterOneOf: [], implicitlyLoadedBefore: [], importedIdResolutions: [ @@ -123,44 +97,18 @@ module.exports = { meta: {}, moduleSideEffects: true, syntheticNamedExports: false - }, - { - external: true, - id: 'external', - meta: {}, - moduleSideEffects: true, - syntheticNamedExports: false } ], - importedIds: [getId('lib'), 'external'], + importedIds: [getId('lib')], importers: [], - isEntry: true, + isEntry: false, isExternal: false, isIncluded: true, meta: {}, syntheticNamedExports: false }, { - ast: null, - code: null, - dynamicallyImportedIdResolutions: [], - dynamicallyImportedIds: [], - dynamicImporters: [getId('dynamic')], - hasDefaultExport: null, - moduleSideEffects: true, - id: 'external', - implicitlyLoadedAfterOneOf: [], - implicitlyLoadedBefore: [], - importedIdResolutions: [], - importedIds: [], - importers: [getId('main')], - isEntry: false, - isExternal: true, - isIncluded: null, - meta: {}, - syntheticNamedExports: false - }, - { + id: getId('lib'), ast: { type: 'Program', start: 0, @@ -181,7 +129,6 @@ module.exports = { dynamicImporters: [], hasDefaultExport: true, moduleSideEffects: true, - id: getId('lib'), implicitlyLoadedAfterOneOf: [], implicitlyLoadedBefore: [], importedIdResolutions: [], @@ -194,35 +141,36 @@ module.exports = { syntheticNamedExports: false }, { + id: getId('main'), ast: { type: 'Program', start: 0, - end: 88, + end: 123, body: [ { type: 'ExportNamedDeclaration', start: 0, - end: 42, + end: 43, declaration: { type: 'VariableDeclaration', start: 7, - end: 42, + end: 43, declarations: [ { type: 'VariableDeclarator', start: 13, - end: 41, + end: 42, id: { type: 'Identifier', start: 13, end: 20, name: 'promise' }, init: { type: 'ImportExpression', start: 23, - end: 41, + end: 42, source: { type: 'Literal', start: 30, - end: 40, - value: 'external', - raw: "'external'" + end: 41, + value: './dynamic', + raw: "'./dynamic'" } } } @@ -234,38 +182,59 @@ module.exports = { }, { type: 'ExportNamedDeclaration', - start: 43, - end: 87, + start: 44, + end: 85, declaration: null, specifiers: [ { type: 'ExportSpecifier', - start: 52, - end: 71, - local: { type: 'Identifier', start: 52, end: 59, name: 'default' }, - exported: { type: 'Identifier', start: 63, end: 71, name: 'internal' } + start: 53, + end: 69, + local: { type: 'Identifier', start: 53, end: 60, name: 'default' }, + exported: { type: 'Identifier', start: 64, end: 69, name: 'value' } } ], - source: { type: 'Literal', start: 79, end: 86, value: './lib', raw: "'./lib'" } + source: { type: 'Literal', start: 77, end: 84, value: './lib', raw: "'./lib'" } + }, + { + type: 'ExportNamedDeclaration', + start: 86, + end: 122, + declaration: null, + specifiers: [ + { + type: 'ExportSpecifier', + start: 95, + end: 103, + local: { type: 'Identifier', start: 95, end: 103, name: 'external' }, + exported: { type: 'Identifier', start: 95, end: 103, name: 'external' } + } + ], + source: { + type: 'Literal', + start: 111, + end: 121, + value: 'external', + raw: "'external'" + } } ], sourceType: 'module' }, - code: "export const promise = import('external');\nexport { default as internal } from './lib';\n", + code: "export const promise = import('./dynamic');\nexport { default as value } from './lib';\nexport { external } from 'external';\n", dynamicallyImportedIdResolutions: [ { - external: true, - id: 'external', + external: false, + id: getId('dynamic'), meta: {}, moduleSideEffects: true, syntheticNamedExports: false } ], - dynamicallyImportedIds: ['external'], - dynamicImporters: [getId('main')], + dynamicallyImportedIds: [getId('dynamic')], + dynamicImporters: [], hasDefaultExport: false, moduleSideEffects: true, - id: getId('dynamic'), implicitlyLoadedAfterOneOf: [], implicitlyLoadedBefore: [], importedIdResolutions: [ @@ -275,15 +244,42 @@ module.exports = { meta: {}, moduleSideEffects: true, syntheticNamedExports: false + }, + { + external: true, + id: 'external', + meta: {}, + moduleSideEffects: true, + syntheticNamedExports: false } ], - importedIds: [getId('lib')], + importedIds: [getId('lib'), 'external'], importers: [], - isEntry: false, + isEntry: true, isExternal: false, isIncluded: true, meta: {}, syntheticNamedExports: false + }, + { + id: 'external', + ast: null, + code: null, + dynamicallyImportedIdResolutions: [], + dynamicallyImportedIds: [], + dynamicImporters: [getId('dynamic')], + hasDefaultExport: null, + moduleSideEffects: true, + implicitlyLoadedAfterOneOf: [], + implicitlyLoadedBefore: [], + importedIdResolutions: [], + importedIds: [], + importers: [getId('main')], + isEntry: false, + isExternal: true, + isIncluded: null, + meta: {}, + syntheticNamedExports: false } ] ); diff --git a/test/function/samples/deprecated/plugin-module-ids/_config.js b/test/function/samples/deprecated/plugin-module-ids/_config.js index 18bc07a2a6c..4faf1e294a2 100644 --- a/test/function/samples/deprecated/plugin-module-ids/_config.js +++ b/test/function/samples/deprecated/plugin-module-ids/_config.js @@ -11,9 +11,9 @@ module.exports = { plugins: { renderStart() { rendered = true; - assert.deepStrictEqual(Array.from(this.moduleIds), [ - path.join(__dirname, 'main.js'), + assert.deepStrictEqual([...this.moduleIds].sort(), [ path.join(__dirname, 'foo.js'), + path.join(__dirname, 'main.js'), 'path' ]); } diff --git a/test/function/samples/double-default-export/_config.js b/test/function/samples/double-default-export/_config.js index 8116bd5ec2c..ba5b0fc007d 100644 --- a/test/function/samples/double-default-export/_config.js +++ b/test/function/samples/double-default-export/_config.js @@ -16,7 +16,7 @@ module.exports = { raisedAt: 34 }, pos: 25, - watchFiles: [path.join(__dirname, 'main.js'), path.join(__dirname, 'foo.js')], + watchFiles: [path.join(__dirname, 'foo.js'), path.join(__dirname, 'main.js')], loc: { file: path.join(__dirname, 'foo.js'), line: 2, diff --git a/test/function/samples/double-named-export/_config.js b/test/function/samples/double-named-export/_config.js index eee927b47d6..e3cd81614b7 100644 --- a/test/function/samples/double-named-export/_config.js +++ b/test/function/samples/double-named-export/_config.js @@ -16,7 +16,7 @@ module.exports = { raisedAt: 43 }, pos: 38, - watchFiles: [path.join(__dirname, 'main.js'), path.join(__dirname, 'foo.js')], + watchFiles: [path.join(__dirname, 'foo.js'), path.join(__dirname, 'main.js')], loc: { file: path.join(__dirname, 'foo.js'), line: 3, diff --git a/test/function/samples/double-named-reexport/_config.js b/test/function/samples/double-named-reexport/_config.js index d631636210e..1521e9eb0d8 100644 --- a/test/function/samples/double-named-reexport/_config.js +++ b/test/function/samples/double-named-reexport/_config.js @@ -16,7 +16,7 @@ module.exports = { raisedAt: 43 }, pos: 38, - watchFiles: [path.join(__dirname, 'main.js'), path.join(__dirname, 'foo.js')], + watchFiles: [path.join(__dirname, 'foo.js'), path.join(__dirname, 'main.js')], loc: { file: path.join(__dirname, 'foo.js'), line: 3, diff --git a/test/function/samples/emit-file/chunk-filename-not-available/_config.js b/test/function/samples/emit-file/chunk-filename-not-available/_config.js index eb87d7d659e..2575784f8d7 100644 --- a/test/function/samples/emit-file/chunk-filename-not-available/_config.js +++ b/test/function/samples/emit-file/chunk-filename-not-available/_config.js @@ -1,5 +1,3 @@ -const path = require('path'); - module.exports = { description: 'Throws when accessing the filename before it has been generated', options: { @@ -18,7 +16,6 @@ module.exports = { message: 'Plugin error - Unable to get file name for chunk "chunk.js". Ensure that generate is called first.', plugin: 'test-plugin', - pluginCode: 'CHUNK_NOT_GENERATED', - watchFiles: [path.join(__dirname, 'chunk.js')] + pluginCode: 'CHUNK_NOT_GENERATED' } }; diff --git a/test/function/samples/emit-file/set-asset-source-chunk/_config.js b/test/function/samples/emit-file/set-asset-source-chunk/_config.js index 5c07fa1556b..27b97f89fb1 100644 --- a/test/function/samples/emit-file/set-asset-source-chunk/_config.js +++ b/test/function/samples/emit-file/set-asset-source-chunk/_config.js @@ -1,5 +1,3 @@ -const path = require('path'); - module.exports = { description: 'throws when trying to set the asset source of a chunk', options: { @@ -16,7 +14,6 @@ module.exports = { hook: 'buildStart', message: 'Asset sources can only be set for emitted assets but "6c87f683" is an emitted chunk.', plugin: 'test-plugin', - pluginCode: 'VALIDATION_ERROR', - watchFiles: [path.join(__dirname, 'chunk.js')] + pluginCode: 'VALIDATION_ERROR' } }; diff --git a/test/function/samples/error-after-transform-should-throw-correct-location/_config.js b/test/function/samples/error-after-transform-should-throw-correct-location/_config.js index b9aaaa218a7..2bc6bf9bff6 100644 --- a/test/function/samples/error-after-transform-should-throw-correct-location/_config.js +++ b/test/function/samples/error-after-transform-should-throw-correct-location/_config.js @@ -23,7 +23,7 @@ module.exports = { message: `'default' is not exported by empty.js, imported by main.js`, id: path.join(__dirname, 'main.js'), pos: 44, - watchFiles: [path.join(__dirname, 'main.js'), path.join(__dirname, 'empty.js')], + watchFiles: [path.join(__dirname, 'empty.js'), path.join(__dirname, 'main.js')], loc: { file: path.join(__dirname, 'main.js'), line: 1, diff --git a/test/function/samples/error-parse-json/_config.js b/test/function/samples/error-parse-json/_config.js index 5e0f3c57466..118bb6df977 100644 --- a/test/function/samples/error-parse-json/_config.js +++ b/test/function/samples/error-parse-json/_config.js @@ -17,7 +17,7 @@ module.exports = { raisedAt: 11 }, pos: 10, - watchFiles: [path.join(__dirname, 'main.js'), path.join(__dirname, 'file.json')], + watchFiles: [path.join(__dirname, 'file.json'), path.join(__dirname, 'main.js')], loc: { file: path.join(__dirname, 'file.json'), line: 2, diff --git a/test/function/samples/error-parse-unknown-extension/_config.js b/test/function/samples/error-parse-unknown-extension/_config.js index 20767778673..eca522178fe 100644 --- a/test/function/samples/error-parse-unknown-extension/_config.js +++ b/test/function/samples/error-parse-unknown-extension/_config.js @@ -18,7 +18,7 @@ module.exports = { raisedAt: 1 }, pos: 0, - watchFiles: [path.join(__dirname, 'main.js'), path.join(__dirname, 'file.css')], + watchFiles: [path.join(__dirname, 'file.css'), path.join(__dirname, 'main.js')], loc: { file: path.join(__dirname, 'file.css'), line: 1, diff --git a/test/function/samples/implicit-dependencies/dependant-dynamic-import-no-effects/_config.js b/test/function/samples/implicit-dependencies/dependant-dynamic-import-no-effects/_config.js index ba821789554..a327941f1fd 100644 --- a/test/function/samples/implicit-dependencies/dependant-dynamic-import-no-effects/_config.js +++ b/test/function/samples/implicit-dependencies/dependant-dynamic-import-no-effects/_config.js @@ -20,8 +20,8 @@ module.exports = { 'Module "dependant.js" that should be implicitly loaded before "dep.js" is not included in the module graph. Either it was not imported by an included module or only via a tree-shaken dynamic import, or no imported bindings were used and it had otherwise no side-effects.', watchFiles: [ path.join(__dirname, 'dep.js'), - path.join(__dirname, 'main.js'), - path.join(__dirname, 'dependant.js') + path.join(__dirname, 'dependant.js'), + path.join(__dirname, 'main.js') ] } }; diff --git a/test/function/samples/implicit-dependencies/dependant-dynamic-import-not-included/_config.js b/test/function/samples/implicit-dependencies/dependant-dynamic-import-not-included/_config.js index e89b39449de..ba509a252eb 100644 --- a/test/function/samples/implicit-dependencies/dependant-dynamic-import-not-included/_config.js +++ b/test/function/samples/implicit-dependencies/dependant-dynamic-import-not-included/_config.js @@ -27,8 +27,8 @@ module.exports = { watchFiles: [ path.join(__dirname, 'dep1.js'), path.join(__dirname, 'dep2.js'), - path.join(__dirname, 'main.js'), - path.join(__dirname, 'dependant.js') + path.join(__dirname, 'dependant.js'), + path.join(__dirname, 'main.js') ] } }; diff --git a/test/function/samples/implicit-dependencies/dependant-not-part-of-graph/_config.js b/test/function/samples/implicit-dependencies/dependant-not-part-of-graph/_config.js index 484f9eb1861..3ff5862734a 100644 --- a/test/function/samples/implicit-dependencies/dependant-not-part-of-graph/_config.js +++ b/test/function/samples/implicit-dependencies/dependant-not-part-of-graph/_config.js @@ -33,8 +33,8 @@ module.exports = { path.join(__dirname, 'dep1.js'), path.join(__dirname, 'dep2.js'), path.join(__dirname, 'dep3.js'), - path.join(__dirname, 'main.js'), - path.join(__dirname, 'dependant.js') + path.join(__dirname, 'dependant.js'), + path.join(__dirname, 'main.js') ] } }; diff --git a/test/function/samples/import-of-unexported-fails/_config.js b/test/function/samples/import-of-unexported-fails/_config.js index 0dcf4450b34..285d0e71d07 100644 --- a/test/function/samples/import-of-unexported-fails/_config.js +++ b/test/function/samples/import-of-unexported-fails/_config.js @@ -7,7 +7,7 @@ module.exports = { message: `'default' is not exported by empty.js, imported by main.js`, id: path.join(__dirname, 'main.js'), pos: 7, - watchFiles: [path.join(__dirname, 'main.js'), path.join(__dirname, 'empty.js')], + watchFiles: [path.join(__dirname, 'empty.js'), path.join(__dirname, 'main.js')], loc: { file: path.join(__dirname, 'main.js'), line: 1, diff --git a/test/function/samples/max-parallel-file-reads-error/_config.js b/test/function/samples/max-parallel-file-reads-error/_config.js index 9aeadc4f067..f35d3d859d6 100644 --- a/test/function/samples/max-parallel-file-reads-error/_config.js +++ b/test/function/samples/max-parallel-file-reads-error/_config.js @@ -26,6 +26,6 @@ module.exports = { }, error: { message: `Could not load ${join(__dirname, 'dep.js')} (imported by main): broken`, - watchFiles: ['main', join(__dirname, 'dep.js')] + watchFiles: [join(__dirname, 'dep.js'), 'main'] } }; diff --git a/test/function/samples/plugin-module-information/_config.js b/test/function/samples/plugin-module-information/_config.js index eba9ccd654c..ef4a57f1c96 100644 --- a/test/function/samples/plugin-module-information/_config.js +++ b/test/function/samples/plugin-module-information/_config.js @@ -37,10 +37,99 @@ module.exports = { }, renderStart() { rendered = true; - assert.deepStrictEqual([...this.getModuleIds()], [ID_MAIN, ID_FOO, ID_PATH, ID_NESTED]); assert.deepStrictEqual( - JSON.parse(JSON.stringify([...this.getModuleIds()].map(id => this.getModuleInfo(id)))), + JSON.parse( + JSON.stringify([...this.getModuleIds()].sort().map(id => this.getModuleInfo(id))) + ), [ + { + ast: { + type: 'Program', + start: 0, + end: 66, + body: [ + { + type: 'ImportDeclaration', + start: 0, + end: 24, + specifiers: [ + { + type: 'ImportDefaultSpecifier', + start: 7, + end: 11, + local: { type: 'Identifier', start: 7, end: 11, name: 'path' } + } + ], + source: { type: 'Literal', start: 17, end: 23, value: 'path', raw: "'path'" } + }, + { + type: 'ExportNamedDeclaration', + start: 26, + end: 65, + declaration: { + type: 'VariableDeclaration', + start: 33, + end: 65, + declarations: [ + { + type: 'VariableDeclarator', + start: 39, + end: 64, + id: { type: 'Identifier', start: 39, end: 42, name: 'foo' }, + init: { + type: 'CallExpression', + start: 45, + end: 64, + callee: { + type: 'MemberExpression', + start: 45, + end: 57, + object: { type: 'Identifier', start: 45, end: 49, name: 'path' }, + property: { type: 'Identifier', start: 50, end: 57, name: 'resolve' }, + computed: false, + optional: false + }, + arguments: [ + { type: 'Literal', start: 58, end: 63, value: 'foo', raw: "'foo'" } + ], + optional: false + } + } + ], + kind: 'const' + }, + specifiers: [], + source: null + } + ], + sourceType: 'module' + }, + code: "import path from 'path';\n\nexport const foo = path.resolve('foo');\n", + dynamicallyImportedIdResolutions: [], + dynamicallyImportedIds: [], + dynamicImporters: [], + hasDefaultExport: false, + moduleSideEffects: true, + id: ID_FOO, + implicitlyLoadedAfterOneOf: [], + implicitlyLoadedBefore: [], + importedIdResolutions: [ + { + external: true, + id: ID_PATH, + meta: {}, + moduleSideEffects: true, + syntheticNamedExports: false + } + ], + importedIds: [ID_PATH], + importers: [ID_MAIN, ID_NESTED], + isEntry: false, + isExternal: false, + isIncluded: true, + meta: {}, + syntheticNamedExports: false + }, { ast: { type: 'Program', @@ -206,114 +295,6 @@ module.exports = { meta: {}, syntheticNamedExports: false }, - { - ast: { - type: 'Program', - start: 0, - end: 66, - body: [ - { - type: 'ImportDeclaration', - start: 0, - end: 24, - specifiers: [ - { - type: 'ImportDefaultSpecifier', - start: 7, - end: 11, - local: { type: 'Identifier', start: 7, end: 11, name: 'path' } - } - ], - source: { type: 'Literal', start: 17, end: 23, value: 'path', raw: "'path'" } - }, - { - type: 'ExportNamedDeclaration', - start: 26, - end: 65, - declaration: { - type: 'VariableDeclaration', - start: 33, - end: 65, - declarations: [ - { - type: 'VariableDeclarator', - start: 39, - end: 64, - id: { type: 'Identifier', start: 39, end: 42, name: 'foo' }, - init: { - type: 'CallExpression', - start: 45, - end: 64, - callee: { - type: 'MemberExpression', - start: 45, - end: 57, - object: { type: 'Identifier', start: 45, end: 49, name: 'path' }, - property: { type: 'Identifier', start: 50, end: 57, name: 'resolve' }, - computed: false, - optional: false - }, - arguments: [ - { type: 'Literal', start: 58, end: 63, value: 'foo', raw: "'foo'" } - ], - optional: false - } - } - ], - kind: 'const' - }, - specifiers: [], - source: null - } - ], - sourceType: 'module' - }, - code: "import path from 'path';\n\nexport const foo = path.resolve('foo');\n", - dynamicallyImportedIdResolutions: [], - dynamicallyImportedIds: [], - dynamicImporters: [], - hasDefaultExport: false, - moduleSideEffects: true, - id: ID_FOO, - implicitlyLoadedAfterOneOf: [], - implicitlyLoadedBefore: [], - importedIdResolutions: [ - { - external: true, - id: ID_PATH, - meta: {}, - moduleSideEffects: true, - syntheticNamedExports: false - } - ], - importedIds: [ID_PATH], - importers: [ID_MAIN, ID_NESTED], - isEntry: false, - isExternal: false, - isIncluded: true, - meta: {}, - syntheticNamedExports: false - }, - { - ast: null, - code: null, - dynamicallyImportedIdResolutions: [], - dynamicallyImportedIds: [], - dynamicImporters: [ID_MAIN], - hasDefaultExport: null, - moduleSideEffects: true, - id: ID_PATH, - implicitlyLoadedAfterOneOf: [], - implicitlyLoadedBefore: [], - importedIdResolutions: [], - importedIds: [], - importers: [ID_FOO], - isEntry: false, - isExternal: true, - isIncluded: null, - meta: {}, - syntheticNamedExports: false - }, { ast: { type: 'Program', @@ -404,6 +385,26 @@ module.exports = { isIncluded: true, meta: {}, syntheticNamedExports: false + }, + { + ast: null, + code: null, + dynamicallyImportedIdResolutions: [], + dynamicallyImportedIds: [], + dynamicImporters: [ID_MAIN], + hasDefaultExport: null, + moduleSideEffects: true, + id: ID_PATH, + implicitlyLoadedAfterOneOf: [], + implicitlyLoadedBefore: [], + importedIdResolutions: [], + importedIds: [], + importers: [ID_FOO], + isEntry: false, + isExternal: true, + isIncluded: null, + meta: {}, + syntheticNamedExports: false } ] ); diff --git a/test/function/samples/reassign-import-fails/_config.js b/test/function/samples/reassign-import-fails/_config.js index e4aaef4bcc5..131fd8cf6c7 100644 --- a/test/function/samples/reassign-import-fails/_config.js +++ b/test/function/samples/reassign-import-fails/_config.js @@ -7,7 +7,7 @@ module.exports = { message: `Illegal reassignment to import 'x'`, id: path.join(__dirname, 'main.js'), pos: 113, - watchFiles: [path.join(__dirname, 'main.js'), path.join(__dirname, 'foo.js')], + watchFiles: [path.join(__dirname, 'foo.js'), path.join(__dirname, 'main.js')], loc: { file: path.join(__dirname, 'main.js'), line: 8, diff --git a/test/function/samples/reassign-import-not-at-top-level-fails/_config.js b/test/function/samples/reassign-import-not-at-top-level-fails/_config.js index 43d4f0d4e90..2292fb59041 100644 --- a/test/function/samples/reassign-import-not-at-top-level-fails/_config.js +++ b/test/function/samples/reassign-import-not-at-top-level-fails/_config.js @@ -7,7 +7,7 @@ module.exports = { message: `Illegal reassignment to import 'x'`, id: path.join(__dirname, 'main.js'), pos: 95, - watchFiles: [path.join(__dirname, 'main.js'), path.join(__dirname, 'foo.js')], + watchFiles: [path.join(__dirname, 'foo.js'), path.join(__dirname, 'main.js')], loc: { file: path.join(__dirname, 'main.js'), line: 7, diff --git a/test/function/samples/reexport-missing-error/_config.js b/test/function/samples/reexport-missing-error/_config.js index 510b104cec1..d8922519654 100644 --- a/test/function/samples/reexport-missing-error/_config.js +++ b/test/function/samples/reexport-missing-error/_config.js @@ -7,7 +7,7 @@ module.exports = { message: `'foo' is not exported by empty.js, imported by main.js`, id: path.join(__dirname, 'main.js'), pos: 9, - watchFiles: [path.join(__dirname, 'main.js'), path.join(__dirname, 'empty.js')], + watchFiles: [path.join(__dirname, 'empty.js'), path.join(__dirname, 'main.js')], loc: { file: path.join(__dirname, 'main.js'), line: 1, diff --git a/test/function/samples/synthetic-named-exports/circular-synthetic-exports/_config.js b/test/function/samples/synthetic-named-exports/circular-synthetic-exports/_config.js index 89a605bae77..2b492df4c07 100644 --- a/test/function/samples/synthetic-named-exports/circular-synthetic-exports/_config.js +++ b/test/function/samples/synthetic-named-exports/circular-synthetic-exports/_config.js @@ -16,6 +16,6 @@ module.exports = { code: 'SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT', id: path.join(__dirname, 'main.js'), message: `Module "main.js" that is marked with 'syntheticNamedExports: "__synthetic"' needs an explicit export named "__synthetic" that does not reexport an unresolved named export of the same module.`, - watchFiles: [path.join(__dirname, 'main.js'), path.join(__dirname, 'dep.js')] + watchFiles: [path.join(__dirname, 'dep.js'), path.join(__dirname, 'main.js')] } }; diff --git a/test/function/samples/synthetic-named-exports/synthetic-exports-need-default/_config.js b/test/function/samples/synthetic-named-exports/synthetic-exports-need-default/_config.js index 0a89c1f782a..61282f02510 100644 --- a/test/function/samples/synthetic-named-exports/synthetic-exports-need-default/_config.js +++ b/test/function/samples/synthetic-named-exports/synthetic-exports-need-default/_config.js @@ -15,6 +15,6 @@ module.exports = { code: 'SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT', id: path.join(__dirname, 'dep.js'), message: `Module "dep.js" that is marked with 'syntheticNamedExports: true' needs a default export that does not reexport an unresolved named export of the same module.`, - watchFiles: [path.join(__dirname, 'main.js'), path.join(__dirname, 'dep.js')] + watchFiles: [path.join(__dirname, 'dep.js'), path.join(__dirname, 'main.js')] } }; diff --git a/test/function/samples/synthetic-named-exports/synthetic-exports-need-fallback-export/_config.js b/test/function/samples/synthetic-named-exports/synthetic-exports-need-fallback-export/_config.js index 7e85c3165ac..0613924e218 100644 --- a/test/function/samples/synthetic-named-exports/synthetic-exports-need-fallback-export/_config.js +++ b/test/function/samples/synthetic-named-exports/synthetic-exports-need-fallback-export/_config.js @@ -18,6 +18,6 @@ module.exports = { code: 'SYNTHETIC_NAMED_EXPORTS_NEED_NAMESPACE_EXPORT', id: DEP_ID, message: `Module "dep.js" that is marked with 'syntheticNamedExports: "__synthetic"' needs an explicit export named "__synthetic" that does not reexport an unresolved named export of the same module.`, - watchFiles: [path.join(__dirname, 'main.js'), DEP_ID] + watchFiles: [DEP_ID, path.join(__dirname, 'main.js')] } }; diff --git a/test/function/samples/update-expression-of-import-fails/_config.js b/test/function/samples/update-expression-of-import-fails/_config.js index f3596401b98..d540cf5ca28 100644 --- a/test/function/samples/update-expression-of-import-fails/_config.js +++ b/test/function/samples/update-expression-of-import-fails/_config.js @@ -7,7 +7,7 @@ module.exports = { message: `Illegal reassignment to import 'a'`, id: path.join(__dirname, 'main.js'), pos: 28, - watchFiles: [path.join(__dirname, 'main.js'), path.join(__dirname, 'foo.js')], + watchFiles: [path.join(__dirname, 'foo.js'), path.join(__dirname, 'main.js')], loc: { file: path.join(__dirname, 'main.js'), line: 3, diff --git a/test/utils.js b/test/utils.js index 1ef7c165bb7..e7f7f61ac9d 100644 --- a/test/utils.js +++ b/test/utils.js @@ -23,6 +23,9 @@ exports.wait = function wait(ms) { function normaliseError(error) { delete error.stack; delete error.toString; + if (error.watchFiles) { + error.watchFiles.sort(); + } return { ...error, message: error.message }; }