From fbf3d91fc988de69d89513b088ef5d9aabf83fae Mon Sep 17 00:00:00 2001 From: Sam Tsai Date: Wed, 25 Oct 2023 09:44:24 -0400 Subject: [PATCH] fix(cypress): compatibility with esm bundlers Webpack does support `require.resolve` but other bundlers like esbuild does not. We improve the compatibility by using `require.resolve` only if it is available. --- packages/cypress/src/support.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/cypress/src/support.ts b/packages/cypress/src/support.ts index fbd41be..34e5ee7 100644 --- a/packages/cypress/src/support.ts +++ b/packages/cypress/src/support.ts @@ -31,7 +31,7 @@ declare global { function injectArgos() { const fileName = - typeof require?.resolve === "function" + typeof require.resolve === "function" ? require.resolve("@argos-ci/browser/global.js") : "node_modules/@argos-ci/browser/dist/global.js"; cy.readFile(fileName).then((source) => @@ -43,7 +43,7 @@ function injectArgos() { function readArgosCypressVersion() { const fileName = - typeof require?.resolve === "function" + typeof require.resolve === "function" ? require.resolve("@argos-ci/cypress/package.json") : "node_modules/@argos-ci/cypress/package.json"; return cy.readFile(fileName).then((source) => {