Skip to main content

Hello,

i tried to reproduce the same thing that i found here

https://github.com/trailheadapps/lwc-recipes-oss/tree/main/src/modules/recipe/compositionDynamic

 

But each time i try to push the code to salesforce i get this error:

LWC1503: Dynamic imports are not allowed.

 

here's the JS method that cause this problem

    async loadComponent(lwcCmp) {

        const ctor = await import(lwcCmp);

        this.sectionConstructor = ctor.default;

    }

 

do you have any idea how to solve this problem?

8 risposte
  1. 15 ott 2024, 22:21

    You need to enable Lightning Web Security for Lightning Web Components and Aura Components, go to Setup > Session Settings and turn it on. If this feature is not enabled, you may encounter the error "Dynamic imports are not allowed" when deploying the component.

0/9000