Uh oh!
There was an error while loading. Please reload this page.
module: accept Windows relative path - #22186
Conversation
There was a problem hiding this comment.
This change looked necessary, but this piece of code does not seem to be used anywhere in node core nor tested. newReturn seems to be passed as true everywhere. Hence, I'm not sure about this, let me know if I should leave this as it was.
There was a problem hiding this comment.
newReturn is for backwards compatibility. There were some people using the private, underscored methods directly and were expecting the old return value.
There was a problem hiding this comment.
Should there be an else clause added that asserts that runTest('.\\lodash') on non-Windows throws or whatever it is supposed to do?
joaocgreis
commented
Aug 10, 2018
@Trott thanks! Updated. CI: https://ci.nodejs.org/view/All/job/node-test-pull-request/16346/ cc @nodejs/platform-windows. Not sure who to ping for modules (the |
phillipj
commented
Aug 15, 2018
Food for thought and too big a discussion for the changes done here, but I feel it's kinda awkward we allow POSIX require paths on Windows, but not Windows paths on POSIX. If we did, it would mean better code portability. But again keeping to POSIX paths would provide that portability cross Windows/POSIX already so 🤷♂️ |
joaocgreis
commented
Aug 16, 2018
cc @nodejs/modules I plan to land this next week if there are no objections. |
bmeck
commented
Aug 16, 2018
@joaocgreis This seems fine for |
benjamingr
left a comment
There was a problem hiding this comment.
This is a huge change and effectively means that code developed on Windows has a lower chance of working on linux/mac which can cause divergence.
Module paths are not file paths.
I'm not sure I object to the change itself but I think there needs to be more discussion before we simply land this.
@bmeck why would this be fine for Also cc @nodejs/platform-windows |
benjamingr
commented
Aug 16, 2018
I'd be totally fine with fixing #21918 though only for |
bmeck
commented
Aug 16, 2018
@benjamingr mostly because |
This PR is a small bug fix for cjs. I'm not sure I fully understand all the red x's to hold it. @benjamingr are you objecting to the comment by @phillipj and not the PR? Much of Node's code already allows forward and back slashes for Windows in paths. This PR fixes one place where it was missed. |
@jdalton mostly, I did not want this to get merged without a LGTM from @nodejs/platform-windows since it changes the behaviour to diverge between windows and other platforms further. If it's consistent and aligns with the policy - then sure. |
jdalton
commented
Aug 16, 2018
@benjamingr Ah ok. @joaocgreis is on the Note: \cc @mhdawson I'd like to be added to @nodejs/platform-windows since its a neighboring Microsoft team (DevPlat) that's tasked with this and it has cross-over into my team (WebPlat DevX). |
Clearing my review given clarifications.
Trott
commented
Aug 16, 2018
@jdalton: I added you to platform-windows |
refack
left a comment
There was a problem hiding this comment.
Let's think about this a little bit more
What does this produce: console.log(require('.\\test.js')===require('./test.js'))P.S. I'm tending towards -1
@jdalton I'm not sure that is a good enough argument to change CJS semantics... This has been there for the lifespan of CJS, right? I'd rather not change it. Which brings up other windows FS quirks such as case sensitivity. console.log(require('.\\test.js')===require('.\\Test.js'))Or is that allowed while console.log(require('./test.js')===require('./Test.js'))is not... |
@refack The example below assumes a path of foo.jsconsole.log("\n"+[path.resolve(".\\bar.js"),require(path.resolve(".\\bar.js")),require("./..\\demo\\bar.js"),require("..\\demo\\bar.js"),require("./bar.js")].join("\n"))bar.jsmodule.exports="bar"Running While I can do As a Windows user I've hit this issue on more than one occasion and was surprised it wasn't addressed. It motivated me fix in my own module loader (a year or so back). This inconsistency/oversight is one of the many cuts that makes the Node Windows experience less-great than other platforms. |
refack
commented
Aug 17, 2018
refack
commented
Aug 17, 2018
BTW: isn't this |
ljharb
commented
Aug 17, 2018
@jdalton would you be able to perhaps open a PR to https://github.com/browserify/resolve that adds a test case for this new behavior? :-D |
jdalton
commented
Aug 17, 2018
Yep. Anywhere there is a one-off path separator check it's easy to overlook. One way to handled this is by abstracting the check to a helper method for broader internal use.
I dig more tests!
It can be.
Yep! |
benjamingr
commented
Aug 17, 2018
Adding the semver-major tag per the discussion. |
joaocgreis
commented
Aug 22, 2018
I agree with CI: https://ci.nodejs.org/view/All/job/node-test-pull-request/16687/ Thanks for the reviews so far! Since this is now |
Trott
commented
Aug 24, 2018
I rebased and tried to force push to fix the dreaded jinja LICENSE CRLF thing, but I don't have permissions to push. @joaocgreis: Can you rebase this against master? |
refack
commented
Aug 24, 2018
Wait. If this reproduces the CRLF issue, I want to investigate. |
9e10faa to
98ce2d5Comparejoaocgreis
commented
Aug 24, 2018
@Trott thanks! Rebased, here we go again: https://ci.nodejs.org/view/All/job/node-test-pull-request/16736/ @refack in case you need, the previous head was 9e10faa54ca78dea007b1b1997d92047c6512037, just the same 3 commits here on top of c6a54af. That was before #22340, the failures look as expected to me. Do you see something unexpected there? |
joaocgreis
commented
Aug 28, 2018
CI is green. |
Trott
left a comment
There was a problem hiding this comment.
LGTM if CITGM doesn't find anything alarming.
Before this change, require('.\\test.js') failed while
require('./test.js') succeeded. This changes _resolveLookupPaths so
that both ways are accepted on Windows.
Fixes: nodejs#2191898ce2d5 to
cf41cb0Comparejoaocgreis
commented
Sep 2, 2018
CitGM (this PR): https://ci.nodejs.org/view/All/job/citgm-smoker/1523/ |
joaocgreis
commented
Sep 5, 2018
@Trott CitGM looks quite red, but similar to master. Do you see anything alarming? |
BridgeAR
commented
Sep 5, 2018
@joaocgreis the failures all seem unrelated to me. These show up in all CITGM runs. There are still a couple of flakes. |
BridgeAR
commented
Sep 5, 2018
joaocgreis
commented
Sep 12, 2018
joaocgreis
commented
Sep 12, 2018
CI is all green. Landed in b36c581. Thanks for all reviews! |
Before this change, require('.\\test.js') failed while
require('./test.js') succeeded. This changes _resolveLookupPaths so
that both ways are accepted on Windows.
Fixes: #21918
PR-URL: #22186
Reviewed-By: Phillip Johnsen <johphi@gmail.com>
Reviewed-By: John-David Dalton <john.david.dalton@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Before this change,
require('.\\test.js')failed whilerequire('./test.js')succeeded. This changes_resolveLookupPathsso that both ways are accepted on Windows.Fixes: #21918 (cc @targos)
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes