sysgears / apollo-universal-starter-kit

Apollo Universal Starter Kit is a SEO-friendly, fully-configured, modular starter application that helps developers to streamline web, server, and mobile development with cutting-edge technologies and ultimate code reuse.
https://apollokit.org
MIT License
1.68k stars 323 forks source link

import-js compliant #1053

Open zirho opened 5 years ago

zirho commented 5 years ago

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

larixer commented 5 years ago

@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?

zirho commented 5 years ago

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!

larixer commented 5 years ago

@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 commented 5 years ago

@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

zirho commented 5 years ago

@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