-
Notifications
You must be signed in to change notification settings - Fork 631
[heft] Add options to only resolve symlinks that are within node_modules #5011
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
dmichon-msft
merged 9 commits into
microsoft:main
from
dmichon-msft:real-node-module-path
Nov 21, 2024
Merged
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
fcfe2f4
[node-core-library] Add RealNodeModulePathResolver
dmichon-msft bd749e3
[heft-typescript] Add onlyResolveSymlinksInNodeModules option
dmichon-msft 7583f9c
[heft-jest] Add node module symlink resolver
dmichon-msft ff696ae
Test resolver
dmichon-msft 99caf58
Use features in local-node-rig
dmichon-msft de24c48
Fix duplicate types
dmichon-msft 66ee641
Disable CI fail-fast
dmichon-msft db5acc2
Pay extra lstat
dmichon-msft ae72c34
Fix unit tests
dmichon-msft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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; | ||
dmichon-msft marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
// @public | ||
export const realNodeModulePath: (input: string) => string; | ||
|
||
// (No @packageDocumentation comment for this package) | ||
|
||
``` |
This file contains hidden or 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') { | ||
dmichon-msft marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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 hidden or 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'); | ||
dmichon-msft marked this conversation as resolved.
Show resolved
Hide resolved
|
||
export = resolver; |
This file contains hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.