Open rwjblue opened 8 years ago
@stefanpenner - I'm happy to fix this given some guidance...
See https://github.com/emberjs/emberjs-build/pull/175 for where this cropped up.
@rwjblue: ok, well the issue is as follows:
module-base-dir today merely (and likely insufficiently) uses heuristics in the path to work. It looks at your path, and a/b/node_modules/c/b and assumes you have path-to-one-past-node-modules. Which most likely is too naive, and is actually not aligned with the node resolution algorithim.
This means, I believe we must actually inspect the disk, looking for package.json
's to calculate the correct path.
So given:
/a/b/c/node_modules/d/e/f
where f has a package.json
, then the path is /a/b/c/node_modules/d/e/f
but today we only inspect the string, which suggests /a/b/c/node_modules/d
/a/b/c/node_modules/d/e/f
where e has the first “find-up” package.json
, then the path is /a/b/c/node_modules/d/e
/a/b/c/node_modules/d/e/f
where d has the first “find-up” package.json
, then the path is /a/b/c/node_modules/d
/a/b/c/node_modules/d/e/f
where c has the first “find-up” package.json
, then the path is /a/b/c
I suspect the also change is like:
/a/b/c/node_modules/d/e/f
moduleBaseDir
call@rwjblue actually looking at this again, it seems to be working as expected, or at the very least originally how I thought it should work. Now I am not sure which behavior we want. It does seem like it might be nice if it walked up until it found the package.json
, although originally the idea was for subclasses to just provide it explicitly via baseDir
.
It does seem like what you propose betters aligns us with the node ecosystem.
this may actually be fixed now, if you have cycles it may be worth attempting to re-test against master.
A quick rebase proved tricky...
When calling:
An error with the following stack is triggered:
This is because
module-base-dir
does not attempt to resolve thepackage.json
above the provided path.Perhaps adding:
Would fix, but I am uncertain...