* Applies the plugin by registering its hooks on the compiler. * @param {Dependency} dependency the dependency for which the template should be applied * @param {ReplaceSource} source the current replace source which can be modified * @param {DependencyTemplateContext} templateContext the cont
(
dependency,
source,
{ runtimeTemplate, module, moduleGraph, chunkGraph, runtimeRequirements }
)
| 54 | * @returns {void} |
| 55 | */ |
| 56 | apply( |
| 57 | dependency, |
| 58 | source, |
| 59 | { runtimeTemplate, module, moduleGraph, chunkGraph, runtimeRequirements } |
| 60 | ) { |
| 61 | const dep = /** @type {ImportWeakDependency} */ (dependency); |
| 62 | const content = runtimeTemplate.moduleNamespacePromise({ |
| 63 | chunkGraph, |
| 64 | module: /** @type {Module} */ (moduleGraph.getModule(dep)), |
| 65 | request: dep.request, |
| 66 | strict: /** @type {BuildMeta} */ (module.buildMeta).strictHarmonyModule, |
| 67 | message: "import() weak", |
| 68 | weak: true, |
| 69 | dependency: dep, |
| 70 | runtimeRequirements |
| 71 | }); |
| 72 | |
| 73 | source.replace(dep.range[0], dep.range[1] - 1, content); |
| 74 | } |
| 75 | }; |
| 76 | |
| 77 | module.exports = ImportWeakDependency; |
nothing calls this directly
no test coverage detected