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

invalid code generated for preact useRef #302

Closed
nitsky opened this issue Jul 30, 2020 · 3 comments
Closed

invalid code generated for preact useRef #302

nitsky opened this issue Jul 30, 2020 · 3 comments

Comments

@nitsky
Copy link
Contributor

nitsky commented Jul 30, 2020

I am observing that esbuild is emitting the invalid code shown below. h3 corresponds to useRef and o3 corresponds to currentHook from preact/hooks: https://github.com/preactjs/preact/blob/3017d91a69f1b52bb89be118e22f4778cb82dd02/hooks/src/index.js#L175. It seems esbuild is choosing to split off currentHook into a separate chunk even though its value is reassigned in useRef. I am using esbuild v0.6.11 and the bundle and splitting flags.

import {
  o3,
} from "./chunk.frH4ZD-M.js";

// ../node_modules/preact/hooks/dist/hooks.module.js
function h3(n3) {
  return o3 = 5, _3(function() {
    return {current: n3};
  }, []);
}
@evanw evanw closed this as completed in 392680e Jul 31, 2020
@evanw
Copy link
Owner

evanw commented Jul 31, 2020

Thank you so much for reporting this. This is a really good test case. I've fixed this issue and the fix will be in the next release. I wrote up some more information about this bug in the release notes.

@evanw
Copy link
Owner

evanw commented Jul 31, 2020

This fix was released in version 0.6.12.

@nitsky
Copy link
Contributor Author

nitsky commented Jul 31, 2020

@evanw thank you so much for the quick fix!

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