Add CodeValueObject (#42065)

This commit is contained in:
Yenru Chin
2020-02-04 12:55:38 -08:00
committed by GitHub
parent 7cba407dbd
commit 2fa35a8617
2 changed files with 13 additions and 1 deletions
+2 -1
View File
@@ -1665,7 +1665,7 @@ declare namespace webpack {
}
class DefinePlugin extends Plugin {
constructor(definitions: { [key: string]: DefinePlugin.CodeValuePrimitive});
constructor(definitions: {[key: string]: DefinePlugin.CodeValueObject});
static runtimeValue(
fn: ({ module }: { module: compilation.Module }) => DefinePlugin.CodeValuePrimitive,
fileDependencies?: string[]
@@ -1681,6 +1681,7 @@ declare namespace webpack {
exec(parser: compilation.normalModuleFactory.Parser): CodeValuePrimitive;
}
type CodeValuePrimitive = string | number | boolean | RegExp | RuntimeValue | null | undefined;
type CodeValueObject = CodeValuePrimitive | {[key: string]: CodeValueObject};
}
class DllPlugin extends Plugin {
+11
View File
@@ -446,6 +446,17 @@ plugin = new webpack.DefinePlugin({
BROWSER_SUPPORTS_HTML5: true,
TWO: "1+1",
"typeof window": JSON.stringify("object"),
OBJECT: {
foo: "bar",
bar: {
DEEP_RUNTIME: webpack.DefinePlugin.runtimeValue(
() => JSON.stringify("DEEP_RUUNTIME")
),
foofoo: {
barbar: false
}
}
},
RUNTIME: webpack.DefinePlugin.runtimeValue(
() => JSON.stringify("TEST_VALUE")
)