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

[question] Does esbuild preserve variable names between builds? #1641

Closed
sheremet-va opened this issue Sep 29, 2021 · 2 comments
Closed

[question] Does esbuild preserve variable names between builds? #1641

sheremet-va opened this issue Sep 29, 2021 · 2 comments

Comments

@sheremet-va
Copy link

What I mean is:

If I minify one file with esbuild (real world example with vite):

import { ce as createBundle, ab as preserveNames, ... } from './vendor.42afgv2.js';

Will it create the same minified file between different builds and/or different machines?

@evanw
Copy link
Owner

evanw commented Sep 29, 2021

Yes output should be deterministic between builds and machines. If the input between two different builds or two different machines is identical and esbuild is generating different outputs, then that's a bug in esbuild itself.

However, there are potentially some things that could cause the input to be different. If the input is different, esbuild's outputs may be different but that's not a bug in esbuild. Some reasons for the input being different:

  • The relative file path is used as the module identifier, and different package managers put files in different places. So using different package managers causes the input to be different between builds. The fix is to always use the same package manager. See [FeatureRequest] reproducable build among npm and pnpm #1499.

  • Plugins may use non-deterministic names for virtual files generated during the build. In that case the input may be different between builds. The plugin needs to be fixed in this case, not esbuild. See [Bug?] hash not stable with same files #1530.

Also build output is not guaranteed to stay the same across different esbuild versions.

@evanw
Copy link
Owner

evanw commented Oct 4, 2021

Closing because this question was answered.

@evanw evanw closed this as completed Oct 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants