getkey / rollup-plugin-obfuscator

The most powerful rollup plugin for javascript-obfuscator.
Mozilla Public License 2.0
121 stars 9 forks source link

How to solve this error? #7

Closed CRC32EX closed 2 years ago

CRC32EX commented 2 years ago

Steps to reproduce this issue

  1. Init Vue3 project

    npm init vue@latest

    image

  2. Install modules

    cd vue-project
    npm install
    npm install --save-dev rollup-plugin-obfuscator javascript-obfuscator
  3. Edit vite.config.ts

    vim vite.config.ts

    image

  4. Build

    npm run build
  5. 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)
getkey commented 2 years ago

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.

vuolter commented 2 months ago

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