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

Regression in v0.14.x #2080

Closed
btd opened this issue Mar 4, 2022 · 2 comments
Closed

Regression in v0.14.x #2080

btd opened this issue Mar 4, 2022 · 2 comments

Comments

@btd
Copy link

btd commented Mar 4, 2022

Hi,
thank you for great project it really moved community forward. I caught bug in v0.14 (using vite)
If it is was reported sorry i did not found it.

there is repro repo https://github.com/btd/esbuild-bug

@hyrious
Copy link

hyrious commented Mar 4, 2022

Because you have type: module in package.json, esbuild produces codes that follows the node behavior (https://esbuild.github.io/content-types/#default-interop). In which case you can only do import default_name from "some-cjs-module".

Looks like esbuild drops one pure variable declaration (see it live):

// input
var A = {} // this is pure
A.x = 1
var A = {}
A.y = 2

// output
A.x = 1;
var A = {};
A.y = 2;

Now question: is var A = A || {} pure? It seems esbuild marks all of them as pure.

However, if you manually give it some sife effects, esbuild won't erase it (see it live):

// input
var A = {} // this is pure
A.x = 1
var A = console.log(1) || {} // not pure
A.y = 2
var A = A || {} // pure again
A.y = 3
var A = {} // keep last one
A.y = 4

// output
A.x = 1;
var A = console.log(1) || {};
A.y = 2;
A.y = 3;
var A = {};
A.y = 4;

@magic-akari
Copy link
Contributor

There are two variable declarations in gradient-parser.
The first declarations disappears after esbuild compilation.

https://github.com/rafaelcaricio/gradient-parser/blob/92b6e8011e02e3682064fd2aea20da6becf3347e/build/node.js#L5
https://github.com/rafaelcaricio/gradient-parser/blob/92b6e8011e02e3682064fd2aea20da6becf3347e/build/node.js#L172

magic-akari added a commit to magic-akari/esbuild that referenced this issue Mar 5, 2022
- fix evanw#2080 regression introduced in 4fa3d7a
magic-akari added a commit to magic-akari/esbuild that referenced this issue Mar 13, 2022
- fix evanw#2080 regression introduced in 4fa3d7a
magic-akari added a commit to magic-akari/esbuild that referenced this issue Mar 13, 2022
- fix evanw#2080 regression introduced in 4fa3d7a
magic-akari added a commit to magic-akari/esbuild that referenced this issue Mar 13, 2022
- fix evanw#2080 regression introduced in 4fa3d7a
@evanw evanw closed this as completed in ea3b3d3 Mar 13, 2022
zhusjfaker pushed a commit to speedy-js/esbuild that referenced this issue Mar 28, 2022
hardfist pushed a commit to speedy-js/esbuild that referenced this issue Mar 28, 2022
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

Successfully merging a pull request may close this issue.

3 participants