New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make sure entry paths are always full paths #1248
Conversation
Looks great, published in 10.1.1. |
@zertosh @substack I think we need to decide exactly how (and where) entry file paths will be resolved and document it more. This PR is a bit different, but reminiscent of the situation with #1033 / #1059 / #1077. This PR pseudo-resolves the paths and module-deps still actually resolves them, so unfortunately this does not ensure that Here's a very simple repro (given an var
browserify = require('browserify'),
row_flow = require('browserify-row-flow');
browserify('./entry')
.plugin(row_flow().plugin())
.bundle()
; You can see that it exits the Re: #1219 (comment), I almost brought this up over there that the CLI and API resolve entry file paths differently, but I figured it's a divergence that makes sense so I didn't bother. As of v10.1.0 entry files provided to the API were resolved using the module resolution algorithm. So the following were not equivalent: browserify('./entry');
browserify('entry'); I figure it makes sense for the CLI to resolve This PR changes the resolution behavior of the second case: browserify('entry'); Previously, if there were a |
Probably the worst behavior is having the API and CLI do different things. Sure, this PR doesn't ensure that the file exists, but it brings consistency.
The best thing to do is to just delegate to mdeps. This line is what preserves the input row's file. Just remove the
It's still trivial. Just pass in an absolute path :) |
Maybe. They're pretty different animals though and I'd hate to see compromises made for the CLI pollute the API. The CLI and API would be more consistent if you could do
That's pretty much what I've been thinking and what I did for a similar case in #1077.
For me it just circles back to my questions in #1162 -- what is
Well it's even more trivial now since it happens by default. What is now less trivial is using a module name to refer to an entry file. I guess now you'd have to manually invoke node-resolve on it, or if you're sure you want to resolve it from |
It looks like this broke being able to name a module and file location using the browser field in package.json What's worse is that with the JSONStream changes trying to downgrade fails due to the missing dependency. |
@Gillingham Can you please open an issue with a simple reproduction for the |
When using the CLI, entry files were always resolved to absolute paths, but when using the API, they weren't. module-deps respects the
row.file
on its initial rows insofar that it resolved relative paths (based onopts.basedir
) but it didn't rewrite it on therow
. This led to a weird behavior with watchify where entry files were never being pulled from the cache - unless you used the CLI or passed in an absolute path via the API.Using
basedir
to resolve the path is consistent with @substack's view on path resolution ("require vs entry" in #1219 (comment)).This PR also adds a few tests that use the relative path behavior and extends others to verify that
row.file
is always the absolute path.cc: @jmm @terinjokes