apollo-universal-starter-kit icon indicating copy to clipboard operation
apollo-universal-starter-kit copied to clipboard

import-js compliant

Open zirho opened this issue 7 years ago • 5 comments

Kutos to Lerna! Hey guys, thank you for the great work. Just wanted to fire up a conversation about recent Lerna migration. I believe that it will give us a lot of advantages on maintainability in a long run.

Here is a thing I believe this project can do better. For me, It became a second nature to use import-js to import other files' exports automatically. Recent Lerna integration totally dismissed the advantage of it and affecting productivity due to the missing property 'main' in each of package.json.

At the same time, I am not 100% sure that I set my dev environment correctly so that auto import to work. For me, I have to calculate how many folders I should hop through manually to import the file correctly. Which is totally feasible compare to the advantage this project gives but I feel like it can be improved.

Do you guys have plan to battle that? or can you explain the way you guys auto-import exports if yours work?

Thanks!

related discussion https://github.com/Galooshi/import-js/issues/504

zirho avatar Mar 25 '19 05:03 zirho

@zirho Hi. I'm not aware of this import-js tool. In your issue report you mention that module-packages have no, main. I think adding that is trivial. Will it make import-js work properly?

larixer avatar Mar 25 '19 05:03 larixer

Hey Victor, Thank you for the response. I will test it out to see if it works later tonight. I believe dependencies also should be populated but I saw you guys talking about that in another issue.

Thanks!

zirho avatar Mar 25 '19 16:03 zirho

@zirho Yes, the dependencies need to be populated as well, but I guess not all of the dependencies, we certainly don't want to declare react dependency in each of the modules, only in core module

larixer avatar Mar 25 '19 17:03 larixer

@zirho ... though if we have react as a peerDependency in every module, and specify exact react version in core module, that would be fine. I just don't want to update react dependency version in 30 packages, only in one package

larixer avatar Mar 25 '19 17:03 larixer

@vlasenko Sorry for the late response.

Although I don't completely understand lerna architecture, just skimmed through the doc briefly, I see what you are saying. Can we have core depends on react and have others depend on core so that they can import react from core? It is just random thought.

Anyway, it seems importjs tries to parse the file and add import code when I add sibling packages in dependencies and add main: index.ts key in package.json. However, it errors out due to the lack of typescript support. (parsing error)

There are certainly few more hoops required to get this working. Maybe import-js can address this by getting aware of yarn workspace feature.

Let me dig more into it. Thanks

zirho avatar Mar 31 '19 04:03 zirho