-
Notifications
You must be signed in to change notification settings - Fork 604
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[heft] Add options to only resolve symlinks that are within node_modu…
…les (#5011) * [node-core-library] Add RealNodeModulePathResolver * [heft-typescript] Add onlyResolveSymlinksInNodeModules option * [heft-jest] Add node module symlink resolver * Test resolver * Use features in local-node-rig * Fix duplicate types * Disable CI fail-fast * Pay extra lstat * Fix unit tests --------- Co-authored-by: David Michon <[email protected]>
- Loading branch information
1 parent
b8f1b2b
commit 6f5f09d
Showing
21 changed files
with
649 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ on: | |
jobs: | ||
build: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- NodeVersion: 18.18.x | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,5 +49,7 @@ | |
// "excludeGlobs": [ | ||
// "some/path/*.css" | ||
// ] | ||
} | ||
}, | ||
|
||
"onlyResolveSymlinksInNodeModules": true | ||
} |
10 changes: 10 additions & 0 deletions
10
common/changes/@rushstack/heft-jest-plugin/fast-realpath_2024-11-20-05-21.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"changes": [ | ||
{ | ||
"packageName": "@rushstack/heft-jest-plugin", | ||
"comment": "Add a custom resolver that only resolves symlinks that are within node_modules.", | ||
"type": "minor" | ||
} | ||
], | ||
"packageName": "@rushstack/heft-jest-plugin" | ||
} |
10 changes: 10 additions & 0 deletions
10
common/changes/@rushstack/heft-typescript-plugin/fast-realpath_2024-11-20-04-20.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"changes": [ | ||
{ | ||
"packageName": "@rushstack/heft-typescript-plugin", | ||
"comment": "Add \"onlyResolveSymlinksInNodeModules\" option to improve performance for typical repository layouts.", | ||
"type": "minor" | ||
} | ||
], | ||
"packageName": "@rushstack/heft-typescript-plugin" | ||
} |
10 changes: 10 additions & 0 deletions
10
common/changes/@rushstack/node-core-library/fast-realpath_2024-11-20-19-57.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"changes": [ | ||
{ | ||
"packageName": "@rushstack/node-core-library", | ||
"comment": "Add `RealNodeModulePathResolver` class to get equivalent behavior to `realpath` with fewer system calls (and therefore higher performance) in the typical scenario where the only symlinks in the repository are inside of `node_modules` folders and are links to package folders.", | ||
"type": "minor" | ||
} | ||
], | ||
"packageName": "@rushstack/node-core-library" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
## API Report File for "@rushstack/real-node-module-path" | ||
|
||
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). | ||
```ts | ||
|
||
/// <reference types="node" /> | ||
|
||
// @public | ||
export function clearCache(): void; | ||
|
||
// @public | ||
export const realNodeModulePath: (input: string) => string; | ||
|
||
// (No @packageDocumentation comment for this package) | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. | ||
// See LICENSE in the project root for license information. | ||
|
||
import * as path from 'node:path'; | ||
import { RealNodeModulePathResolver } from '@rushstack/node-core-library/lib/RealNodeModulePath'; | ||
|
||
const jestResolvePackageFolder: string = path.dirname(require.resolve('jest-resolve/package.json')); | ||
const jestResolveFileWalkersPath: string = path.resolve(jestResolvePackageFolder, './build/fileWalkers.js'); | ||
|
||
const jestUtilPackageFolder: string = path.dirname( | ||
require.resolve('jest-util/package.json', { paths: [jestResolvePackageFolder] }) | ||
); | ||
const jestUtilTryRealpathPath: string = path.resolve(jestUtilPackageFolder, './build/tryRealpath.js'); | ||
|
||
const { realNodeModulePath }: RealNodeModulePathResolver = new RealNodeModulePathResolver(); | ||
|
||
const fileWalkersModule: { | ||
realpathSync: (filePath: string) => string; | ||
} = require(jestResolveFileWalkersPath); | ||
fileWalkersModule.realpathSync = realNodeModulePath; | ||
|
||
const tryRealpathModule: { | ||
default: (filePath: string) => string; | ||
} = require(jestUtilTryRealpathPath); | ||
tryRealpathModule.default = (input: string): string => { | ||
try { | ||
return realNodeModulePath(input); | ||
} catch (error) { | ||
// Not using the helper from FileSystem here because this code loads in every Jest worker process | ||
// and FileSystem has a lot of extra dependencies | ||
if (error.code !== 'ENOENT' && error.code !== 'EISDIR') { | ||
throw error; | ||
} | ||
} | ||
return input; | ||
}; |
7 changes: 7 additions & 0 deletions
7
heft-plugins/heft-jest-plugin/src/exports/jest-node-modules-symlink-resolver.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. | ||
// See LICENSE in the project root for license information. | ||
|
||
import '../JestRealPathPatch'; | ||
// Using this syntax because HeftJestResolver uses `export =` syntax. | ||
import resolver = require('../HeftJestResolver'); | ||
export = resolver; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.