-
Notifications
You must be signed in to change notification settings - Fork 455
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 support #3919
Comments
Is this regarding #2765 ? |
@yawaramin yes, except the proposal here is more type safe? |
@bobzhang your approach here made me think about this a bit more and now I think we can do dynamic imports with just (* foo.ml *)
let x = 0
(* import.ml *)
module type FOO = sig
val x : int
end
external foo : (_ [@bs.as "./foo.bs"]) -> (module FOO) Js.Promise.t =
"import" [@@bs.val]
let _ = foo |> Js.Promise.then_(fun (module Foo : FOO) ->
Foo.x |> Js.log |> Js.Promise.resolve) This generates: // Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE
'use strict';
import("./foo.bs").then((function (Foo) {
return Promise.resolve((console.log(Foo.x), /* () */0));
}));
/* Not a pure module */ [EDIT: this is possible now thanks to the modules-as-objects change! On previous versions this would compile as |
@bobzhang has there been progress on this? that'd be crucial for overall performance |
@bobzhang any update? :-) |
@yawaramin your solution works fine. Can we make it little more generic, so that it works for any module. Something like below
|
@tejesh014 sure, that makes sense. I'll write up an article about it on my blog when I get some time. |
I'm also interested in whether there has been any recent movement/plans here. 👀 |
Also looking to this |
hey, any changes here? |
Todo:
The text was updated successfully, but these errors were encountered: