From b68035522a4d8e5e335063a2b960d82c20c87823 Mon Sep 17 00:00:00 2001 From: David Michon Date: Fri, 23 Aug 2024 23:41:32 +0000 Subject: [PATCH] [webpack-resolve] Fix bug caused by mutating request --- .../resolver-new_2024-08-23-23-41.json | 10 ++++++++++ .../src/KnownDescriptionFilePlugin.ts | 15 ++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) create mode 100644 common/changes/@rushstack/webpack-workspace-resolve-plugin/resolver-new_2024-08-23-23-41.json diff --git a/common/changes/@rushstack/webpack-workspace-resolve-plugin/resolver-new_2024-08-23-23-41.json b/common/changes/@rushstack/webpack-workspace-resolve-plugin/resolver-new_2024-08-23-23-41.json new file mode 100644 index 00000000000..2c26bb608f8 --- /dev/null +++ b/common/changes/@rushstack/webpack-workspace-resolve-plugin/resolver-new_2024-08-23-23-41.json @@ -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" +} \ No newline at end of file diff --git a/webpack/webpack-workspace-resolve-plugin/src/KnownDescriptionFilePlugin.ts b/webpack/webpack-workspace-resolve-plugin/src/KnownDescriptionFilePlugin.ts index 769721c181f..cf4025b3cb1 100644 --- a/webpack/webpack-workspace-resolve-plugin/src/KnownDescriptionFilePlugin.ts +++ b/webpack/webpack-workspace-resolve-plugin/src/KnownDescriptionFilePlugin.ts @@ -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) => {