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

Update WebGPU.js -- fix error: await is only valid in async functions and the top level bodies of modules #28107

Closed
wants to merge 1 commit into from

Conversation

czl0325
Copy link

@czl0325 czl0325 commented Apr 10, 2024

Related issue:
fix error: await is only valid in async functions and the top level bodies of modules

Description

when I run on chrome,find error: Uncaught SyntaxError: await is only valid in async functions and the top level bodies of modules (at main.1f19ae8e.js:62752:18)

image

A clear and concise description of what the problem was and how this pull request solves it.

await must be in async function

@gkjohnson
Copy link
Collaborator

the top level bodies of modules

The await is at the top level the module file. If this is failing you'll need to check your build process settings or direct a question at the bundler project.

@czl0325
Copy link
Author

czl0325 commented Apr 10, 2024

run in "parcel-bundler": "^1.12.5"

scripts: "parcel src/index.html --open"

@Mugen87 Mugen87 closed this Apr 10, 2024
@czl0325
Copy link
Author

czl0325 commented Apr 10, 2024

this is a code example

https://codepen.io/czl0325/pen/vYMjrOG

@marcofugaro
Copy link
Contributor

@czl0325 Parcel does not support top-level await: parcel-bundler/parcel#4028,
which is currently being used in the WebGPU code.

My suggestion would be to use another bundler.

@czl0325
Copy link
Author

czl0325 commented Apr 10, 2024

Why not consider adding an async function that is compatible with various bundlers?

@gkjohnson
Copy link
Collaborator

If you need help understanding why the code is structured the way it is please ask at the forum. Your suggested change breaks the WebGPU implementation.

@ycw
Copy link
Contributor

ycw commented Apr 14, 2024

aside: top-level-await(=es2022) violated 3's provisions(<=es2018)

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 this pull request may close these issues.

5 participants