-
Notifications
You must be signed in to change notification settings - Fork 1k
Support newer node versions which changed internalModuleReadJSON #1059
Support newer node versions which changed internalModuleReadJSON #1059
Conversation
The comment you linked to isn't working. Is there any issue or other PR this relates to here? Edit: Nvm, I think there's enough context in the other linked issue. There's likely more to close in this repo. |
The issue fixed by this PR is mentioned in vercel/pkg-fetch#105 - the PR itself is prerequisite for vercel/pkg-fetch#115 |
Thanks for the PR and good job making it backwards-compatible. Indeed, this change is needed for newer versions of Node.js. I picked @alexk111 ‘s similar patch to my fork and it is working perfectly fine in production so far: jesec@44fb852. That revision is not backwards compatible, though. I will merge this PR once I tested it. BTW: As you apparently got the inspiration from @alexk111 , I think it would be fair to add them as co-author or split the change into two. (one for fix, one for backwards compatibility) I can help you to do that. |
@jesec Feel free to split the commit as you think it is best. |
367330b
to
1801a95
Compare
1801a95
to
e4be7cd
Compare
Note to maintainers: "Rebase and merge" here, so authorship of different commits can be preserved. |
Closes: #114 Needs: vercel/pkg#1059
Hold for now. returnArray is somehow true with Node 10.21.0.
e4be7cd
to
602ceb8
Compare
Changes made: @@ -32,8 +32,6 @@ var removeUplevels = common.removeUplevels;
var FLAG_ENABLE_PROJECT = false;
var NODE_VERSION_MAJOR = process.version.match(/^v(\d+)/)[1] | 0;
var NODE_VERSION_MINOR = process.version.match(/^v\d+.(\d+)/)[1] | 0;
-var NODE_VERSION_PATCH = process.version.match(/^v\d+.\d+.(\d+)/)[1] | 0;
-
// /////////////////////////////////////////////////////////////////
// ENTRYPOINT //////////////////////////////////////////////////////
@@ -1201,13 +1199,10 @@ function payloadFileSync (pointer) {
// For newer node versions (after https://github.com/nodejs/node/pull/33229 ):
// Returns an array [string, boolean].
//
- var returnArray = (NODE_VERSION_MAJOR === 12 &&
- (NODE_VERSION_MINOR === 18 && NODE_VERSION_PATCH >= 3) ||
- NODE_VERSION_MINOR > 18) ||
+ var returnArray = (NODE_VERSION_MAJOR === 12 && NODE_VERSION_MINOR >= 19) ||
(NODE_VERSION_MAJOR === 14 && NODE_VERSION_MINOR >= 5) ||
(NODE_VERSION_MAJOR >= 15); Fixes the conditional by simplifying it to ">= 12.19.x". As we are not going to ship =12.18.x and IMO better readability is more important, the VERSION_PATCH part is discarded. |
The PR is inspired by https://github.com/vercel/pkg-fetch/pull105#issuecomment-757116069
This is a pre-requisite for updating to newer Node.js version (currently supports only v12, v14 and for future usage >=v15). The change should preserver backward-compatibility.
Related: #1008 https://github.com/vercel/pkg-fetch/issues/114