getkey/rollup-plugin-obfuscator

How to solve this error?

CRC32EX opened this issue · 2 comments

Steps to reproduce this issue

  1. Init Vue3 project
npm init vue@latest

image

  1. Install modules
cd vue-project
npm install
npm install --save-dev rollup-plugin-obfuscator javascript-obfuscator
  1. Edit vite.config.ts
vim vite.config.ts

image

  1. Build
npm run build
  1. Error
vite v2.8.6 building for production...
✓ 6 modules transformed.
[rollup-plugin-obfuscator] Line 4: Unexpected token import
> ...ateWebHistory(import.meta.env....
file: C:/Users/user01/Desktop/vue-project/src/router/index.ts
error during build:
Error: Line 4: Unexpected token import
> ...ateWebHistory(import.meta.env....
    at Function.processParsingError (C:\Users\user01\Desktop\vue-project\node_modules\javascript-obfuscator\dist\webpack:\JavaScriptObfuscator\src\EspreeFacade.ts:100:15)
    at Function.parse (C:\Users\user01\Desktop\vue-project\node_modules\javascript-obfuscator\dist\webpack:\JavaScriptObfuscator\src\EspreeFacade.ts:44:46)
    at e.parseCode (C:\Users\user01\Desktop\vue-project\node_modules\javascript-obfuscator\dist\webpack:\JavaScriptObfuscator\src\JavaScriptObfuscator.ts:151:29)
    at e.obfuscate (C:\Users\user01\Desktop\vue-project\node_modules\javascript-obfuscator\dist\webpack:\JavaScriptObfuscator\src\JavaScriptObfuscator.ts:132:46)
    at Object.value [as obfuscate] (C:\Users\user01\Desktop\vue-project\node_modules\javascript-obfuscator\dist\webpack:\JavaScriptObfuscator\src\JavaScriptObfuscatorFacade.ts:31:70)
    at Object.exports.default.transform (C:\Users\user01\Desktop\vue-project\node_modules\rollup-plugin-obfuscator\src\rollup-plugin-obfuscator.ts:52:38)
    at C:\Users\user01\Desktop\vue-project\node_modules\rollup\dist\shared\rollup.js:22779:37
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

The issue you're facing is not in rollup-plugin-obfuscator but in javascript-obfuscator (observe how the top of the stack trace is in node_modules\javascript-obfuscator).
Therefore I cannot solve your issue, but upstream will be able to help you! You can go there to open an issue.

In my use-case setting global: true fixed it.