Dynamic import is a way of dynamicly importing a JavaScript file, it's a JavaScript function.
Using webpack we will currently emit code that won't run, as shown by https://github.com/cloudflare/wrangler/issues/1044.
I don't know if we want to support loading file "dynamically" in Cloudflare workers. But if we do we should:
import(lol() + ".js") would be disallowed )It's worth notting that it works with WebAssembly Modules because they are handled differently and we transpile the import function to an identifier (which maps to the worker binding).
await import("something.js")
I see no reason not to support this if it's something the runtime will accept. In my opinion, we should make Wrangler as straightforward to use for simple cases, and make it flexible enough for superusers. If someone can do something through the API and their own build tools, I see no reason not to support in Wrangler.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically closed because it has not had recent activity. You may re-open the issue if it is still relevant.
@xtuc @EverlastingBugstopper is there any conclusion on whether this will be implemented or not? If so, is there any ETA?
The current 1MB script limit makes it impossible to publish any large React app with Cloudflare Workers since Wrangler compiles everything to a single file, you easily end up with 5MB+ files. If dynamic imports were available, then developers could make use of React.lazy to handle lazily importing components via dynamic import.
Most helpful comment
@xtuc @EverlastingBugstopper is there any conclusion on whether this will be implemented or not? If so, is there any ETA?
The current 1MB script limit makes it impossible to publish any large React app with Cloudflare Workers since Wrangler compiles everything to a single file, you easily end up with 5MB+ files. If dynamic imports were available, then developers could make use of
React.lazyto handle lazily importing components via dynamic import.