You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Toplevel module M = await (P: S) compiles to a static import #8815
let module handles that form (bs_builtin_ppx.ml#L417-L439). The toplevel Pstr_module case rewrites only the unconstrained form (L763-L794). module_expr_mapper then strips the await (L854-L856), so the module is imported statically.
Commands (with Primitive_promise.res copied from the runtime and a one-line Primitive_module.res containing external import: 'a => promise<'a> = "%import", each compiled first with bsc -nopervasives):
Expected: B is a dynamic import like A and the local C, for example let B = await import("./p.js");, with no static require of P.
Introduced
ece8b14 already compiles it this way. The comments describing it as a dynamic import come from #8738 (23a4197).
Impact
Writing module M = await (P: S) at toplevel puts P in the static import graph, so it is not code-split, and nothing reports it. The same constrained form inside a function is a dynamic import. Either the toplevel case should handle a module-type path like let module does, or the comments should state the restriction.
Activity