-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Code splitting does not enforce strict mode #749
Comments
The ESM format itself invokes strict mode |
@lukeed that's the problem, a |
Right, but that's not a bundler/code-splitting issue. It's an intentional design feature of ESM altogether. So unless/until SystemJS is supported (#192), I don't think you're going to be able to use that dependency and |
I'm currently working on an overhaul of code splitting which will add support for code splitting with the It's true that esbuild doesn't currently enforce strict mode at compile time. You should be able to use other tools for that though such as a linter. It should be possible to set one up to reject things like this so they don't make it into your source code in the first place. FWIW the Doing
There isn't an easy way of transforming JavaScript that uses |
Very cool, congrats! |
When using code splitting and dynamic imports, the only format actually producing chunks is
esm
right now. So the resulting entry point needs to be loaded with a<script type="module"...
element. However, the module type forces scripts to be loaded in strict mode.I ran into this scenario because some library from npm uses the
with
statement. That statement is forbidden in strict mode but esbuild doesn't account for that, resulting in an invalid output that will cause an error in the browser.I have put together an example repo: https://github.com/Ventajou/esbuild-import
No idea if there are more cases like this, I'm hopng it's relatively easy for esbuild to remove
with
because right now I have no way around this..The text was updated successfully, but these errors were encountered: