Quellcode durchsuchen

[js] Add `Lib.dynamicImport()` method (#10465)

* [js] Add `Lib.dynamicImport()` method

* [js] Fixed the return type of `Lib.dynamicImport()` method
Cédric Belin vor 3 Jahren
Ursprung
Commit
ec4a73dc81
1 geänderte Dateien mit 8 neuen und 0 gelöschten Zeilen
  1. 8 0
      std/js/Lib.hx

+ 8 - 0
std/js/Lib.hx

@@ -34,6 +34,14 @@ class Lib {
 		js.Syntax.code("debugger");
 	}
 
+	/**
+		Inserts an `import` expression that loads JavaScript object from
+		a module or file specified in the `module` argument.
+	**/
+	public static inline function dynamicImport(module:String):js.lib.Promise<Dynamic> {
+		return js.Syntax.code("import({0})", module);
+	}
+
 	/**
 		Display an alert message box containing the given message.
 		@deprecated Use Browser.alert() instead.