| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 74a22cd commit d7d4f0e
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -140,6 +140,8 @@ class PackageMap { | |||
| 140 | 140 | * @returns {string|null} | |
| 141 | 141 | */ | |
| 142 | 142 | #getKeyForPath(filePath) { | |
| 143 | + filePath = pathResolve(filePath); | ||
| 144 | + | ||
| 143 | 145 | const cached = this.#pathToKeyCache.get(filePath); | |
| 144 | 146 | if (cached !== undefined) { return cached; } | |
| 145 | 147 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -300,6 +300,22 @@ describe('CJS: --experimental-package-map', { concurrency: !process.env.TEST_PAR | |||
| 300 | 300 | describe('longest path wins', () => { | |
| 301 | 301 | const longestPathMap = fixtures.path('package-map/package-map-longest-path.json'); | |
| 302 | 302 | ||
| 303 | + it('resolves from createRequire() paths with mixed separators', () => { | ||
| 304 | + const { status, stdout, stderr } = spawnSync(process.execPath, [ | ||
| 305 | + '--no-warnings', | ||
| 306 | + '--experimental-package-map', longestPathMap, | ||
| 307 | + '-e', | ||
| 308 | + `const { createRequire } = require('node:module'); const req = createRequire(process.cwd() + '/node_modules/inner/index.js'); const dep = req('dep-a'); console.log(dep.default);`, | ||
| 309 | + ], { | ||
| 310 | + cwd: fixtures.path('package-map/root'), | ||
| 311 | + encoding: 'utf8', | ||
| 312 | + }); | ||
| 313 | + | ||
| 314 | + assert.strictEqual(stderr, ''); | ||
| 315 | + assert.match(stdout, /dep-a-value/); | ||
| 316 | + assert.strictEqual(status, 0, stderr); | ||
| 317 | + }); | ||
| 318 | + | ||
| 303 | 319 | it('resolves nested package using its own dependencies, not the parent', () => { | |
| 304 | 320 | // Inner lives at ./root/node_modules/inner which is inside root's | |
| 305 | 321 | // path (./root). The longest matching path should win, so code in | |
| Back | FazBrowse Home | New Git URL |
0 commit comments