mirror of https://github.com/webpack/webpack.git
add more compat hooks to MainTemplate
This commit is contained in:
parent
b7ad2b368c
commit
97079ba9a3
|
|
@ -56,6 +56,20 @@ class MainTemplate {
|
|||
"DEP_WEBPACK_MAIN_TEMPLATE_RENDER_MANIFEST"
|
||||
)
|
||||
},
|
||||
modules: {
|
||||
tap: () => {
|
||||
throw new Error(
|
||||
"MainTemplate.hooks.modules has been removed (there is no replacement, please create an issue to request that)"
|
||||
);
|
||||
}
|
||||
},
|
||||
moduleObj: {
|
||||
tap: () => {
|
||||
throw new Error(
|
||||
"MainTemplate.hooks.moduleObj has been removed (there is no replacement, please create an issue to request that)"
|
||||
);
|
||||
}
|
||||
},
|
||||
require: {
|
||||
tap: util.deprecate(
|
||||
(options, fn) => {
|
||||
|
|
@ -67,6 +81,54 @@ class MainTemplate {
|
|||
"DEP_WEBPACK_MAIN_TEMPLATE_REQUIRE"
|
||||
)
|
||||
},
|
||||
beforeStartup: {
|
||||
tap: () => {
|
||||
throw new Error(
|
||||
"MainTemplate.hooks.beforeStartup has been removed (use RuntimeGlobals.startup instead)"
|
||||
);
|
||||
}
|
||||
},
|
||||
startup: {
|
||||
tap: () => {
|
||||
throw new Error(
|
||||
"MainTemplate.hooks.startup has been removed (use RuntimeGlobals.startup instead)"
|
||||
);
|
||||
}
|
||||
},
|
||||
afterStartup: {
|
||||
tap: () => {
|
||||
throw new Error(
|
||||
"MainTemplate.hooks.afterStartup has been removed (use RuntimeGlobals.startup instead)"
|
||||
);
|
||||
}
|
||||
},
|
||||
render: {
|
||||
tap: util.deprecate(
|
||||
(options, fn) => {
|
||||
getJavascriptModulesPlugin()
|
||||
.getCompilationHooks(compilation)
|
||||
.render.tap(options, (source, renderContext) => {
|
||||
if (
|
||||
renderContext.chunkGraph.getNumberOfEntryModules(
|
||||
renderContext.chunk
|
||||
) === 0 ||
|
||||
!renderContext.chunk.hasRuntime()
|
||||
) {
|
||||
return source;
|
||||
}
|
||||
return fn(
|
||||
source,
|
||||
renderContext.chunk,
|
||||
compilation.hash,
|
||||
compilation.moduleTemplates.javascript,
|
||||
compilation.dependencyTemplates
|
||||
);
|
||||
});
|
||||
},
|
||||
"MainTemplate.hooks.render is deprecated (use JavascriptModulesPlugin.getCompilationHooks().render instead)",
|
||||
"DEP_WEBPACK_MAIN_TEMPLATE_RENDER"
|
||||
)
|
||||
},
|
||||
renderWithEntry: {
|
||||
tap: util.deprecate(
|
||||
(options, fn) => {
|
||||
|
|
@ -120,6 +182,27 @@ class MainTemplate {
|
|||
"DEP_WEBPACK_MAIN_TEMPLATE_HASH_FOR_CHUNK"
|
||||
)
|
||||
},
|
||||
globalHashPaths: {
|
||||
tap: util.deprecate(
|
||||
() => {},
|
||||
"MainTemplate.hooks.globalHashPaths has been removed (it's no longer needed)",
|
||||
"DEP_WEBPACK_MAIN_TEMPLATE_HASH_FOR_CHUNK"
|
||||
)
|
||||
},
|
||||
globalHash: {
|
||||
tap: util.deprecate(
|
||||
() => {},
|
||||
"MainTemplate.hooks.globalHash has been removed (it's no longer needed)",
|
||||
"DEP_WEBPACK_MAIN_TEMPLATE_HASH_FOR_CHUNK"
|
||||
)
|
||||
},
|
||||
hotBootstrap: {
|
||||
tap: () => {
|
||||
throw new Error(
|
||||
"MainTemplate.hooks.hotBootstrap has been removed (use your own RuntimeModule instead)"
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
// for compatibility:
|
||||
/** @type {SyncWaterfallHook<[string, Chunk, string, ModuleTemplate, DependencyTemplates]>} */
|
||||
|
|
|
|||
Loading…
Reference in New Issue