Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IDE cannot resolve imported local file #241

Open
ultimate-tester opened this issue May 19, 2020 · 2 comments
Open

IDE cannot resolve imported local file #241

ultimate-tester opened this issue May 19, 2020 · 2 comments

Comments

@ultimate-tester
Copy link

ultimate-tester commented May 19, 2020

Hi,

I'm shimming a file called "Foo.js". This file is local and it's path relative to my entry file is "../FolderB/Foo.js". With the following configuration I am able to shim it:

"browserify-shim": {
        "Foo": "global:Foo"
    }

And then I imported it with

import Foo from 'Foo'

This works fine with Browserify, but the IDE gets confused and tells me "Module is not installed".
Is there any way to specify the absolute path to the file in browserify-shim config and make it recognize the relative import from my entry file so both Browserify-shim and the IDE are happy?

@bendrucker
Copy link
Collaborator

I don't think so. Is there a reason you're not using a proper relative path, i.e. ./foo? This is important to distinguish between registry/builtin packages and local modules.

@ultimate-tester
Copy link
Author

ultimate-tester commented May 20, 2020

I don't think so. Is there a reason you're not using a proper relative path, i.e. ./foo? This is important to distinguish between registry/builtin packages and local modules.

Yeah, well the reason behind that is that I cannot get the shim to work with a relative path but probably I'm doing something wrong. This is how I would like to import and how the IDE likes it too:

import Foo from '../FolderB/Foo.js'

And then this is what I tried:

Just the name of the module

"browserify-shim": {
        "Foo": "global:Foo"
    }

Same path as import path:

"browserify-shim": {
        "../FolderB/Foo.js": "global:Foo"
    }

Path relative to this package.json file

"browserify-shim": {
        "./src/FolderB/Foo.js": "global:Foo"
    }

With all the above options, the shim doens't work. I verified this by looking in the output javascript file. With the configuration as explained in my first post, the whole class inside Foo disappears from the output which is what I expect.

Any idea?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants