{:builds
+ {:build-id
+ {:modules
+ {:module-id
+ {:prepend "window.shadow_esm_import = function(x) { return import(x); };"}}}}}
+diff --git a/docs/UsersGuide.html b/docs/UsersGuide.html index 3c01e08..b64ad65 100644 --- a/docs/UsersGuide.html +++ b/docs/UsersGuide.html @@ -3802,6 +3802,18 @@
There are a couple ways of loading code dynamically. shadow.lazy
is the most convenient and easiest.
+ Note
+ |
+
+shadow.lazy is only intended for use with the :browser target. If you are targeting :esm , consider using shadow.esm/dynamic-import .
+ |
+
This would load an external ESM module dynamically at runtime without it ever being part of the build. You can of course also load your own :modules
dynamically this way too.
This would load an external ESM module dynamically at runtime without it ever being part of the build. You can of course also load your own :modules
dynamically this way too, referencing them by url. It is not currently possible to load your modules by name with dynamic-import
.
dynamic-import
is only intended for use with the :esm
target. The purpose of this helper is to work around an issue with the Closure compiler - we cannot directly call import
from code processed by Closure. dynamic-import
calls a function that wraps import
in a way that Closure cannot interfere with. If you are using a different target such as :browser
, you can make shadow.esm/dynamic-import
work by adding to your build config:
{:builds
+ {:build-id
+ {:modules
+ {:module-id
+ {:prepend "window.shadow_esm_import = function(x) { return import(x); };"}}}}}
+