Open
Description
I want to ensure the values I use in my webpack obfuscator config are type safe. But for some reason the TypeScript compiler gives me no error if, for example, I use incorrect values like high-obfuscation123
for optionsPreset
:
webpack.config.ts
export const mainConfig: Configuration = {
// ...
plugins: [
// ...
new WebpackObfuscatorPlugin({
optionsPreset: "high-obfuscation123", // No compile time errors. Only runtime ones (during webpack running).
// ...
})
],
// ...
}
I also tried to access configuration types directly but it causes an another runtime error although VSCode successfully recognize imports:
webpack.config.ts
// ...
import WebpackObfuscatorPlugin from 'webpack-obfuscator';
import { OptionsPreset } from 'javascript-obfuscator/typings/src/enums/options/presets/OptionsPreset';
import { SourceMapMode } from 'javascript-obfuscator/typings/src/enums/source-map/SourceMapMode';
import { SourceMapSourcesMode } from 'javascript-obfuscator/typings/src/enums/source-map/SourceMapSourcesMode';
export const mainConfig: Configuration = {
// ...
plugins: [
// ...
new WebpackObfuscatorPlugin({
// ...
optionsPreset: OptionsPreset.LowObfuscation,
sourceMapMode: SourceMapMode.Separate,
sourceMapSourcesMode: SourceMapSourcesMode.Sources,
stringArrayIndexesType: [StringArrayIndexesType.HexadecimalNumericString],
target: ObfuscationTarget.Node
})
],
// ...
}
How can I make my webpack obfuscator config type safe?
Metadata
Metadata
Assignees
Labels
No labels