Skip to content
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

module: resolve _-prefixed dependencies to real path #6460

Closed
wants to merge 5 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,15 @@ Module._findPath = function(request, paths, isMain) {
// For each path
for (var i = 0; i < paths.length; i++) {
// Don't search further if path doesn't exist
const curPath = paths[i];
var curPath = paths[i];
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, this line was fine. It was just the other 3 that were causing problems.

Copy link
Contributor

Choose a reason for hiding this comment

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

I test again on const in loop, it will be TurboFan compiler

node v6.0.0
function testFn(a, b) {
  const foo = [1, 2, 3];
  let total = 0;
  for (const a of foo) {
    const c = a;
    total += c;
  }
  return total;
}
[disabled optimization for 0x3a6acdbf0661 <SharedFunctionInfo formatValue>, reason: TryCatchStatement]
6
[didn't find optimized code in optimized code map for 0x4dca4458ee9 <SharedFunctionInfo testFn>]
[compiling method 0x3b482c0c0669 <JS Function testFn (SharedFunctionInfo 0x4dca4458ee9)> using TurboFan]
[optimizing 0x3b482c0c0669 <JS Function testFn (SharedFunctionInfo 0x4dca4458ee9)> - took 1.139, 0.000, 0.000 ms]
Function is TurboFan compiler

Copy link
Contributor

Choose a reason for hiding this comment

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

@fengmk2 I was tracing this particular function (Module._findPath()) and this particular const usage did not result in aborted or disabled optimizations for the entire containing function.

Copy link
Author

Choose a reason for hiding this comment

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

Switched back to vars.

if (curPath && stat(curPath) < 1) continue;

// If _basePath is a symlink, use the real path rather than the path of the
// symlink as cache key.
const _basePath = path.resolve(curPath, '_' + request);
const basePath = path.resolve(curPath, request);
var _basePath = path.resolve(curPath, '_' + request);
var basePath = path.resolve(curPath, request);

const filename = tryFindPath(basePath, exts, isMain, isAbsolute) ||
var filename = tryFindPath(basePath, exts, isMain, isAbsolute) ||
tryFindPath(_basePath, exts, true, isAbsolute);

if (filename) {
Expand Down