-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
Absolute paths of development environment are leaked to unminified production code #2623
Comments
I can't reproduce this issue with the |
Hello @Timsonrobl. Please provide a online reproduction by codesandbox or a minimal GitHub repository. Issues labeled by |
Sure, here it is: https://github.com/Timsonrobl/vitejs-leak-minrepo |
Got it. Seems only reproducible in Windows. |
I can attest that this is reproducible only on Windows. I scaffolded a Vite project using the var C__Users_Phil_Documents_GitHub_viteReproJs_node_modules_react = { exports: {} }; ...while on Ubuntu 20.04 (WSL 2/Windows 10): var react = { exports: {} }; I'm having problem with Vite where build artifacts generated on Windows and Linux are different, and I suspect this is the root cause. |
It seems the problem originates from @rollup/plugin-commonjs: export function getName(id) {
const name = makeLegalIdentifier(basename(id, extname(id)));
if (name !== 'index') {
return name;
}
const segments = dirname(id).split(sep);
return makeLegalIdentifier(segments[segments.length - 1]);
} This function is used to extract a module's base name from the module ID. For example, The problem is that Vite.js normalizes all module IDs to use forward slashes ( I see two possible ways of fixing this.
|
Vite currently has a bug that causes it to generate different bundles on Windows and Linux. This is caused by a fault in @rollup/plugin-commonjs which is bundled into Vite. We directly fix the fault in our `node_modules/` using patch-package. Let's hope the Rollup devs accept my PR and the fix is integrated into Vite. More links: - Bug reports: - vitejs/vite#2623 - rollup/plugins#923 - Related pull requests: - rollup/plugins#924
Vite currently has a bug that causes it to generate different bundles on Windows and Linux. This is caused by a fault in @rollup/plugin-commonjs which is bundled into Vite. We directly fix the fault in our `node_modules/` using patch-package. Let's hope the Rollup devs accept my PR and the fix is integrated into Vite. More links: - Bug reports: - vitejs/vite#2623 - rollup/plugins#923 - Related pull requests: - rollup/plugins#924
@rollup/plugin-commonjs v20.0.0 fixes the bug (see rollup/plugins#924). Once we update our dependencies, this issue should be resolved. Note: I marked the PR for @rollup/plugin-commonjs as a breaking change (and a major version bump) since it alters how variables are emitted. However, this should be a patch version bump for Vite since it doesn't affect its core functionality. Edit: Should I make a PR for this? Or does the Vite team have an established process for bumping major versions of dependencies? |
Thanks a lot @pastelmind,
We have renovate bot in the repo, at one point it will generate a PR for this. But if you would like to do a PR, I think it is a good idea so this issue is referenced as the reason for the update. |
Describe the bug
"vite build" are currently leaking full paths from development environment if set to
minify: false
.For example if project code is located on
C:\users\sensitive-info-like-user-real-names\projects\myproject\source
vite would add variable names likevar C__users_sensitiveInfoLikeUserRealNames_projects_myproject_source_node_modules_objectInspect
into production code generated byvite build
.I understand that not minifying code for production is not common, however code minification is not a security procedure and should not affect security matters in my opinion.
Reproduction
I'm pretty sure this behavior is universal for any vite project.
System Info
vite
version: 2.1.2Logs (Optional if provided reproduction)
vite
orvite build
with the--debug
flag.The text was updated successfully, but these errors were encountered: