Skip to main content

Code reviews rule: Dynamic imports for platformResourceLoader

Written by David Martin
Updated this week

Dynamic imports for platformResourceLoader

Why is this an issue?

Salesforce no longer allows dynamic imports of the lightning/platformResourceLoader module. You must use a static import declaration instead.

Examples

Example of incorrect code:

const loader = await import("lightning/platformResourceLoader");

Example of correct code:

import { loadScript, loadStyle } from 'lightning/platformResourceLoader';

How can I fix violations?

Replace the dynamic import() call with a static import declaration at the top of your module.

Resources

Did this answer your question?