From c1a0442747754497866b095267228c5edb99b38a Mon Sep 17 00:00:00 2001 From: erenken Date: Tue, 12 Sep 2023 17:40:15 -0400 Subject: [PATCH] feat(nextjs): can set compiler when setting up `nxComponentTestingPreset` Currently nextjs only uses the *swa* compiler To use @cypress/code-coverage you need to use *babel*, you can now select which compiler to use. closed #19131 --- packages/cypress/plugins/cypress-preset.ts | 1 + packages/next/plugins/component-testing.ts | 2 +- packages/react/plugins/component-testing/index.ts | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/cypress/plugins/cypress-preset.ts b/packages/cypress/plugins/cypress-preset.ts index 6e3ed1a87e141..a3f58e1d7149a 100644 --- a/packages/cypress/plugins/cypress-preset.ts +++ b/packages/cypress/plugins/cypress-preset.ts @@ -18,6 +18,7 @@ export interface NxComponentTestingOptions { */ ctTargetName?: string; bundler?: 'vite' | 'webpack'; + compiler?: 'swc' | 'babel'; } export function nxBaseCypressPreset( diff --git a/packages/next/plugins/component-testing.ts b/packages/next/plugins/component-testing.ts index aa5284f08f4fe..d1461ad474981 100644 --- a/packages/next/plugins/component-testing.ts +++ b/packages/next/plugins/component-testing.ts @@ -97,7 +97,7 @@ Able to find CT project, ${!!ctProjectConfig}.`); assets: buildAssets, outputPath: buildOuputPath, outputFileName: 'main.js', - compiler: 'swc', + compiler: options?.compiler || 'swc', tsConfig: join( ctExecutorContext.root, ctProjectConfig.root, diff --git a/packages/react/plugins/component-testing/index.ts b/packages/react/plugins/component-testing/index.ts index 3f27caef7421c..0ff603b314c16 100644 --- a/packages/react/plugins/component-testing/index.ts +++ b/packages/react/plugins/component-testing/index.ts @@ -156,7 +156,7 @@ export function nxComponentTestingPreset( const { buildBaseWebpackConfig } = require('./webpack-fallback'); webpackConfig = buildBaseWebpackConfig({ tsConfigPath: findTsConfig(normalizedProjectRootPath), - compiler: 'babel', + compiler: options?.compiler || 'babel', }); }