From cea2664a26da06655017e51f4911ea505a6b685b Mon Sep 17 00:00:00 2001 From: Ryan Manuel Date: Tue, 15 Nov 2022 09:41:42 -0600 Subject: [PATCH] fix: issue with loading typescript and v8 snapshot (#24684) --- .circleci/config.yml | 10 +++++----- packages/packherd-require/src/loader.ts | 9 ++++++++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 727f15cd4177..ece7fad43a0c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -27,7 +27,7 @@ mainBuildFilters: &mainBuildFilters branches: only: - develop - - 'ryanm/fix/migrating-to-11-from-9-typescript' + - 'ryanm/fix/typescript-issue' # usually we don't build Mac app - it takes a long time # but sometimes we want to really confirm we are doing the right thing @@ -36,7 +36,7 @@ macWorkflowFilters: &darwin-workflow-filters when: or: - equal: [ develop, << pipeline.git.branch >> ] - - equal: [ 'ryanm/fix/migrating-to-11-from-9-typescript', << pipeline.git.branch >> ] + - equal: [ 'ryanm/fix/typescript-issue', << pipeline.git.branch >> ] - matches: pattern: "-release$" value: << pipeline.git.branch >> @@ -45,7 +45,7 @@ linuxArm64WorkflowFilters: &linux-arm64-workflow-filters when: or: - equal: [ develop, << pipeline.git.branch >> ] - - equal: [ 'ryanm/fix/migrating-to-11-from-9-typescript', << pipeline.git.branch >> ] + - equal: [ 'ryanm/fix/typescript-issue', << pipeline.git.branch >> ] - matches: pattern: "-release$" value: << pipeline.git.branch >> @@ -63,7 +63,7 @@ windowsWorkflowFilters: &windows-workflow-filters when: or: - equal: [ develop, << pipeline.git.branch >> ] - - equal: [ 'ryanm/fix/migrating-to-11-from-9-typescript', << pipeline.git.branch >> ] + - equal: [ 'ryanm/fix/typescript-issue', << pipeline.git.branch >> ] - matches: pattern: "-release$" value: << pipeline.git.branch >> @@ -130,7 +130,7 @@ commands: - run: name: Check current branch to persist artifacts command: | - if [[ "$CIRCLE_BRANCH" != "develop" && "$CIRCLE_BRANCH" != "ryanm/fix/migrating-to-11-from-9-typescript" ]]; then + if [[ "$CIRCLE_BRANCH" != "develop" && "$CIRCLE_BRANCH" != "ryanm/fix/typescript-issue" ]]; then echo "Not uploading artifacts or posting install comment for this branch." circleci-agent step halt fi diff --git a/packages/packherd-require/src/loader.ts b/packages/packherd-require/src/loader.ts index dfc457207c7c..f395aae9ec0b 100644 --- a/packages/packherd-require/src/loader.ts +++ b/packages/packherd-require/src/loader.ts @@ -898,8 +898,15 @@ export class PackherdModuleLoader { parent = this._createModule(fullPath, parent, moduleUri) } + const originalRequireResolve = require.resolve + require.resolve = Object.assign( - (moduleUri: string, _options?: { paths?: string[] }) => { + (moduleUri: string, options?: { paths?: string[] }) => { + // Handle the case where options populated. The module is expected to be outside of the cypress snapshot so use the original require.resolve. + if (options && options.paths) { + return originalRequireResolve(moduleUri, options) + } + return this.tryResolve(moduleUri, parent).fullPath }, {