From dc714570f04f43aabb97b34b30a2ae7a58c941c5 Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Mon, 31 Jul 2023 09:22:55 -0700 Subject: [PATCH 1/6] feat(cypress): Vite 5 compatibility --- packages/cypress/src/plugins/preprocessor-vite.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cypress/src/plugins/preprocessor-vite.ts b/packages/cypress/src/plugins/preprocessor-vite.ts index f5d9fa5ca2ed4..529f0db4f634b 100644 --- a/packages/cypress/src/plugins/preprocessor-vite.ts +++ b/packages/cypress/src/plugins/preprocessor-vite.ts @@ -74,7 +74,7 @@ function vitePreprocessor(userConfigPath?: string): CypressPreprocessor { cache.set(filePath, outputPath); - const { build } = require('vite'); + const { build } = await import('vite'); const watcher = (await build({ configFile: userConfigPath, From 502aebd91370dd5bf26a2e7c8b49bc5d86b47799 Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Tue, 8 Aug 2023 09:24:55 -0700 Subject: [PATCH 2/6] Update packages/cypress/src/plugins/preprocessor-vite.ts Co-authored-by: Caleb Ukle --- packages/cypress/src/plugins/preprocessor-vite.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/cypress/src/plugins/preprocessor-vite.ts b/packages/cypress/src/plugins/preprocessor-vite.ts index 529f0db4f634b..1de62248a258d 100644 --- a/packages/cypress/src/plugins/preprocessor-vite.ts +++ b/packages/cypress/src/plugins/preprocessor-vite.ts @@ -74,7 +74,9 @@ function vitePreprocessor(userConfigPath?: string): CypressPreprocessor { cache.set(filePath, outputPath); - const { build } = await import('vite'); + const { build } = await (Function( + 'return import("vite")' + )() as Promise); const watcher = (await build({ configFile: userConfigPath, From 0164d89ae8ce940332d92b418287f72fc66f501a Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Tue, 8 Aug 2023 09:27:13 -0700 Subject: [PATCH 3/6] Update packages/cypress/src/plugins/preprocessor-vite.ts --- packages/cypress/src/plugins/preprocessor-vite.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cypress/src/plugins/preprocessor-vite.ts b/packages/cypress/src/plugins/preprocessor-vite.ts index 1de62248a258d..0bee34924ce47 100644 --- a/packages/cypress/src/plugins/preprocessor-vite.ts +++ b/packages/cypress/src/plugins/preprocessor-vite.ts @@ -76,7 +76,7 @@ function vitePreprocessor(userConfigPath?: string): CypressPreprocessor { const { build } = await (Function( 'return import("vite")' - )() as Promise); + )() as Promise); const watcher = (await build({ configFile: userConfigPath, From 8476f7b825d8e18d4d764f7ea78b926a35010f83 Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Tue, 8 Aug 2023 09:27:56 -0700 Subject: [PATCH 4/6] Update index.ts --- packages/react/plugins/component-testing/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react/plugins/component-testing/index.ts b/packages/react/plugins/component-testing/index.ts index 82ee45f60fd62..255b32da45b48 100644 --- a/packages/react/plugins/component-testing/index.ts +++ b/packages/react/plugins/component-testing/index.ts @@ -84,7 +84,7 @@ export function nxComponentTestingPreset( const viteConfigPath = findViteConfig(normalizedProjectRootPath); const { mergeConfig, loadConfigFromFile, searchForWorkspaceRoot } = - await import('vite'); + await (Function('return import("vite")')() as Promise); const resolved = await loadConfigFromFile( { From d845c7c34750b66fd81a0e36a496ee115d3baa15 Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Tue, 8 Aug 2023 09:28:31 -0700 Subject: [PATCH 5/6] Update packages/cypress/src/plugins/preprocessor-vite.ts --- packages/cypress/src/plugins/preprocessor-vite.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/cypress/src/plugins/preprocessor-vite.ts b/packages/cypress/src/plugins/preprocessor-vite.ts index 0bee34924ce47..849357b36aa04 100644 --- a/packages/cypress/src/plugins/preprocessor-vite.ts +++ b/packages/cypress/src/plugins/preprocessor-vite.ts @@ -74,9 +74,7 @@ function vitePreprocessor(userConfigPath?: string): CypressPreprocessor { cache.set(filePath, outputPath); - const { build } = await (Function( - 'return import("vite")' - )() as Promise); + const { build } = await (Function('return import("vite")')() as Promise); const watcher = (await build({ configFile: userConfigPath, From 901d8ebb4504eebb6a9a446f9a06199307902317 Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Tue, 8 Aug 2023 09:46:24 -0700 Subject: [PATCH 6/6] format --- packages/cypress/src/plugins/preprocessor-vite.ts | 4 +++- packages/react/plugins/component-testing/index.ts | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/cypress/src/plugins/preprocessor-vite.ts b/packages/cypress/src/plugins/preprocessor-vite.ts index 849357b36aa04..4cacbfcfc6780 100644 --- a/packages/cypress/src/plugins/preprocessor-vite.ts +++ b/packages/cypress/src/plugins/preprocessor-vite.ts @@ -74,7 +74,9 @@ function vitePreprocessor(userConfigPath?: string): CypressPreprocessor { cache.set(filePath, outputPath); - const { build } = await (Function('return import("vite")')() as Promise); + const { build } = await (Function('return import("vite")')() as Promise< + typeof import('vite') + >); const watcher = (await build({ configFile: userConfigPath, diff --git a/packages/react/plugins/component-testing/index.ts b/packages/react/plugins/component-testing/index.ts index 255b32da45b48..a58b0fdd9f614 100644 --- a/packages/react/plugins/component-testing/index.ts +++ b/packages/react/plugins/component-testing/index.ts @@ -84,7 +84,9 @@ export function nxComponentTestingPreset( const viteConfigPath = findViteConfig(normalizedProjectRootPath); const { mergeConfig, loadConfigFromFile, searchForWorkspaceRoot } = - await (Function('return import("vite")')() as Promise); + await (Function('return import("vite")')() as Promise< + typeof import('vite') + >); const resolved = await loadConfigFromFile( {