Skip to main content

Code reviews rule: Breaking change in LWC import and export statements

Written by David Martin
Updated today

Breaking change in LWC import and export statements

Why is this an issue?

From LWC version 62.0 and later, Salesforce prevents the use of bare imports, bare exports, and exports from the lwc package.

Examples

Example of incorrect code:

// Don’t do this
import 'lwc';
export * as lwc from 'lwc';
export {} from 'lwc';
export { privateFunction } from 'lwc';

How can I fix violations?

  1. Replace bare imports: Convert to named imports specifying what you need.

  2. Replace bare exports: Use named exports for specific items.

  3. Don't re-export lwc: Import from lwc for use within the component only.

Resources

Did this answer your question?