Support 'packagejson' as a custom cwd option.#149
Conversation
|
@cpsubrian Hey, thanks for your contribution and sorry for taking that long! Two small things:
|
|
@fatfisz Thanks for the review. Will look into those changes and update. |
|
@cpsubrian Hi, could you also rebase this on the The file where you should put the changes now is |
|
@fatfisz Yep, no problem. Will do when I get a moment. Had to jump over to a different project last week. |
Codecov Report
Continue to review full report at Codecov.
|
|
@fatfisz Rebased to |
|
@cpsubrian That's ok, |
|
Ooops, I've only now noticed a small problem in the tests - in two cases you are using |
|
@fatfisz Oh haha, I had fixed those locally but I guess I didn't push them. Oops! |
Some context:
.babelrcconfig at the root level of the repo (not per sub-package).import db from 'src/db', where 'src' is relative to the root of the package of the file being transpiled.This PR facilitates that and is working great for me so far.
Sample
.babelrcconfiguration:{ "plugins": [ ["babel-plugin-module-resolver", { "root": ["./"], "cwd": "packagejson" }] ] }The key is that this approach works not matter what your actual 'cwd' is. This means that my imports work whether I am running
babel-node/babel-watchfrom the repo root, or runningbabelon each sub-package individually.I'm not married to
find-root, it was literally the first 'find my package.json' module that I found 😄