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
Use require.resolve instead of the "resolve" package #11125
Use require.resolve instead of the "resolve" package #11125
Conversation
@@ -135,7 +134,7 @@ export function* loadConfig( | |||
envName: string, | |||
caller: CallerMetadata | void, | |||
): Handler<ConfigFile> { | |||
const filepath = yield* resolve(name, { basedir: dirname }); | |||
const filepath = require.resolve(name, { paths: [dirname] }); |
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.
This is now always synchronous, but I don't think that it's a real problem.
sync: (string, {| basedir: string |}) => string; | ||
}; | ||
} | ||
declare var require: { |
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.
Do we still need this as require
is Node.js builtin package?
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.
Yeah, flow doesn't support require.resolve
.
* Remove resolve from package.json * Add flow typings for require.resolve * Run codemod * Remove other usages * Update tests
In #11125 we replaced the "require" package with the require.resolve builtin Node.js function. They have a slightly different behavior: `require.resolve` uses the real file path, while "resolve" keeps symlinks as normal directories.
In #11125 we replaced the "require" package with the require.resolve builtin Node.js function. They have a slightly different behavior: `require.resolve` uses the real file path, while "resolve" keeps symlinks as normal directories.
* Remove resolve from package.json * Add flow typings for require.resolve * Run codemod * Remove other usages * Update tests
In #11125 we replaced the "require" package with the require.resolve builtin Node.js function. They have a slightly different behavior: `require.resolve` uses the real file path, while "resolve" keeps symlinks as normal directories.
* Remove resolve from package.json * Add flow typings for require.resolve * Run codemod * Remove other usages * Update tests
In #11125 we replaced the "require" package with the require.resolve builtin Node.js function. They have a slightly different behavior: `require.resolve` uses the real file path, while "resolve" keeps symlinks as normal directories.
* Remove resolve from package.json * Add flow typings for require.resolve * Run codemod * Remove other usages * Update tests
* Remove resolve from package.json * Add flow typings for require.resolve * Run codemod * Remove other usages * Update tests
In #11125 we replaced the "require" package with the require.resolve builtin Node.js function. They have a slightly different behavior: `require.resolve` uses the real file path, while "resolve" keeps symlinks as normal directories.
* Remove resolve from package.json * Add flow typings for require.resolve * Run codemod * Remove other usages * Update tests
In #11125 we replaced the "require" package with the require.resolve builtin Node.js function. They have a slightly different behavior: `require.resolve` uses the real file path, while "resolve" keeps symlinks as normal directories.
* Remove resolve from package.json * Add flow typings for require.resolve * Run codemod * Remove other usages * Update tests
In #11125 we replaced the "require" package with the require.resolve builtin Node.js function. They have a slightly different behavior: `require.resolve` uses the real file path, while "resolve" keeps symlinks as normal directories.
* Remove resolve from package.json * Add flow typings for require.resolve * Run codemod * Remove other usages * Update tests
In #11125 we replaced the "require" package with the require.resolve builtin Node.js function. They have a slightly different behavior: `require.resolve` uses the real file path, while "resolve" keeps symlinks as normal directories.
* Remove resolve from package.json * Add flow typings for require.resolve * Run codemod * Remove other usages * Update tests
In #11125 we replaced the "require" package with the require.resolve builtin Node.js function. They have a slightly different behavior: `require.resolve` uses the real file path, while "resolve" keeps symlinks as normal directories.
* Remove resolve from package.json * Add flow typings for require.resolve * Run codemod * Remove other usages * Update tests
In #11125 we replaced the "require" package with the require.resolve builtin Node.js function. They have a slightly different behavior: `require.resolve` uses the real file path, while "resolve" keeps symlinks as normal directories.
* Remove resolve from package.json * Add flow typings for require.resolve * Run codemod * Remove other usages * Update tests
In #11125 we replaced the "require" package with the require.resolve builtin Node.js function. They have a slightly different behavior: `require.resolve` uses the real file path, while "resolve" keeps symlinks as normal directories.
* Remove resolve from package.json * Add flow typings for require.resolve * Run codemod * Remove other usages * Update tests
* Remove resolve from package.json * Add flow typings for require.resolve * Run codemod * Remove other usages * Update tests
* Remove resolve from package.json * Add flow typings for require.resolve * Run codemod * Remove other usages * Update tests
* Remove resolve from package.json * Add flow typings for require.resolve * Run codemod * Remove other usages * Update tests
In babel#11125 we replaced the "require" package with the require.resolve builtin Node.js function. They have a slightly different behavior: `require.resolve` uses the real file path, while "resolve" keeps symlinks as normal directories.
* Remove resolve from package.json * Add flow typings for require.resolve * Run codemod * Remove other usages * Update tests
* Remove resolve from package.json * Add flow typings for require.resolve * Run codemod * Remove other usages * Update tests
* Remove resolve from package.json * Add flow typings for require.resolve * Run codemod * Remove other usages * Update tests
* Remove resolve from package.json * Add flow typings for require.resolve * Run codemod * Remove other usages * Update tests
* Remove resolve from package.json * Add flow typings for require.resolve * Run codemod * Remove other usages * Update tests
* Remove resolve from package.json * Add flow typings for require.resolve * Run codemod * Remove other usages * Update tests
The
paths
option is supported starting from node 8.9.0 (https://nodejs.org/api/modules.html#modules_require_resolve_request_options).The upgrade was done using this small codemod (probably it's overkill for this PR, but I expected many more
resolve.sync
usages 😂)