-
Notifications
You must be signed in to change notification settings - Fork 27
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
Dynamic import should accept multiple arguments #55
Comments
so, basically you would prefer this? return await import("./a.js", { attribute: something }).catch(() => import("./a.js")); it makes it less obvious that the |
// if there is a import.length meta property
if (import.length > 2) import("a", {}) // oops, still SyntaxError. Can not run
else import("a") |
I don't think this makes sense to add separately from the module attributes proposal. Given that there are browsers shipping now without this syntax change, you'd need your feature test to work there too. Let's just continue discussion in the module attributes proposal. |
This can be changed earlier than that proposal so in future it is less pain. (Less range of versions of browsers in this embarrassing situation) |
I don't think I agree that this is important to be able to feature test for. It is really unclear to me how/whether this would be usable in practice, even if it were supported. The typical usage pattern is with a static import, where it will be a syntax error in browsers without module attributes. I'd recommend people initially adopt module attributes similarly to async/await: through transpilers. Can we move this discussion to the module attributes repo? |
You can move it |
So, this proposal lets |
I am running into this issue at the moment. Though it's not an issue for production builds. I reckon there's not much that can be done about this spec-wise though. |
Current syntax:
Proposed syntax:
Currently
import("a", { })
is SyntaxError and it's harder for developers to do "feature detecting" in future. The module attribute proposal is going to add 2nd parameter forImportCall
but developers can't write code like this:Because it is a SyntaxError. IMO it's better to allow more than 1 parameter and throw a runtime error so it will be easier for the developers in the future.
Since the module attribute is just stage 1, make this change in that proposal will be too late. Too many versions of the browser will only accept the exact 1 argument and it's impossible to write the feature detect above.
It's better to extend this syntax asap for the future (and throw at runtime for now) and it won't break anything (because it just makes invalid syntax valid).
The text was updated successfully, but these errors were encountered: