We’ve been using Lerna in Create React App, and I really like its approach. I think we should support a similar workflow (even without Lerna itself) for the “absolute paths” feature.
I imagine it working like this:
- In addition to
src, you can create a special top-level folder called packages.
- Inside
packages, you can create folders like app, stuff, lol, and they all “see” each other so you can import things from app/whatever.js or lol/wow.js. You can also import any packages from src (but not vice versa). The entry point is still src/index.js.
- We won’t add any magic handling that breaks Node resolution mechanism. Instead, whenever you
npm start, npm test, or npm run build, we will run a utility that creates symlinks from node_modules of the root project to every folder in packages. It reports a hard error if there is a conflict. This means the authors can add server rendering after ejecting without scratching their heads, and that all the tooling assuming Node resolution mechanism keeps working.
package.json
public/
src/
index.js # can import app/banana.js or harry-potter/wand.js
packages/
app/
banana.js # can import harry-potter/wand.js
harry-potter/
wand.js # can import app/banana.js
node_modules/
app -> packages/app
harry-potter -> packages/harry-potter
other-deps
Am I missing why this would be a bad idea?
We’ve been using Lerna in Create React App, and I really like its approach. I think we should support a similar workflow (even without Lerna itself) for the “absolute paths” feature.
I imagine it working like this:
src, you can create a special top-level folder calledpackages.packages, you can create folders likeapp,stuff,lol, and they all “see” each other so you can import things fromapp/whatever.jsorlol/wow.js. You can also import any packages fromsrc(but not vice versa). The entry point is stillsrc/index.js.npm start,npm test, ornpm run build, we will run a utility that creates symlinks fromnode_modulesof the root project to every folder inpackages. It reports a hard error if there is a conflict. This means the authors can add server rendering after ejecting without scratching their heads, and that all the tooling assuming Node resolution mechanism keeps working.Am I missing why this would be a bad idea?