Issue
Scoped imports are not allowed in a custom Lightning Web Component (LWC) when that component uses the runtime namespace tag in its LWC XML configuration file. The import fails and the component does not load or compile as expected.
Symptoms
.js-meta.xml configuration file.Applies To
Root Cause
This is a known limitation of Lightning Locker. Lightning Locker wraps component JavaScript in secure wrappers to enforce namespace isolation, and under this architecture scoped imports in combination with the runtime namespace tag are not supported. The behavior is expected under Lightning Locker; it is not a defect in your component code. Salesforce's newer security architecture, Lightning Web Security (LWS), is designed to replace Lightning Locker for Lightning web components. Lightning Locker remains in use for Aura components in orgs where LWS is not yet enabled for Aura.
To resolve the limitation, switch the org's Lightning web component security to Lightning Web Security (LWS), which supports scenarios Lightning Locker restricts.
Recommended: test in a sandbox first
Session, then select Session Settings.Note: LWS is generally available and is enabled by default for orgs created in Winter '23 and later, so this limitation typically appears only in orgs still running Lightning Locker for Lightning web components.
What Lightning Web Security supports
Lightning Web Security provides capabilities that Lightning Locker does not:
window, document, element) without secure wrappersIf you need to revert
To turn the setting off again, return to Setup → Session Settings, deselect Use Lightning Web Security for Lightning web components and Aura components, save, and clear your browser cache. The org returns to Lightning Locker for Lightning web components (and the scoped-import limitation applies again).
Additional Resources
000395260

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.