Skip to content

Conversation

@BridgeAR
Copy link
Member

This removes a lot of code that has no functionality anymore. All
Node.js internal code calls _resolveLookupPaths with two arguments.

The code that validates index.js is not required at all as we check
for these files anyway, so it's just redundant code that should be
removed.

I defensively marked this as semver-major even though I did not find any usage of the third argument outside of Node.js and that would only be an issue if that part was monkey patched.

Refs: #25362

@nodejs/modules PTAL

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

@BridgeAR BridgeAR added the semver-major PRs that contain breaking changes and should be released in the next major version. label Mar 29, 2019
@nodejs-github-bot
Copy link
Collaborator

@BridgeAR Sadly, an error occurred when I tried to trigger a build. :(

@targos
Copy link
Member

targos commented Mar 30, 2019

Can you rebase ?

@BridgeAR BridgeAR force-pushed the remove-module-dead-code branch from 82ad1bd to 846196e Compare March 31, 2019 10:40
@nodejs-github-bot
Copy link
Collaborator

@BridgeAR BridgeAR requested a review from targos March 31, 2019 10:45
@BridgeAR
Copy link
Member Author

BridgeAR commented Apr 1, 2019

@nodejs/modules @nodejs/tsc PTAL.

@BridgeAR BridgeAR requested a review from mcollina April 1, 2019 15:00
@BridgeAR BridgeAR requested a review from guybedford April 3, 2019 00:29
This removes a lot of code that has no functionality anymore. All
Node.js internal code calls `_resolveLookupPaths` with two arguments.

The code that validates `index.js` is not required at all as we check
for these files anyway, so it's just redundant code that should be
removed.
@BridgeAR BridgeAR force-pushed the remove-module-dead-code branch from 846196e to 1abfc93 Compare April 3, 2019 01:54
@nodejs-github-bot
Copy link
Collaborator

@BridgeAR
Copy link
Member Author

BridgeAR commented Apr 3, 2019

Rebased due to conflicts.

@BridgeAR BridgeAR requested review from devsnek, hybrist and jasnell April 3, 2019 12:15
@nodejs-github-bot
Copy link
Collaborator

Copy link
Contributor

@hybrist hybrist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@BridgeAR BridgeAR added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Apr 3, 2019
@BridgeAR
Copy link
Member Author

BridgeAR commented Apr 4, 2019

@nodejs/tsc I would actually like to land this as patch instead of semver-major. I just checked gzemnid and I could not find a single topcode module using the function with three arguments or it is set to true.
Update: I made a mistake here. This is definitely a breaking change due to the changed signature. Only a few actually used modules rely upon that and I'll open PR's to fix these.

@nodejs/modules PTAL

This is really quite a lot of dead code that is hit on each request and thus even minimally slowing down loading.

@ljharb
Copy link
Member

ljharb commented Apr 4, 2019

@BridgeAR could you not remove the dead code in one backportable patch PR, without removing the argument, and land the breaking argument change separately?

@BridgeAR
Copy link
Member Author

BridgeAR commented Apr 4, 2019

@ljharb I could separate that but the returned id would be changed in that case. I guess that property is not used outside of Node.js core and people monkey patching this function only rely upon the second array entry but that's difficult to tell for sure. That's why I wanted to land this together.

@BridgeAR
Copy link
Member Author

BridgeAR commented Apr 5, 2019

@nodejs/tsc PTAL. This is semver-major and still requires reviews from the TSC.

@MylesBorins
Copy link
Contributor

So a thought... will removing this stuff make it harder for us to backport some of the modules stuff to 10.x?

Would it maybe be better to do this change for 13 and keep the delta smaller between 10 and 12?

Copy link
Contributor

@guybedford guybedford left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work.

@MylesBorins which commits are you thinking about specifically here? If this is about ES Modules, the diffs seem separate enough for that not to be an issue. If it is the other PRs done by @BridgeAR or on CommonJS, it would definitely make sense to ensure any CJS loader code is ported in the same order.

@BridgeAR
Copy link
Member Author

BridgeAR commented Apr 5, 2019

@MylesBorins

will removing this stuff make it harder for us to backport some of the modules stuff to 10.x

This should not make that any more difficult. As @guybedford pointed out this diff is separate from any ES Modules code. I believe there where a few things that have to be backported as well for the ES Modules but I don't know about them exactly as I did not do those. AFAIK non of my changes touched any of these things.

Copy link
Member

@Trott Trott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM if CITGM doesn't reveal any surprises

@BridgeAR
Copy link
Member Author

BridgeAR commented Apr 6, 2019

CITGM looks good.

The following modules came up with https://gzemnid.nodejs.org:

899740	vxx-1.2.2.tgz/src/util.js:101:  var resolvedModule = Module._resolveLookupPaths(request, parent);
736731	requizzle-0.2.1.tgz/lib/requizzle.js:43:	var lookupPaths = Module._resolveLookupPaths(targetPath, parentModule);
47202	yui-3.18.1.tgz/get-nodejs/get-nodejs-debug.js:109:                url = Module._findPath(url, Module._resolveLookupPaths(url, module.parent.parent)[1]);
47202	yui-3.18.1.tgz/get-nodejs/get-nodejs.js:105:                url = Module._findPath(url, Module._resolveLookupPaths(url, module.parent.parent)[1]);
47202	yui-3.18.1.tgz/yui-nodejs/yui-nodejs-debug.js:4386:                url = Module._findPath(url, Module._resolveLookupPaths(url, module.parent.parent)[1]);
47202	yui-3.18.1.tgz/yui-nodejs/yui-nodejs.js:4135:                url = Module._findPath(url, Module._resolveLookupPaths(url, module.parent.parent)[1]);
45159	babel-plugin-recharts-1.2.0.tgz/lib/index.js:51:  var _Module$_resolveLooku = _module2.default._resolveLookupPaths(source, finalModule),
4998	rigger-1.0.0.tgz/index.js:305:                .concat(mod._resolveLookupPaths(this.cwd)[1]);

Update: I removed modules that were not impacted from the list.

@BridgeAR
Copy link
Member Author

BridgeAR commented Apr 8, 2019

This already has a couple LGs but it needs one more LG from the @nodejs/tsc. PTAL

@vmarchaud
Copy link
Contributor

@BridgeAR Thanks again for taking the time to make a PR to keymetrics/trassingue but we stopped using this code few months ago, i've archived the repo

@BridgeAR
Copy link
Member Author

BridgeAR commented Apr 8, 2019

Thanks everyone for the reviews.

Landed in d11c4be 🎉

@vmarchaud thanks for letting me know. That was the most impacted module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no pending requests for changes, and a CI started. semver-major PRs that contain breaking changes and should be released in the next major version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants