| | |
| | | /** @typedef {import("../javascript/JavascriptParser").Range} Range */ |
| | | |
| | | /** |
| | | * Defines the export in module type used by this module. |
| | | * @typedef {object} ExportInModule |
| | | * @property {Module} module the module |
| | | * @property {string} exportName the name of the export |
| | |
| | | const globToRegexpCache = new WeakMap(); |
| | | |
| | | /** |
| | | * Returns a regular expression. |
| | | * @param {string} glob the pattern |
| | | * @param {Map<string, RegExp>} cache the glob to RegExp cache |
| | | * @param {CacheItem} cache the glob to RegExp cache |
| | | * @returns {RegExp} a regular expression |
| | | */ |
| | | const globToRegexp = (glob, cache) => { |
| | |
| | | |
| | | class SideEffectsFlagPlugin { |
| | | /** |
| | | * Creates an instance of SideEffectsFlagPlugin. |
| | | * @param {boolean} analyseSource analyse source code for side effects |
| | | */ |
| | | constructor(analyseSource = true) { |
| | | /** @type {boolean} */ |
| | | this._analyseSource = analyseSource; |
| | | } |
| | | |
| | | /** |
| | | * Apply the plugin |
| | | * Applies the plugin by registering its hooks on the compiler. |
| | | * @param {Compiler} compiler the compiler instance |
| | | * @returns {void} |
| | | */ |
| | |
| | | }); |
| | | if (this._analyseSource) { |
| | | /** |
| | | * Processes the provided parser. |
| | | * @param {JavascriptParser} parser the parser |
| | | * @returns {void} |
| | | */ |
| | |
| | | |
| | | logger.time("update dependencies"); |
| | | |
| | | /** @type {Set<Module>} */ |
| | | const optimizedModules = new Set(); |
| | | |
| | | /** |
| | | * Optimize incoming connections. |
| | | * @param {Module} module module |
| | | */ |
| | | const optimizeIncomingConnections = (module) => { |
| | |
| | | module |
| | | )) { |
| | | const dep = connection.dependency; |
| | | /** @type {boolean} */ |
| | | let isReexport; |
| | | if ( |
| | | (isReexport = |
| | |
| | | for (const module of modules) { |
| | | optimizeIncomingConnections(module); |
| | | } |
| | | moduleGraph.finishUpdateParent(); |
| | | logger.timeEnd("update dependencies"); |
| | | } |
| | | ); |
| | |
| | | } |
| | | |
| | | /** |
| | | * Module has side effects. |
| | | * @param {string} moduleName the module name |
| | | * @param {SideEffectsFlagValue} flagValue the flag value |
| | | * @param {Map<string, RegExp>} cache cache for glob to regexp |
| | | * @param {CacheItem} cache cache for glob to regexp |
| | | * @returns {boolean | undefined} true, when the module has side effects, undefined or false when not |
| | | */ |
| | | static moduleHasSideEffects(moduleName, flagValue, cache) { |