From fa1d9341a225d8ecc248f4744affcd574a1e6bd8 Mon Sep 17 00:00:00 2001 From: Lukas Taegert-Atkinson Date: Tue, 18 Jan 2022 06:11:21 +0100 Subject: [PATCH] Add importedIdResolutions to moduleInfo --- docs/05-plugin-development.md | 14 +++- src/ExternalModule.ts | 2 + src/Module.ts | 9 +++ src/rollup/types.d.ts | 2 + .../_config.js | 20 ++++++ .../implicitly-dependent-entry/_config.js | 20 ++++++ .../multiple-dependencies/_config.js | 72 +++++++++++++++++++ .../single-dependency/_config.js | 20 ++++++ .../deprecated/manual-chunks-info/_config.js | 47 ++++++++++++ .../samples/manual-chunks-info/_config.js | 47 ++++++++++++ .../samples/module-parsed-hook/_config.js | 12 ++++ .../plugin-module-information/_config.js | 49 +++++++++++++ .../samples/preload-module/_config.js | 4 ++ 13 files changed, 316 insertions(+), 2 deletions(-) diff --git a/docs/05-plugin-development.md b/docs/05-plugin-development.md index ab5ead9f000..068abb62045 100644 --- a/docs/05-plugin-development.md +++ b/docs/05-plugin-development.md @@ -122,7 +122,7 @@ This hook is called each time a module has been fully parsed by Rollup. See [`th In contrast to the [`transform`](guide/en/#transform) hook, this hook is never cached and can be used to get information about both cached and other modules, including the final shape of the `meta` property, the `code` and the `ast`. -This hook will wait until all imports are resolved so that the information in `moduleInfo.importedIds` and `moduleInfo.dynamicallyImportedIds` is complete and accurate. Note however that information about importing modules may be incomplete as additional importers could be discovered later. If you need this information, use the [`buildEnd`](guide/en/#buildend) hook. +This hook will wait until all imports are resolved so that the information in `moduleInfo.importedIds`, `moduleInfo.dynamicallyImportedIds`, `moduleInfo.importedIdResolutions`, and `moduleInfo.dynamicallyImportedIdResolutions` is complete and accurate. Note however that information about importing modules may be incomplete as additional importers could be discovered later. If you need this information, use the [`buildEnd`](guide/en/#buildend) hook. #### `options` @@ -677,8 +677,10 @@ type ModuleInfo = { isExternal: boolean; // for external modules that are referenced but not included in the graph isIncluded: boolean | null; // is the module included after tree-shaking, `null` if external or not yet available importedIds: string[]; // the module ids statically imported by this module + importedIdResolutions: ResolvedId[]; // how statically imported ids were resolved, for use with this.load importers: string[]; // the ids of all modules that statically import this module dynamicallyImportedIds: string[]; // the module ids imported by this module via dynamic import() + dynamicallyImportedIdResolutions: ResolvedId[]; // how ids imported via dynamic import() were resolved dynamicImporters: string[]; // the ids of all modules that import this module via dynamic import() implicitlyLoadedAfterOneOf: string[]; // implicit relationships, declared via this.emitFile implicitlyLoadedBefore: string[]; // implicit relationships, declared via this.emitFile @@ -686,6 +688,14 @@ type ModuleInfo = { meta: { [plugin: string]: any }; // custom module meta-data syntheticNamedExports: boolean | string; // final value of synthetic named exports }; + +type ResolvedId = { + id: string; // the id of the imported module + external: boolean | 'absolute'; // is this module external, "absolute" means it will not be rendered as relative in the module + moduleSideEffects: boolean | 'no-treeshake'; // are side effects of the module observed, is tree-shaking enabled + syntheticNamedExports: boolean | string; // does the module allow importing non-existing named exports + meta: { [plugin: string]: any }; // custom module meta-data when resolving the module +}; ``` During the build, this object represents currently available information about the module. Before the [`buildEnd`](guide/en/#buildend) hook, this information may be incomplete as e.g. the `importedIds` are not yet resolved or additional `importers` are discovered. @@ -706,7 +716,7 @@ Loads and parses the module corresponding to the given id, attaching additional This allows you to inspect the final content of modules before deciding how to resolve them in the [`resolveId`](guide/en/#resolveid) hook and e.g. resolve to a proxy module instead. If the module becomes part of the graph later, there is no additional overhead from using this context function as the module will not be parsed again. The signature allows you to directly pass the return value of [`this.resolve`](guide/en/#thisresolve) to this function as long as it is neither `null` nor external. -The returned promise will resolve once the module has been fully transformed and parsed but before any imports have been resolved. That means that the resulting `ModuleInfo` will have empty `importedIds` and `dynamicallyImportedIds`. This helps to avoid deadlock situations when awaiting `this.load` in a `resolveId` hook. If you are interested in `importedIds` and `dynamicallyImportedIds`, you should implement a `moduleParsed` hook. +The returned promise will resolve once the module has been fully transformed and parsed but before any imports have been resolved. That means that the resulting `ModuleInfo` will have empty `importedIds`, `dynamicallyImportedIds`, `importedIdResolutions` and `dynamicallyImportedIdResolutions`. This helps to avoid deadlock situations when awaiting `this.load` in a `resolveId` hook. If you are interested in `importedIds` and `dynamicallyImportedIds`, you should implement a `moduleParsed` hook. Note that with regard to the `moduleSideEffects`, `syntheticNamedExports` and `meta` options, the same restrictions apply as for the `resolveId` hook: Their values only have an effect if the module has not been loaded yet. Thus, it is very important to use `this.resolve` first to find out if any plugins want to set special values for these options in their `resolveId` hook, and pass these options on to `this.load` if appropriate. The example below showcases how this can be handled to add a proxy module for modules containing a special code comment: diff --git a/src/ExternalModule.ts b/src/ExternalModule.ts index 97a66c36e67..efd5420de5f 100644 --- a/src/ExternalModule.ts +++ b/src/ExternalModule.ts @@ -41,6 +41,7 @@ export default class ExternalModule { this.info = { ast: null, code: null, + dynamicallyImportedIdResolutions: EMPTY_ARRAY, dynamicallyImportedIds: EMPTY_ARRAY, get dynamicImporters() { return dynamicImporters.sort(); @@ -49,6 +50,7 @@ export default class ExternalModule { id, implicitlyLoadedAfterOneOf: EMPTY_ARRAY, implicitlyLoadedBefore: EMPTY_ARRAY, + importedIdResolutions: EMPTY_ARRAY, importedIds: EMPTY_ARRAY, get importers() { return importers.sort(); diff --git a/src/Module.ts b/src/Module.ts index 12fe9b7c245..fe458e638b0 100644 --- a/src/Module.ts +++ b/src/Module.ts @@ -38,6 +38,7 @@ import { NormalizedInputOptions, PartialNull, PreserveEntrySignaturesOption, + ResolvedId, ResolvedIdMap, RollupError, RollupLogProps, @@ -259,6 +260,11 @@ export default class Module { this.info = { ast: null, code: null, + get dynamicallyImportedIdResolutions() { + return module.dynamicImports + .map(({ argument }) => typeof argument === 'string' && module.resolvedIds[argument]) + .filter(Boolean) as ResolvedId[]; + }, get dynamicallyImportedIds() { const dynamicallyImportedIds: string[] = []; for (const { id } of module.dynamicImports) { @@ -279,6 +285,9 @@ export default class Module { get implicitlyLoadedBefore() { return Array.from(module.implicitlyLoadedBefore, getId).sort(); }, + get importedIdResolutions() { + return Array.from(module.sources, source => module.resolvedIds[source]).filter(Boolean); + }, get importedIds() { return Array.from(module.sources, source => module.resolvedIds[source]?.id).filter(Boolean); }, diff --git a/src/rollup/types.d.ts b/src/rollup/types.d.ts index 45cabb78c10..cf2ffa4117e 100644 --- a/src/rollup/types.d.ts +++ b/src/rollup/types.d.ts @@ -160,11 +160,13 @@ interface ModuleInfo { ast: AcornNode | null; code: string | null; dynamicImporters: readonly string[]; + dynamicallyImportedIdResolutions: readonly ResolvedId[]; dynamicallyImportedIds: readonly string[]; hasModuleSideEffects: boolean | 'no-treeshake'; id: string; implicitlyLoadedAfterOneOf: readonly string[]; implicitlyLoadedBefore: readonly string[]; + importedIdResolutions: readonly ResolvedId[]; importedIds: readonly string[]; importers: readonly string[]; isEntry: boolean; diff --git a/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry/_config.js b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry/_config.js index a0d90878714..661bf005fac 100644 --- a/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry/_config.js +++ b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-emitted-entry/_config.js @@ -70,12 +70,22 @@ module.exports = { sourceType: 'module' }, code: "import { value } from './lib';\nconsole.log(value);\n", + dynamicallyImportedIdResolutions: [], dynamicallyImportedIds: [], dynamicImporters: [], hasModuleSideEffects: true, id: ID_MAIN, implicitlyLoadedAfterOneOf: [], implicitlyLoadedBefore: [], + importedIdResolutions: [ + { + external: false, + id: ID_LIB, + meta: {}, + moduleSideEffects: true, + syntheticNamedExports: false + } + ], importedIds: [ID_LIB], importers: [], isEntry: true, @@ -130,12 +140,22 @@ module.exports = { sourceType: 'module' }, code: "import { value } from './lib';\nconsole.log(value);\n", + dynamicallyImportedIdResolutions: [], dynamicallyImportedIds: [], dynamicImporters: [], hasModuleSideEffects: true, id: ID_DEP, implicitlyLoadedAfterOneOf: [], implicitlyLoadedBefore: [], + importedIdResolutions: [ + { + external: false, + id: ID_LIB, + meta: {}, + moduleSideEffects: true, + syntheticNamedExports: false + } + ], importedIds: [ID_LIB], importers: [], isEntry: true, diff --git a/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-entry/_config.js b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-entry/_config.js index 897835fb6d0..7856f608a24 100644 --- a/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-entry/_config.js +++ b/test/chunking-form/samples/implicit-dependencies/implicitly-dependent-entry/_config.js @@ -66,12 +66,22 @@ module.exports = { sourceType: 'module' }, code: "import { value } from './lib';\nconsole.log(value);\n", + dynamicallyImportedIdResolutions: [], dynamicallyImportedIds: [], dynamicImporters: [], hasModuleSideEffects: true, id: ID_MAIN, implicitlyLoadedAfterOneOf: [], implicitlyLoadedBefore: [], + importedIdResolutions: [ + { + external: false, + id: ID_LIB, + meta: {}, + moduleSideEffects: true, + syntheticNamedExports: false + } + ], importedIds: [ID_LIB], importers: [], isEntry: true, @@ -126,12 +136,22 @@ module.exports = { sourceType: 'module' }, code: "import { value } from './lib';\nconsole.log(value);\n", + dynamicallyImportedIdResolutions: [], dynamicallyImportedIds: [], dynamicImporters: [], hasModuleSideEffects: true, id: ID_DEP, implicitlyLoadedAfterOneOf: [], implicitlyLoadedBefore: [], + importedIdResolutions: [ + { + external: false, + id: ID_LIB, + meta: {}, + moduleSideEffects: true, + syntheticNamedExports: false + } + ], importedIds: [ID_LIB], importers: [], isEntry: true, diff --git a/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_config.js b/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_config.js index 2d38a4c3fd6..c0d26c83d4b 100644 --- a/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_config.js +++ b/test/chunking-form/samples/implicit-dependencies/multiple-dependencies/_config.js @@ -114,12 +114,36 @@ module.exports = { sourceType: 'module' }, code: "import { lib1 } from './lib1';\nimport { lib1b } from './lib1b';\nimport { lib2 } from './lib2';\nconsole.log('main1', lib1, lib1b, lib2);\n", + dynamicallyImportedIdResolutions: [], dynamicallyImportedIds: [], dynamicImporters: [], hasModuleSideEffects: true, id: ID_MAIN1, implicitlyLoadedAfterOneOf: [], implicitlyLoadedBefore: [ID_DEP], + importedIdResolutions: [ + { + external: false, + id: ID_LIB1, + meta: {}, + moduleSideEffects: true, + syntheticNamedExports: false + }, + { + external: false, + id: ID_LIB1B, + meta: {}, + moduleSideEffects: true, + syntheticNamedExports: false + }, + { + external: false, + id: ID_LIB2, + meta: {}, + moduleSideEffects: true, + syntheticNamedExports: false + } + ], importedIds: [ID_LIB1, ID_LIB1B, ID_LIB2], importers: [], isEntry: true, @@ -209,12 +233,36 @@ module.exports = { sourceType: 'module' }, code: "import { lib1 } from './lib1';\nimport { lib1b } from './lib1b';\nimport { lib3 } from './lib3';\nconsole.log('main2', lib1, lib1b, lib3);\n", + dynamicallyImportedIdResolutions: [], dynamicallyImportedIds: [], dynamicImporters: [], hasModuleSideEffects: true, id: ID_MAIN2, implicitlyLoadedAfterOneOf: [], implicitlyLoadedBefore: [ID_DEP], + importedIdResolutions: [ + { + external: false, + id: ID_LIB1, + meta: {}, + moduleSideEffects: true, + syntheticNamedExports: false + }, + { + external: false, + id: ID_LIB1B, + meta: {}, + moduleSideEffects: true, + syntheticNamedExports: false + }, + { + external: false, + id: ID_LIB3, + meta: {}, + moduleSideEffects: true, + syntheticNamedExports: false + } + ], importedIds: [ID_LIB1, ID_LIB1B, ID_LIB3], importers: [], isEntry: true, @@ -303,12 +351,36 @@ module.exports = { sourceType: 'module' }, code: "import { lib1 } from './lib1';\nimport { lib2 } from './lib2';\nimport { lib3 } from './lib3';\nconsole.log(lib1, lib2, lib3);\n", + dynamicallyImportedIdResolutions: [], dynamicallyImportedIds: [], dynamicImporters: [], hasModuleSideEffects: true, id: ID_DEP, implicitlyLoadedAfterOneOf: [ID_MAIN1, ID_MAIN2], implicitlyLoadedBefore: [], + importedIdResolutions: [ + { + external: false, + id: ID_LIB1, + meta: {}, + moduleSideEffects: true, + syntheticNamedExports: false + }, + { + external: false, + id: ID_LIB2, + meta: {}, + moduleSideEffects: true, + syntheticNamedExports: false + }, + { + external: false, + id: ID_LIB3, + meta: {}, + moduleSideEffects: true, + syntheticNamedExports: false + } + ], importedIds: [ID_LIB1, ID_LIB2, ID_LIB3], importers: [], isEntry: false, diff --git a/test/chunking-form/samples/implicit-dependencies/single-dependency/_config.js b/test/chunking-form/samples/implicit-dependencies/single-dependency/_config.js index 26fab23a6d8..699ba45512e 100644 --- a/test/chunking-form/samples/implicit-dependencies/single-dependency/_config.js +++ b/test/chunking-form/samples/implicit-dependencies/single-dependency/_config.js @@ -65,12 +65,22 @@ module.exports = { sourceType: 'module' }, code: "import { value } from './lib';\nconsole.log(value);\n", + dynamicallyImportedIdResolutions: [], dynamicallyImportedIds: [], dynamicImporters: [], hasModuleSideEffects: true, id: ID_MAIN, implicitlyLoadedAfterOneOf: [], implicitlyLoadedBefore: [ID_DEP], + importedIdResolutions: [ + { + external: false, + id: ID_LIB, + meta: {}, + moduleSideEffects: true, + syntheticNamedExports: false + } + ], importedIds: [ID_LIB], importers: [], isEntry: true, @@ -125,12 +135,22 @@ module.exports = { sourceType: 'module' }, code: "import { value } from './lib';\nconsole.log(value);\n", + dynamicallyImportedIdResolutions: [], dynamicallyImportedIds: [], dynamicImporters: [], hasModuleSideEffects: true, id: ID_DEP, implicitlyLoadedAfterOneOf: [ID_MAIN], implicitlyLoadedBefore: [], + importedIdResolutions: [ + { + external: false, + id: ID_LIB, + meta: {}, + moduleSideEffects: true, + syntheticNamedExports: false + } + ], importedIds: [ID_LIB], importers: [], isEntry: false, diff --git a/test/function/samples/deprecated/manual-chunks-info/_config.js b/test/function/samples/deprecated/manual-chunks-info/_config.js index ac8ce09551e..c3d75ad7977 100644 --- a/test/function/samples/deprecated/manual-chunks-info/_config.js +++ b/test/function/samples/deprecated/manual-chunks-info/_config.js @@ -100,12 +100,37 @@ module.exports = { sourceType: 'module' }, code: "export const promise = import('./dynamic');\nexport { default as value } from './lib';\nexport { external } from 'external';\n", + dynamicallyImportedIdResolutions: [ + { + external: false, + id: getId('dynamic'), + meta: {}, + moduleSideEffects: true, + syntheticNamedExports: false + } + ], dynamicallyImportedIds: [getId('dynamic')], dynamicImporters: [], hasModuleSideEffects: true, id: getId('main'), implicitlyLoadedAfterOneOf: [], implicitlyLoadedBefore: [], + importedIdResolutions: [ + { + external: false, + id: getId('lib'), + meta: {}, + moduleSideEffects: true, + syntheticNamedExports: false + }, + { + external: true, + id: 'external', + meta: {}, + moduleSideEffects: true, + syntheticNamedExports: false + } + ], importedIds: [getId('lib'), 'external'], importers: [], isEntry: true, @@ -117,12 +142,14 @@ module.exports = { { ast: null, code: null, + dynamicallyImportedIdResolutions: [], dynamicallyImportedIds: [], dynamicImporters: [getId('dynamic')], hasModuleSideEffects: true, id: 'external', implicitlyLoadedAfterOneOf: [], implicitlyLoadedBefore: [], + importedIdResolutions: [], importedIds: [], importers: [getId('main')], isEntry: false, @@ -147,12 +174,14 @@ module.exports = { sourceType: 'module' }, code: 'export default 42;\n', + dynamicallyImportedIdResolutions: [], dynamicallyImportedIds: [], dynamicImporters: [], hasModuleSideEffects: true, id: getId('lib'), implicitlyLoadedAfterOneOf: [], implicitlyLoadedBefore: [], + importedIdResolutions: [], importedIds: [], importers: [getId('dynamic'), getId('main')], isEntry: false, @@ -220,12 +249,30 @@ module.exports = { sourceType: 'module' }, code: "export const promise = import('external');\nexport { default as internal } from './lib';\n", + dynamicallyImportedIdResolutions: [ + { + external: true, + id: 'external', + meta: {}, + moduleSideEffects: true, + syntheticNamedExports: false + } + ], dynamicallyImportedIds: ['external'], dynamicImporters: [getId('main')], hasModuleSideEffects: true, id: getId('dynamic'), implicitlyLoadedAfterOneOf: [], implicitlyLoadedBefore: [], + importedIdResolutions: [ + { + external: false, + id: getId('lib'), + meta: {}, + moduleSideEffects: true, + syntheticNamedExports: false + } + ], importedIds: [getId('lib')], importers: [], isEntry: false, diff --git a/test/function/samples/manual-chunks-info/_config.js b/test/function/samples/manual-chunks-info/_config.js index 9639ec5fbb2..4780bfcae47 100644 --- a/test/function/samples/manual-chunks-info/_config.js +++ b/test/function/samples/manual-chunks-info/_config.js @@ -99,12 +99,37 @@ module.exports = { sourceType: 'module' }, code: "export const promise = import('./dynamic');\nexport { default as value } from './lib';\nexport { external } from 'external';\n", + dynamicallyImportedIdResolutions: [ + { + external: false, + id: getId('dynamic'), + meta: {}, + moduleSideEffects: true, + syntheticNamedExports: false + } + ], dynamicallyImportedIds: [getId('dynamic')], dynamicImporters: [], hasModuleSideEffects: true, id: getId('main'), implicitlyLoadedAfterOneOf: [], implicitlyLoadedBefore: [], + importedIdResolutions: [ + { + external: false, + id: getId('lib'), + meta: {}, + moduleSideEffects: true, + syntheticNamedExports: false + }, + { + external: true, + id: 'external', + meta: {}, + moduleSideEffects: true, + syntheticNamedExports: false + } + ], importedIds: [getId('lib'), 'external'], importers: [], isEntry: true, @@ -116,12 +141,14 @@ module.exports = { { ast: null, code: null, + dynamicallyImportedIdResolutions: [], dynamicallyImportedIds: [], dynamicImporters: [getId('dynamic')], hasModuleSideEffects: true, id: 'external', implicitlyLoadedAfterOneOf: [], implicitlyLoadedBefore: [], + importedIdResolutions: [], importedIds: [], importers: [getId('main')], isEntry: false, @@ -146,12 +173,14 @@ module.exports = { sourceType: 'module' }, code: 'export default 42;\n', + dynamicallyImportedIdResolutions: [], dynamicallyImportedIds: [], dynamicImporters: [], hasModuleSideEffects: true, id: getId('lib'), implicitlyLoadedAfterOneOf: [], implicitlyLoadedBefore: [], + importedIdResolutions: [], importedIds: [], importers: [getId('dynamic'), getId('main')], isEntry: false, @@ -219,12 +248,30 @@ module.exports = { sourceType: 'module' }, code: "export const promise = import('external');\nexport { default as internal } from './lib';\n", + dynamicallyImportedIdResolutions: [ + { + external: true, + id: 'external', + meta: {}, + moduleSideEffects: true, + syntheticNamedExports: false + } + ], dynamicallyImportedIds: ['external'], dynamicImporters: [getId('main')], hasModuleSideEffects: true, id: getId('dynamic'), implicitlyLoadedAfterOneOf: [], implicitlyLoadedBefore: [], + importedIdResolutions: [ + { + external: false, + id: getId('lib'), + meta: {}, + moduleSideEffects: true, + syntheticNamedExports: false + } + ], importedIds: [getId('lib')], importers: [], isEntry: false, diff --git a/test/function/samples/module-parsed-hook/_config.js b/test/function/samples/module-parsed-hook/_config.js index f0dae77c7d3..c1505d17f54 100644 --- a/test/function/samples/module-parsed-hook/_config.js +++ b/test/function/samples/module-parsed-hook/_config.js @@ -48,12 +48,22 @@ module.exports = { sourceType: 'module' }, code: "export { value } from './dep.js';\n", + dynamicallyImportedIdResolutions: [], dynamicallyImportedIds: [], dynamicImporters: [], hasModuleSideEffects: true, id: ID_MAIN, implicitlyLoadedAfterOneOf: [], implicitlyLoadedBefore: [], + importedIdResolutions: [ + { + external: false, + id: ID_DEP, + meta: {}, + moduleSideEffects: true, + syntheticNamedExports: false + } + ], importedIds: [ID_DEP], importers: [], isEntry: true, @@ -94,12 +104,14 @@ module.exports = { sourceType: 'module' }, code: 'export const value = 42;\n', + dynamicallyImportedIdResolutions: [], dynamicallyImportedIds: [], dynamicImporters: [], hasModuleSideEffects: true, id: ID_DEP, implicitlyLoadedAfterOneOf: [], implicitlyLoadedBefore: [], + importedIdResolutions: [], importedIds: [], importers: [ID_MAIN], isEntry: false, diff --git a/test/function/samples/plugin-module-information/_config.js b/test/function/samples/plugin-module-information/_config.js index 0b8f55f201a..67a5202770d 100644 --- a/test/function/samples/plugin-module-information/_config.js +++ b/test/function/samples/plugin-module-information/_config.js @@ -18,11 +18,13 @@ module.exports = { ast: null, code: null, dynamicImporters: [], + dynamicallyImportedIdResolutions: [], dynamicallyImportedIds: [], hasModuleSideEffects: true, id, implicitlyLoadedAfterOneOf: [], implicitlyLoadedBefore: [], + importedIdResolutions: [], importedIds: [], importers: [], isEntry: id === ID_MAIN, @@ -163,12 +165,37 @@ module.exports = { sourceType: 'module' }, code: "export { foo } from './foo.js';\nexport const nested = import('./nested/nested');\nexport const path = import('path');\nexport const pathAgain = import(thePath);\n", + dynamicallyImportedIdResolutions: [ + { + external: false, + id: ID_NESTED, + meta: {}, + moduleSideEffects: true, + syntheticNamedExports: false + }, + { + external: true, + id: ID_PATH, + meta: {}, + moduleSideEffects: true, + syntheticNamedExports: false + } + ], dynamicallyImportedIds: [ID_NESTED, ID_PATH], dynamicImporters: [], hasModuleSideEffects: true, id: ID_MAIN, implicitlyLoadedAfterOneOf: [], implicitlyLoadedBefore: [], + importedIdResolutions: [ + { + external: false, + id: ID_FOO, + meta: {}, + moduleSideEffects: true, + syntheticNamedExports: false + } + ], importedIds: [ID_FOO], importers: [], isEntry: true, @@ -240,12 +267,22 @@ module.exports = { sourceType: 'module' }, code: "import path from 'path';\n\nexport const foo = path.resolve('foo');\n", + dynamicallyImportedIdResolutions: [], dynamicallyImportedIds: [], dynamicImporters: [], hasModuleSideEffects: 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, @@ -257,12 +294,14 @@ module.exports = { { ast: null, code: null, + dynamicallyImportedIdResolutions: [], dynamicallyImportedIds: [], dynamicImporters: [ID_MAIN], hasModuleSideEffects: true, id: ID_PATH, implicitlyLoadedAfterOneOf: [], implicitlyLoadedBefore: [], + importedIdResolutions: [], importedIds: [], importers: [ID_FOO], isEntry: false, @@ -337,12 +376,22 @@ module.exports = { sourceType: 'module' }, code: "import { foo } from '../foo.js';\n\nexport const nested = 'nested' + foo;\n", + dynamicallyImportedIdResolutions: [], dynamicallyImportedIds: [], dynamicImporters: [ID_MAIN], hasModuleSideEffects: true, id: ID_NESTED, implicitlyLoadedAfterOneOf: [], implicitlyLoadedBefore: [], + importedIdResolutions: [ + { + external: false, + id: ID_FOO, + meta: {}, + moduleSideEffects: true, + syntheticNamedExports: false + } + ], importedIds: [ID_FOO], importers: [], isEntry: false, diff --git a/test/function/samples/preload-module/_config.js b/test/function/samples/preload-module/_config.js index 9364c4b843f..15ce55e3c24 100644 --- a/test/function/samples/preload-module/_config.js +++ b/test/function/samples/preload-module/_config.js @@ -33,11 +33,13 @@ module.exports = { assert.deepStrictEqual(moduleInfo, { code: "import './dep';\nassert.ok(true);\n", dynamicImporters: [], + dynamicallyImportedIdResolutions: [], dynamicallyImportedIds: [], hasModuleSideEffects: true, id: ID_MAIN, implicitlyLoadedAfterOneOf: [], implicitlyLoadedBefore: [], + importedIdResolutions: [], importedIds: [], importers: [], isEntry: false, @@ -71,11 +73,13 @@ module.exports = { assert.deepStrictEqual(moduleInfo, { code: 'assert.ok(true);\n', dynamicImporters: [], + dynamicallyImportedIdResolutions: [], dynamicallyImportedIds: [], hasModuleSideEffects: true, id: ID_DEP, implicitlyLoadedAfterOneOf: [], implicitlyLoadedBefore: [], + importedIdResolutions: [], importedIds: [], importers: [ID_MAIN], isEntry: false,