Skip to content

[webpack-resolve] Fix bug caused by mutating request #4902

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
merged 1 commit into from
Aug 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@rushstack/webpack-workspace-resolve-plugin",
"comment": "Fix bug caused by mutating resolver request object.",
"type": "patch"
}
],
"packageName": "@rushstack/webpack-workspace-resolve-plugin"
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,18 @@ export class KnownDescriptionFilePlugin {
// Store the resolver context since a WeakMap lookup is cheaper than walking the tree again
contextForPackage.set(descriptionFileData, match.value);

// Since we don't allow any alternative processing of request, we can mutate it
// instead of cloning it.
request.descriptionFileRoot = descriptionFileRoot;
request.descriptionFilePath = descriptionFilePath;
request.descriptionFileData = descriptionFileData;
request.relativePath = relativePath;
const obj: ResolveRequest = {
...request,
descriptionFileRoot,
descriptionFilePath,
descriptionFileData,
relativePath
};

// Delegate to the resolver step at `target`.
resolver.doResolve(
target,
request,
obj,
'using description file: ' + descriptionFilePath + ' (relative path: ' + relativePath + ')',
resolveContext,
(e: Error | undefined, result: ResolveRequest | undefined) => {
Expand Down
Loading