| | |
| | | |
| | | "use strict"; |
| | | |
| | | const Module = require("../Module"); |
| | | const { JAVASCRIPT_TYPE } = require("../ModuleSourceTypeConstants"); |
| | | const makeSerializable = require("../util/makeSerializable"); |
| | | const HarmonyImportDependency = require("./HarmonyImportDependency"); |
| | | |
| | |
| | | /** @typedef {import("../Dependency")} Dependency */ |
| | | /** @typedef {import("../Dependency").GetConditionFn} GetConditionFn */ |
| | | /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */ |
| | | /** @typedef {import("../Module")} Module */ |
| | | /** @typedef {import("../ModuleGraph")} ModuleGraph */ |
| | | /** @typedef {import("../ModuleGraphConnection").ConnectionState} ConnectionState */ |
| | | /** @typedef {import("../javascript/JavascriptParser").ImportAttributes} ImportAttributes */ |
| | |
| | | |
| | | class HarmonyImportSideEffectDependency extends HarmonyImportDependency { |
| | | /** |
| | | * Creates an instance of HarmonyImportSideEffectDependency. |
| | | * @param {string} request the request string |
| | | * @param {number} sourceOrder source order |
| | | * @param {ImportPhaseType} phase import phase |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns function to determine if the connection is active. |
| | | * @param {ModuleGraph} moduleGraph module graph |
| | | * @returns {null | false | GetConditionFn} function to determine if the connection is active |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets module evaluation side effects state. |
| | | * @param {ModuleGraph} moduleGraph the module graph |
| | | * @returns {ConnectionState} how this dependency connects the module to referencing modules |
| | | */ |
| | |
| | | HarmonyImportDependency.Template |
| | | ) { |
| | | /** |
| | | * 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 context object |
| | |
| | | */ |
| | | apply(dependency, source, templateContext) { |
| | | const { moduleGraph, concatenationScope } = templateContext; |
| | | if (concatenationScope) { |
| | | |
| | | const module = /** @type {Module} */ (moduleGraph.getModule(dependency)); |
| | | if (concatenationScope.isModuleInScope(module)) { |
| | | |
| | | if (module && !Module.getSourceBasicTypes(module).has(JAVASCRIPT_TYPE)) { |
| | | // no need to render import |
| | | return; |
| | | } |
| | | |
| | | if (concatenationScope && concatenationScope.isModuleInScope(module)) { |
| | | return; |
| | | } |
| | | super.apply(dependency, source, templateContext); |
| | | } |