From ac8a464fd0f724a8ae1d79818aa39f92086a6670 Mon Sep 17 00:00:00 2001 From: sanex3339 Date: Tue, 7 Apr 2026 10:52:10 +0700 Subject: [PATCH 1/2] Add loader warning for VM obfuscation --- loader/index.ts | 9 +++++++++ package-lock.json | 4 ++-- package.json | 2 +- test/loader.test.ts | 40 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 52 insertions(+), 3 deletions(-) diff --git a/loader/index.ts b/loader/index.ts index 907d913..050a238 100644 --- a/loader/index.ts +++ b/loader/index.ts @@ -32,6 +32,15 @@ async function Loader(this: any, sourceCode: string): Promise { // Extract proApiConfig and onProgress from options const { proApiConfig, onProgress, ...obfuscatorOptions } = options; + if (obfuscatorOptions.vmObfuscation) { + console.warn( + '\x1b[33m[webpack-obfuscator] `vmObfuscation` option is heavily not recommended ' + + 'when used with the loader. Each source file will contain a separate VM runtime, ' + + 'which significantly increases code size and slows down execution. ' + + 'Use the webpack-obfuscator plugin instead, which bundles a single VM runtime.\x1b[0m' + ); + } + const finalOptions = { ...obfuscatorOptions, ignoreRequireImports: true, diff --git a/package-lock.json b/package-lock.json index ac107ab..532be84 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "webpack-obfuscator", - "version": "3.6.0", + "version": "3.6.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "webpack-obfuscator", - "version": "3.6.0", + "version": "3.6.1", "license": "BSD-2-Clause", "dependencies": { "multi-stage-sourcemap": "^0.3.1", diff --git a/package.json b/package.json index 72d34c2..2578d25 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "webpack-obfuscator", - "version": "3.6.0", + "version": "3.6.1", "description": "javascript-obfuscator plugin for Webpack@5", "keywords": [ "obfuscator", diff --git a/test/loader.test.ts b/test/loader.test.ts index f21be7b..8d4a293 100644 --- a/test/loader.test.ts +++ b/test/loader.test.ts @@ -294,4 +294,44 @@ describe('WebpackObfuscatorLoader', () => { expect(output['main.js']).toBeDefined(); }); }); + + describe('vmObfuscation warning', () => { + it('should warn when vmObfuscation option is used', async () => { + const warnSpy = jest.spyOn(console, 'warn').mockImplementation(() => {}); + + const config = createLoaderConfig( + { 'main': './index.js' }, + { vmObfuscation: true } + ); + + try { + await runWebpack(config); + } catch { + // obfuscation may fail, we only care about the warning + } + + expect(warnSpy).toHaveBeenCalledWith( + expect.stringContaining('`vmObfuscation` option is heavily not recommended') + ); + + warnSpy.mockRestore(); + }); + + it('should not warn when vmObfuscation option is not used', async () => { + const warnSpy = jest.spyOn(console, 'warn').mockImplementation(() => {}); + + const config = createLoaderConfig( + { 'main': './index.js' }, + {} + ); + + await runWebpack(config); + + expect(warnSpy).not.toHaveBeenCalledWith( + expect.stringContaining('`vmObfuscation` option is heavily not recommended') + ); + + warnSpy.mockRestore(); + }); + }); }); From b45af83fee56d1f19fd034a9040abcb68036ef32 Mon Sep 17 00:00:00 2001 From: sanex3339 Date: Tue, 7 Apr 2026 10:54:39 +0700 Subject: [PATCH 2/2] Update npmignore --- .npmignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.npmignore b/.npmignore index 9b55694..01f13ab 100644 --- a/.npmignore +++ b/.npmignore @@ -7,4 +7,6 @@ node_modules # include the .d.ts files !*.d.ts tsconfig.json -test \ No newline at end of file +test +.idea +.claude \ No newline at end of file