| | |
| | | [RuntimeGlobals.shareScopeMap]: [RuntimeGlobals.hasOwnProperty] |
| | | }; |
| | | |
| | | const FULLHASH_REGEXP = /\[(?:full)?hash(?::\d+)?\]/; |
| | | |
| | | const PLUGIN_NAME = "RuntimePlugin"; |
| | | |
| | | class RuntimePlugin { |
| | | /** |
| | | * Applies the plugin by registering its hooks on the compiler. |
| | | * @param {Compiler} compiler the Compiler |
| | | * @returns {void} |
| | | */ |
| | |
| | | compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => { |
| | | const globalChunkLoading = compilation.outputOptions.chunkLoading; |
| | | /** |
| | | * Checks whether this runtime plugin is chunk loading disabled for chunk. |
| | | * @param {Chunk} chunk chunk |
| | | * @returns {boolean} true, when chunk loading is disabled for the chunk |
| | | */ |
| | |
| | | |
| | | if ( |
| | | typeof publicPath !== "string" || |
| | | /\[(full)?hash\]/.test(publicPath) |
| | | /\[(?:full)?hash\]/.test(publicPath) |
| | | ) { |
| | | module.fullHash = true; |
| | | } |
| | |
| | | .tap(PLUGIN_NAME, (chunk, set, { chunkGraph }) => { |
| | | if ( |
| | | typeof compilation.outputOptions.chunkFilename === "string" && |
| | | /\[(full)?hash(:\d+)?\]/.test( |
| | | compilation.outputOptions.chunkFilename |
| | | ) |
| | | FULLHASH_REGEXP.test(compilation.outputOptions.chunkFilename) |
| | | ) { |
| | | set.add(RuntimeGlobals.getFullHash); |
| | | } |
| | |
| | | .tap(PLUGIN_NAME, (chunk, set, { chunkGraph }) => { |
| | | if ( |
| | | typeof compilation.outputOptions.cssChunkFilename === "string" && |
| | | /\[(full)?hash(:\d+)?\]/.test( |
| | | compilation.outputOptions.cssChunkFilename |
| | | ) |
| | | FULLHASH_REGEXP.test(compilation.outputOptions.cssChunkFilename) |
| | | ) { |
| | | set.add(RuntimeGlobals.getFullHash); |
| | | } |
| | |
| | | .for(RuntimeGlobals.getChunkUpdateScriptFilename) |
| | | .tap(PLUGIN_NAME, (chunk, set) => { |
| | | if ( |
| | | /\[(full)?hash(:\d+)?\]/.test( |
| | | FULLHASH_REGEXP.test( |
| | | compilation.outputOptions.hotUpdateChunkFilename |
| | | ) |
| | | ) { |
| | |
| | | .for(RuntimeGlobals.getUpdateManifestFilename) |
| | | .tap(PLUGIN_NAME, (chunk, set) => { |
| | | if ( |
| | | /\[(full)?hash(:\d+)?\]/.test( |
| | | FULLHASH_REGEXP.test( |
| | | compilation.outputOptions.hotUpdateMainFilename |
| | | ) |
| | | ) { |