refactor: remove prefetch/preload conflict warning and use RuntimeGlobals.scriptNonce

This commit is contained in:
Ryuya 2025-07-26 17:01:01 -07:00
parent ceac24b37f
commit 5c9de0cd72
2 changed files with 2 additions and 16 deletions

View File

@ -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});`
),
"}"
])

View File

@ -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;