Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use obfuscator can not dynamic route imports #13170

Closed
7 tasks done
FeiFanLiang opened this issue May 12, 2023 · 4 comments
Closed
7 tasks done

use obfuscator can not dynamic route imports #13170

FeiFanLiang opened this issue May 12, 2023 · 4 comments

Comments

@FeiFanLiang
Copy link

FeiFanLiang commented May 12, 2023

Describe the bug

When I build the project using obfuscator and turn on stringArray and try to encode the string, the project cannot be accessed normally
image

image

#13020
#13023
I saw the above two issues and updated vite to 4.3.5,but did not solve the problem,Here is a minimal repro, using the same plugin as isue above

Reproduction

https://stackblitz.com/edit/vitejs-vite-tayyd2?file=vite.config.js

Steps to reproduce

Run npm run build
Run npm run preview

System Info

Vite 4.3.5

Used Package Manager

npm

Logs

No response

Validations

@stackblitz
Copy link

stackblitz bot commented May 12, 2023

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

@FeiFanLiang
Copy link
Author

When not using dynamically loaded routes everything works fine

image

@sapphi-red
Copy link
Member

This is happening because the obfuscator replaces __VITE_PRELOAD__ to \x5f\x5f\x56\x49\x54\x45\x5f\x50\x52\x45\x4c\x4f\x41\x44\x5f\x5f when unicodeEscapeSequence is set to true.

As _ can be represented as /_|\\x5f|\\u0005f|\\u{0*5f}/(regex) in JS, I guess supporting this case will require much more computation.

@patak-dev
Copy link
Member

I think this should be fixed in vite-plugin-obfuscator. Maybe reservedString or reservedNames could be used here.

@github-actions github-actions bot locked and limited conversation to collaborators May 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants