3

I am trying to import the following (highlighted in yellow) file into my LWC component-enter image description here

I am trying to import mycomponent-share.js into the mycomponent.js. The mycomponent-share.js contains the following code-

export function isFunction(value) {
return typeof value === 'function';
}

I am using the following code to import it into mycomponent.js

import { isFunction } from 'mycomponent-share'

But this is not working, please help me.

1 Answer 1

8

You need to tell the LWC compiler to use a relative path:

import { isFunction } from './mycomponent-share';
3
  • 1
    Thanks, this solved my problem. Commented Jan 7, 2020 at 14:48
  • @user2246808 Please accept the answer, so it will help other people. Commented Jan 7, 2020 at 14:50
  • Is there some way to specify that the extension ".js" should be accepted in the import name?
    – kamezaburo
    Commented Oct 27, 2020 at 0:46

You must log in to answer this question.

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