diff --git a/declarations/WebpackOptions.d.ts b/declarations/WebpackOptions.d.ts index 194ad7704..270b72af3 100644 --- a/declarations/WebpackOptions.d.ts +++ b/declarations/WebpackOptions.d.ts @@ -753,6 +753,10 @@ export type OptimizationSplitChunksGetCacheGroups = ( | OptimizationSplitChunksCacheGroup | OptimizationSplitChunksCacheGroup[] | void; +/** + * The name of the trusted types policy created by webpack to serve bundle chunks. Defaults to 'webpack'. + */ +export type TrustedTypesPolicyName = string; /** * Options object as provided by the user. @@ -3038,6 +3042,10 @@ export interface OutputNormalized { * Handles exceptions in module loading correctly at a performance cost (Deprecated). This will handle module error compatible with the Node.js CommonJS way. */ strictModuleExceptionHandling?: StrictModuleExceptionHandling; + /** + * The name of the trusted types policy created by webpack to serve bundle chunks. Defaults to 'webpack'. + */ + trustedTypesPolicyName?: TrustedTypesPolicyName; /** * A unique name of the webpack build to avoid multiple webpack runtimes to conflict when using globals. */ diff --git a/lib/config/defaults.js b/lib/config/defaults.js index c107408d2..fbc732e52 100644 --- a/lib/config/defaults.js +++ b/lib/config/defaults.js @@ -713,6 +713,7 @@ const applyOutputDefaults = ( D(output, "hashFunction", "md4"); D(output, "hashDigest", "hex"); D(output, "hashDigestLength", 20); + D(output, "trustedTypesPolicyName", "webpack"); D(output, "strictModuleExceptionHandling", false); const optimistic = v => v || v === undefined; diff --git a/test/configCases/trusted-types/default-policy-name/index.js b/test/configCases/trusted-types/default-policy-name/index.js index 87287689a..348166171 100644 --- a/test/configCases/trusted-types/default-policy-name/index.js +++ b/test/configCases/trusted-types/default-policy-name/index.js @@ -2,7 +2,6 @@ it("should use default trusted types policy name", function() { // emulate trusted types in a window object const noop = (i) => i const rules = { - createURL: noop, createScriptURL: noop, } window.trustedTypes = { diff --git a/types.d.ts b/types.d.ts index 96ae21a29..35c45573b 100644 --- a/types.d.ts +++ b/types.d.ts @@ -7937,6 +7937,11 @@ declare interface OutputNormalized { */ strictModuleExceptionHandling?: boolean; + /** + * The name of the trusted types policy created by webpack to serve bundle chunks. Defaults to 'webpack'. + */ + trustedTypesPolicyName?: string; + /** * A unique name of the webpack build to avoid multiple webpack runtimes to conflict when using globals. */