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

function is being called before being assigned (undefined variable) #4231

Closed
lemoustachiste opened this issue Sep 27, 2021 · 5 comments · Fixed by rollup/plugins#1038
Closed

Comments

@lemoustachiste
Copy link

Rollup Version

2.57.0

Operating System (or Browser)

Mac Os

Node Version (if applicable)

15

Link To Reproduction

https://github.com/blockchain-certificates/cert-verifier-js/tree/feat/did-support-backup-with-buffer-fallback

Expected Behaviour

When I build and then execute, the functions are not called before being defined.

Actual Behaviour

I have had this bug/issue opened on stackoverflow for about 2 weeks now and I am not making any progress on it, nor getting support. I am starting to wonder if it could be a bug?

https://stackoverflow.com/questions/69165942/rollupjs-function-is-being-called-before-definition-bundled-code

Basically a call is made to a variable that's assigned after it's being called. When I manually change the position of the instantiation, it then does not fail on that issue (but on another one I haven't explored yet).

To repro, use the branch I am pointing to, then npm run build:iife and then npm run test:manual:browser. The output of v3 shows the js error on which it fails.

@lukastaegert
Copy link
Member

Very likely a known issue of the commonjs plugin because it cannot handle circular dependencies in CommonJS code correctly. I have actually started working on a fix, but it will be a long shot until anything will come out of this, weeks at least.

@lemoustachiste
Copy link
Author

Ok thanks for the heads up. I'll try and see how I can reorganize things then

@lemoustachiste
Copy link
Author

ok I see that my error is well documented:
nodejs/readable-stream#348
#1507
rollup/plugins#545

among others, closing.

@lemoustachiste
Copy link
Author

fixed with this approach: nodejs/readable-stream#348 (comment)
Not ideal, but until readable-stream is updated that's an acceptable solution to my problem.

@lukastaegert
Copy link
Member

We are finalizing a new version of the commonjs plugin in rollup/plugins#1038. It is pre-published as @rollup/plugin-commonjs@beta. Please give it a spin to see if it resolves the issue, ideally without additional config needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants