I’m using Salesforce CLI with Visual Code IDE.
I imported a 3rd party library to the scratch orgs static resources. Then I ran the sfdx:source: pull command to pull it into my Visual Code project.
I created an LWC component that imports the 3rd party library from static resources.
import { Config } from ‘@salesforce/resourceUrl/my3rdPartyModule/directoryName/index.js’
When I attempt to push the new component to the scratch org, I encounter the following error:
LWC1513: @salesforce/resourceUrl modules only support default imports.
What does the error mean? Is there a solution for this?
Best Answer
You seem to have incorrect syntax for importing the static resource in the JS. The approach for using 3rd party resource is to upload the static resource and then import it in your JS as below.
Import the Static Resource:
And then utilize
loadStyle
andloadScript
to load those resources (JS and CSS) fromlightning/platformResourceLoader
:Refer to the documentation for more details on the syntax and details.