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

Splitting results in Dynamic require of "<filename>" is not supported when targeting chrome62 #3724

Open
jluxenberg opened this issue Apr 10, 2024 · 0 comments

Comments

@jluxenberg
Copy link

jluxenberg commented Apr 10, 2024

Description

We're trying out "splitting: true" using the ESM output format.

Our build currently targets chrome62.

When we enable splitting, I get the following error when the dynamic import is attempted:

Dynamic require of "<filename>" is not supported

Steps to reproduce

Try changing "chrome62" to "chrome63" here:
https://esbuild.github.io/try/#YgAwLjIwLjIALS1idW5kbGUgLS1vdXRkaXI9ZGlzdC8gLS1zcGxpdHRpbmcgLS1mb3JtYXQ9ZXNtIC0tdGFyZ2V0PWNocm9tZTYyAGUAZW50cnkuanMAY29uc3QgZjEgPSAoKSA9PiB7CiAgY29uc3QgeCA9IGltcG9ydCgnLi9maWxlLmpzJyk7CiAgY29uc29sZS5sb2coIngiLCB4KTsKfQoKZjEoKTsAAGZpbGUuanMAZXhwb3J0IGRlZmF1bHQgNDI7

Notice that in the "chrome62" version, the dynamic require is done via __require from the esbuild runtime.

You can try running the "chrome62" version in a browser, you will see the Dynamic require ... error.

Expected result

Dynamic imports work when targeting chrome62, or a build-time error is generated (e.g. "dynamic imports / splitting not supported on this target")

Actual result

The code is split into multiple chunks, however the code produced cannot actually dynamically import those chunks.

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

1 participant