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

'failed to find top-level export initSync' #7

Closed
Carlrs opened this issue Jan 12, 2023 · 4 comments
Closed

'failed to find top-level export initSync' #7

Carlrs opened this issue Jan 12, 2023 · 4 comments

Comments

@Carlrs
Copy link

Carlrs commented Jan 12, 2023

Having trouble parsing wasm-bindgen output again, this time it's about exports. File in question:

https://gist.github.com/Carlrs/67035c2639f0df5d4eca13e47f64a2ea

@wilsonzlin
Copy link
Owner

I just tried parsing the provided script and didn't encounter any issues. I also couldn't find any code in the parser that causes an error failed to find top-level export. Which version of the library are you using? I'll also take a look at minify-js to see if there's any issue there.

@wilsonzlin
Copy link
Owner

I believe the issue is in minify-js, and have found a reproducible sample:

function bee() {}
export { bee }

Looking into a solution now.

@wilsonzlin wilsonzlin transferred this issue from wilsonzlin/parse-js Jan 13, 2023
@wilsonzlin
Copy link
Owner

I just had a look again and it appears to be working. It only fails if I choose TopLevelMode::Global, which is incorrect as there's an export. Are you able to reproduce the issue with TopLevelMode::Module?

The error is caused by the fact that in global mode, top-level variables are not actually inside any scope. I'll look at improving the error case and avoiding a panic for this situation.

@wilsonzlin
Copy link
Owner

Closing in favour of #9.

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