mirror of https://github.com/webpack/webpack.git
refactor: remove prefetch/preload conflict warning and use RuntimeGlobals.scriptNonce
This commit is contained in:
parent
ceac24b37f
commit
5c9de0cd72
|
@ -49,9 +49,9 @@ class AssetPrefetchPreloadRuntimeModule extends RuntimeModule {
|
|||
// Add nonce if needed
|
||||
compilation.outputOptions.crossOriginLoading
|
||||
? Template.asString([
|
||||
"if(__webpack_require__.nc) {",
|
||||
`if(${RuntimeGlobals.scriptNonce}) {`,
|
||||
Template.indent(
|
||||
"link.setAttribute('nonce', __webpack_require__.nc);"
|
||||
`link.setAttribute('nonce', ${RuntimeGlobals.scriptNonce});`
|
||||
),
|
||||
"}"
|
||||
])
|
||||
|
|
|
@ -242,20 +242,6 @@ class URLParserPlugin {
|
|||
);
|
||||
}
|
||||
|
||||
// Warn if both prefetch and preload are specified
|
||||
if (
|
||||
importOptions.webpackPrefetch !== undefined &&
|
||||
importOptions.webpackPreload !== undefined
|
||||
) {
|
||||
parser.state.module.addWarning(
|
||||
new CommentCompilationWarning(
|
||||
"Both webpackPrefetch and webpackPreload are specified. " +
|
||||
"webpackPreload will take precedence for immediate loading.",
|
||||
/** @type {DependencyLocation} */ (expr.loc)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Store hints on the dependency for later use
|
||||
dep.prefetch = importOptions.webpackPrefetch;
|
||||
dep.preload = importOptions.webpackPreload;
|
||||
|
|
Loading…
Reference in New Issue