3

I am trying to import a 3rd party javascript library into my LWC and everytime I try to push the code to my Scratch Org, I get the below error.

LWC1513: @salesforce/resourceUrl modules only support default imports.

The library consists to 2 files:

  1. A javascript file
  2. A CSS file

I have zipped these 2 files into one and uploaded them as a static resource. I use the below code in the js file of my LWC:

import { Library } from '@salesforce/resourceUrl/CustomLibrary';

The static resource has the name 'CustomLibrary' in my org. The push succeeds without this line of code though. I spent enough time to figure out what is going wrong but with little success.

I came across a similar link on Stack Overflow, but that didn't help me either.

1
  • remove the curly braces around Library
    – glls
    May 12, 2019 at 14:04

1 Answer 1

6

Default imports dont use curly braces, therefore, your import would be as follows:

import Library from '@salesforce/resourceUrl/CustomLibrary';

this is standard across library imports from the static resource library.

for a more in depth explanation, you can refer to the Javascript Reference documentation

and the LWC Documentation on Accessing Static Resources

3

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .