Closed
Description
Related #5593
- Emit the inlined js module path instead of import statement in the header
Thanks to JSX v4, now we can write the dynamic import for react component:
// LazyComp.res
@react.component
let make = (~x) => React.string(x)
// App.res
@val external import: 'a => Js.Promise.t<'a> = "import"
type option = {ssr?: bool}
@val external dynamic: (unit => Js.Promise.t<'a>, option) => 'a = "dynamic"
module L = {
let make = dynamic(() => import(LazyComp.make), {ssr: false})
}
<L x="lazy" />
This example passes the type checker as we intended, but the import statement in js output should be emitted differently.
As-is:
import * as LazyComp from "./LazyComp.bs.js";
var make = dynamic((function (param) {
return import(LazyComp.make);
}), {
ssr: false
});
To-be:
// omit the import statement
var make = dynamic((function (param) {
return import("./LazyComp.bs.js"); // <-- inlined
}), {
ssr: false
});
Metadata
Metadata
Assignees
Labels
No labels