| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 05c3ff5 commit 7f1c83e
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -374,18 +374,24 @@ function finalizeResolution(resolved, base, preserveSymlinks) { | |||
| 374 | 374 | resolved.pathname, 'must not include encoded "/" or "\\" characters', | |
| 375 | 375 | fileURLToPath(base)); | |
| 376 | 376 | ||
| 377 | - const path = fileURLToPath(resolved); | ||
| 377 | + let path = fileURLToPath(resolved); | ||
| 378 | 378 | if (getOptionValue('--experimental-specifier-resolution') === 'node') { | |
| 379 | 379 | let file = resolveExtensionsWithTryExactName(resolved); | |
| 380 | - if (file !== undefined) return file; | ||
| 381 | - if (!StringPrototypeEndsWith(path, '/')) { | ||
| 382 | - file = resolveDirectoryEntry(new URL(`${resolved}/`)); | ||
| 383 | - if (file !== undefined) return file; | ||
| 384 | - } else { | ||
| 385 | - return resolveDirectoryEntry(resolved) || resolved; | ||
| 380 | + | ||
| 381 | + // Directory | ||
| 382 | + if (file === undefined) { | ||
| 383 | + file = StringPrototypeEndsWith(path, '/') ? | ||
| 384 | + (resolveDirectoryEntry(resolved) || resolved) : resolveDirectoryEntry(new URL(`${resolved}/`)); | ||
| 385 | + | ||
| 386 | + if (file === resolved) return file; | ||
| 387 | + | ||
| 388 | + if (file === undefined) { | ||
| 389 | + throw new ERR_MODULE_NOT_FOUND( | ||
| 390 | + resolved.pathname, fileURLToPath(base), 'module'); | ||
| 391 | + } | ||
| 386 | 392 | } | |
| 387 | - throw new ERR_MODULE_NOT_FOUND( | ||
| 388 | - resolved.pathname, fileURLToPath(base), 'module'); | ||
| 393 | + | ||
| 394 | + path = file; | ||
| 389 | 395 | } | |
| 390 | 396 | ||
| 391 | 397 | const stats = tryStatSync(StringPrototypeEndsWith(path, '/') ? | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,40 @@ | |||
| 1 | + import * as common from '../common/index.mjs'; | ||
| 2 | + import path from 'path'; | ||
| 3 | + import fs from 'fs/promises'; | ||
| 4 | + import tmpdir from '../common/tmpdir.js'; | ||
| 5 | + import { spawn } from 'child_process'; | ||
| 6 | + import assert from 'assert'; | ||
| 7 | + | ||
| 8 | + tmpdir.refresh(); | ||
| 9 | + const tmpDir = tmpdir.path; | ||
| 10 | + | ||
| 11 | + // Create the following file structure: | ||
| 12 | + // ├── index.mjs | ||
| 13 | + // ├── subfolder | ||
| 14 | + // │ ├── index.mjs | ||
| 15 | + // │ └── node_modules | ||
| 16 | + // │ └── package-a | ||
| 17 | + // │ └── index.mjs | ||
| 18 | + // └── symlink.mjs -> ./subfolder/index.mjs | ||
| 19 | + const entry = path.join(tmpDir, 'index.mjs'); | ||
| 20 | + const symlink = path.join(tmpDir, 'symlink.mjs'); | ||
| 21 | + const real = path.join(tmpDir, 'subfolder', 'index.mjs'); | ||
| 22 | + const packageDir = path.join(tmpDir, 'subfolder', 'node_modules', 'package-a'); | ||
| 23 | + const packageEntry = path.join(packageDir, 'index.mjs'); | ||
| 24 | + try { | ||
| 25 | + await fs.symlink(real, symlink); | ||
| 26 | + } catch (err) { | ||
| 27 | + if (err.code !== 'EPERM') throw err; | ||
| 28 | + common.skip('insufficient privileges for symlinks'); | ||
| 29 | + } | ||
| 30 | + await fs.mkdir(packageDir, { recursive: true }); | ||
| 31 | + await Promise.all([ | ||
| 32 | + fs.writeFile(entry, 'import "./symlink.mjs";'), | ||
| 33 | + fs.writeFile(real, 'export { a } from "package-a/index.mjs"'), | ||
| 34 | + fs.writeFile(packageEntry, 'export const a = 1;'), | ||
| 35 | + ]); | ||
| 36 | + | ||
| 37 | + spawn(process.execPath, ['--experimental-specifier-resolution=node', entry], | ||
| 38 | + { stdio: 'inherit' }).on('exit', common.mustCall((code) => { | ||
| 39 | + assert.strictEqual(code, 0); | ||
| 40 | + })); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments