-
Notifications
You must be signed in to change notification settings - Fork 12k
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
esbuild: support for dynamic imports to load a lazy chunk #25492
Comments
What do you mean by it doesn't work ? What kind of issues do you have ? |
Dynamic imports with template literals is a Webpack specific feature which is not supported by esbuild. See: evanw/esbuild#56 Instead what you can do is to copy the locale data as assets and import those. |
i will investigate a bit more but what is generated is way less: esbuild:
but a normal build generates:
so you can see from angular_commons every locale has 1 js file also included in the output We have no idea what users are using our product, we can't hard code that at all so all the language/locale stuff is loaded when needed for the locale/language the user is in thats stuff of angular itself from "common" but also "uppy", "numbro" so with an esbuild i don't see all those files generated, so my assumption is that they really don't work and i also get an error that points to that direction i get:
exactly from the stack of the above code, so those 2 imports are both failing and i get that error. |
This is a known issue. For additional information please see the developer preview guide found here: https://angular.io/guide/esbuild#runtime-evaluated-dynamic-import-expressions |
hmm so i need to copy it all my self in all the dynamic imports we have throughout our code (which is quite a few places)
but if i copied it with assets to the root like "locales" folder
that is quite a change for us.. |
ai, thats even worse.. because you can't also use expressions? |
From the guide:
Imports kept in their original form can contain whatever JavaScript allows. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Command
build
Description
in our code we use this (but we have more constructs like this to load locale or language specific files)
but that doesn't seem to work in an esbuild.
is there another way? The none esbuild will generate for our product a huge number of files because of this (all the locale files that match that pattern)
Describe the solution you'd like
that the above import(
string with variable
) does work to load in specific lazy chunksDescribe alternatives you've considered
No response
The text was updated successfully, but these errors were encountered: