fix(npm): fix CJS resolution with local node_modules dir (#16547)

This commit fixes CJS resolution when there's a local "node_modules/"
directory.

Before this commit relative imports from CJS files where resolved
relative to
root directory of the package instead of relative to referrer file.
This commit is contained in:
Bartek Iwańczuk 2022-11-06 00:58:21 +01:00 committed by GitHub
parent 384e53308a
commit e7d7da85df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 91 additions and 0 deletions

View file

@ -641,6 +641,14 @@ itest!(node_modules_dir_with_deps {
temp_cwd: true,
});
itest!(node_modules_dir_yargs {
args: "run --allow-read --allow-env --unstable --node-modules-dir $TESTDATA/npm/cjs_yargs/main.js",
output: "npm/cjs_yargs/main.out",
envs: env_vars(),
http_server: true,
temp_cwd: true,
});
#[test]
fn node_modules_dir_cache() {
let _server = http_server();