Skip to content

esbuild: support for dynamic imports to load a lazy chunk #25492

Closed as not planned
@jcompagner

Description

@jcompagner

Command

build

Description

in our code we use this (but we have more constructs like this to load locale or language specific files)

 return new Promise<string>((resolve, reject) => {
            import(
                `@/../../node_modules/@angular/common/locales/${localeId}.mjs`).then(
                module => {
                    registerLocaleData(module.default, localeId);
                    resolve(localeId);
                },
                () => {
                    import(`@/../../node_modules/@angular/common/locales/${language.toLowerCase()}.mjs`).then(module => {
                        registerLocaleData(module.default, localeId.split('-')[0]);
                        resolve(language.toLowerCase());
                    }, reject);
                });
        });

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 chunks

Describe alternatives you've considered

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions