| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -66,7 +66,9 @@ function resolve(specifier, parentURL) { | |||
| 66 | 66 | throw e; | |
| 67 | 67 | } | |
| 68 | 68 | ||
| 69 | - if (!preserveSymlinks) { | ||
| 69 | + const isMain = parentURL === undefined; | ||
| 70 | + | ||
| 71 | + if (!preserveSymlinks || isMain) { | ||
| 70 | 72 | const real = realpathSync(getPathFromURL(url), { | |
| 71 | 73 | [internalFS.realpathCacheKey]: realpathCache | |
| 72 | 74 | }); | |
@@ -80,7 +82,6 @@ function resolve(specifier, parentURL) { | |||
| 80 | 82 | ||
| 81 | 83 | let format = extensionFormatMap[ext]; | |
| 82 | 84 | if (!format) { | |
| 83 | - const isMain = parentURL === undefined; | ||
| 84 | 85 | if (isMain) | |
| 85 | 86 | format = 'cjs'; | |
| 86 | 87 | else | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,25 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + const common = require('../common'); | ||
| 4 | + const assert = require('assert'); | ||
| 5 | + const path = require('path'); | ||
| 6 | + const { spawn } = require('child_process'); | ||
| 7 | + const tmpdir = require('../common/tmpdir'); | ||
| 8 | + const fs = require('fs'); | ||
| 9 | + tmpdir.refresh(); | ||
| 10 | + | ||
| 11 | + const realPath = path.resolve(__dirname, '../fixtures/es-modules/symlink.mjs'); | ||
| 12 | + const symlinkPath = path.resolve(tmpdir.path, 'symlink.js'); | ||
| 13 | + | ||
| 14 | + try { | ||
| 15 | + fs.symlinkSync(realPath, symlinkPath); | ||
| 16 | + } catch (err) { | ||
| 17 | + if (err.code !== 'EPERM') throw err; | ||
| 18 | + common.skip('insufficient privileges for symlinks'); | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + spawn(process.execPath, | ||
| 22 | + ['--experimental-modules', '--preserve-symlinks', symlinkPath], | ||
| 23 | + { stdio: 'inherit' }).on('exit', (code) => { | ||
| 24 | + assert.strictEqual(code, 0); | ||
| 25 | + }); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1 @@ | |||
| 1 | + export var symlinked = true; | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments