Conversation
fix local short circuit to avoid problems when path looks like a github shortcut
This is really nice. +1 |
This looks nice. Update the documentation to explain the new functionality and I'll merge it. Thanks for your patience, Dylan! |
Awesome, thanks @othiym23! Docs added, though let me know if you want more. |
Could this be limited to only paths pointing outside the package's hierarchy? @hughsk and I have been building/using a tool which allows internal dependencies via symlinking into node_modules, allowing us to depend on a local i.e. how a package chooses to organise its child dependencies should not affect the parent package's ability to be published, so long as it's not reaching outside of its own hierarchy. |
@timoxley - great point, and partly for this reason this PR does not include the "disallow publishing when local paths are used" code. The part of my notes that says "The prepublish validation has been removed." were intended to mean that, sorry for the confusing wording. |
@dylang I see that now. Should stuff be able to be published if it depends on |
@timoxley I don't think it should either. @othiym23 requested (last paragraph) I take that part of the PR out for a separate review. My previous code didn't allow any local directories, but I agree directories within the package should be valid. |
Pulled in the latest from master. @othiym23 - I'd love to see this in a |
It's on the list! Just need a chance to do a final review / tweak / merge, probably in the next day or so. |
@dylang when coming across the private package that is served on http service with authorization needed, there is no way for now to input username & password |
, isLocal | ||
|
||
try { | ||
isLocal = fs.statSync(t.from); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We really try to keep sync code out of the core of npm, because it can totally jam up installs if a lot of things are happening at once. Can you rework this to be async?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was surprised when you didn't comment on this glaring sync call earlier. I hate it too.
@dylang I'm seeing some test failures in the |
Also, if you wanted to add a thing to it so that local dependencies are rewritten to be |
Yup, I have it installed, and I see the failures. I was hoping they were unrelated to my PR. I'll look into that. |
This makes sense.
Do you think |
@othiym23 How is this:
All paths are relative to the project because I'm not sure a good way to support absolute and relative paths without it looking really ugly, such as It has to be http://en.wikipedia.org/wiki/File_URI_scheme |
I think i need to update |
@dylang here is my preference:
The RFC wants the two leading slashes, but without is enough in line with existing practice that I'll be able to sleep at night (importantly, I promise you that I'm not trolling you with those Windows paths, but this does raise the question of how absolute Windows paths should be stored in Yeah, |
Since
Interesting, but I think should be handled in a separate PR. |
Absolutely, I was just pointing out that this idea is spreading!
I'll take a look at what it would take to add absolute paths myself, then, because I'm uncomfortable with having a partial solution in there, particularly if it breaks things for Windows but not unix paths. |
I just realized the one test still not passing isn't passing in master either.
|
Hi @dylang @othiym23 , #4853 is partly related, but in my case, I need an independent package served in http service which needed username and password, however, all others dependences are public and can be fetched from npmjs.org. Example: Has this case been addressed? |
@mice530 This sounds like an issue unrelated to @dylang's changes, which are exclusively for adding support to local paths on the same |
It was a bit of a bear to get working with the changes that have since been landed on master, but I landed this as 991484a..4067d6b, and also added 9164acb to get everything squared up. I also had to add d2b1c5e to make this work with PR #6119, so be sure to run Thanks for putting this together, and thanks for your patience! |
Many thanks @othiym23! I really appreciate all your work to get this in. |
hey folks, not super familiar with npm's implementation, but is there a strong reason not to use symlinks for local paths? (or at least have an option for it, such as our use case is we're usually iterating on modules simultaneously, and it's a bummer to (there are external tools that manage this, such as one linked earlier, but might be nice to have built-in support) |
@clayallsopp You may want to take a look at |
@othiym23 yup am aware of that, but I think it's suboptimal for our kind of workflow. I think the ideal API is a declarative way of doing this in package.json:
this seams reasonably close to the using (not sure if this is a use case you'd want to address and totally understand if it's not) |
@clayallsopp , I think what you're suggesting is a great idea. I'd like to develop modules locally, but dislike having to constantly re-install them. Using npm link via a pre-install is indeed very clunky. |
I just found the npm package linklocal which auto-symlinks locally installed npm modules and does just what I'm looking for. Thanks @timoxley for that! |
Adds support for
package.json
to have local paths, such as relative paths to packages which is helpful for testing. Also add support for--save
,--save-dev
to save local paths topackage.json
.This replaces #5570.
As recommended:
fixes #2442
fixes #4018
and possibly others.