import-js icon indicating copy to clipboard operation
import-js copied to clipboard

Import location not added on file change in certain cases

Open ivangeorgiew opened this issue 7 years ago • 3 comments

When there was a file b.js containing export * from 'a' and I add a new variable const someVariable = 123 in a file a.js, then in a third file if I want to import the someVariable importjs won't give the the option to import it from b.js

ivangeorgiew avatar Jun 01 '18 07:06 ivangeorgiew

Do things change if you give export * from 'a' a relative path? => export * from './a'. If that doesn't work, can you see if you can modify this test to reproduce? https://github.com/Galooshi/import-js/blob/017c7445d5adc71faff4a1eee1cc38beb2e2307b/lib/tests/findExports-test.js#L515

trotzig avatar Jun 04 '18 08:06 trotzig

In my fork of the project I have fixed a bunch of problems including this one. All the tests are passing, but surely you will want for me to add tests which I am too lazy to learn how to do.

The problems I fixed are the following:

  1. specify project root
  2. added logic for watching files with export * from
  3. import computed keys in aliased desctructured constants
  4. proper sorting by package name/filepath with exception for React being on top
  5. import VALUE from obj[VALUE]

Is there a point for me to make a PR with all these changes?

ivangeorgiew avatar Jun 15 '18 06:06 ivangeorgiew

Nice! I'm definitely open to reviewing these changes. When you do open a PR, can you make sure to explain each change (why it is needed, trade-offs with your implementation compared to others, etc)?

For testing, the Importer test will probably be a good target for most changes: https://github.com/Galooshi/import-js/blob/master/lib/tests/Importer-test.js

trotzig avatar Jun 18 '18 08:06 trotzig

Closing this as stale.

I also could not reproduce the behavior in the first comment. Having the files below, when importing c.js I'm given the option to choose between a.js and b.js. The original problem might have been a failure to resolve a non-relative dependency.

a.js

export const someVariable = 123;

b.js

export * from "./a.js";

c.js

console.log(someVariable);

mikabytes avatar Feb 05 '24 08:02 mikabytes