Closed
Description
We should evaluate whether it makes sense for dart2wasm recognize <constant-or-literal>.toJS
expressions and canonicalize & move those objects at compile-time to JS (by emitting them into the ...mjs
file and importing those external references) instead of lazily at runtime.
It may be very common to have code such as
@JS()
external JSObject foo(JSString value);
main() {
foo('foo'.toJS);
}
Currently one may be tempted to cache such manually at the top-level via
@JS()
external JSObject foo(JSString value);
final jsFooArg = 'foo'.toJS;
main() {
foo(jsFooArg);
}
but this compiles to worse code in dart2js (see #56045)
/cc @srujzs
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Done