From 2269cdd976efbcda5b5a5c8fec377334cbcc7c13 Mon Sep 17 00:00:00 2001 From: Josh Wooding <12938082+joshwooding@users.noreply.github.com> Date: Thu, 15 Aug 2024 15:05:36 +0100 Subject: [PATCH] Fix --- .babelrc | 7 +++++++ cypress.config.ts | 14 +++++++++++--- rspack.config.ts | 4 ++++ yarn.lock | 8 ++++++++ 4 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 .babelrc diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000000..9d461d0868 --- /dev/null +++ b/.babelrc @@ -0,0 +1,7 @@ +{ + "env": { + "test": { + "plugins": ["istanbul"] + } + } +} diff --git a/cypress.config.ts b/cypress.config.ts index 14256fc75b..a0cbd37913 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -2,6 +2,8 @@ import installCoverageTask from "@cypress/code-coverage/task"; import { defineConfig } from "cypress"; import { devServer } from "cypress-rspack-dev-server"; +import { version as reactVersion } from "react"; +import { merge } from "webpack-merge"; export default defineConfig({ viewportWidth: 1280, @@ -25,12 +27,18 @@ export default defineConfig({ return devServer({ ...devServerConfig, framework: "react", - rspackConfig: { - ...require("./rspack.config").default, + rspackConfig: merge(require("./rspack.config").default, { experiments: { lazyCompilation: !devServerConfig.cypressConfig.isTextTerminal, }, - }, + resolve: { + alias: { + "cypress/react18": reactVersion.startsWith("18") + ? "cypress/react18" + : "cypress/react", + }, + }, + }), }); }, specPattern: "packages/**/src/**/*.cy.{js,ts,jsx,tsx}", diff --git a/rspack.config.ts b/rspack.config.ts index f4319bc699..03c23ee475 100644 --- a/rspack.config.ts +++ b/rspack.config.ts @@ -15,6 +15,10 @@ export default defineConfig({ test: /\.css$/, use: ["style-loader", "css-loader", "postcss-loader"], }, + { + test: /packages\/.*\/src\/.*\.[tj]sx?$/, + use: ["babel-loader"], + }, { test: /\.(j|t)s$/, exclude: [/[\\/]node_modules[\\/]/], diff --git a/yarn.lock b/yarn.lock index b1ce0b9faf..16449ac7b7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5949,6 +5949,7 @@ __metadata: sass: "npm:^1.52.3" storybook: "npm:^8.2.4" stylelint: "npm:^16.0.0" + swc-plugin-coverage-instrument: "npm:^0.0.24" typescript: "npm:4.6.4" vite: "npm:^4.4.9" vite-plugin-istanbul: "npm:^6.0.0" @@ -27582,6 +27583,13 @@ __metadata: languageName: node linkType: hard +"swc-plugin-coverage-instrument@npm:^0.0.24": + version: 0.0.24 + resolution: "swc-plugin-coverage-instrument@npm:0.0.24" + checksum: 10/7eeb04408430d79ee8ec7a628955e7680d62c89f49a002fa482e5bed73c0d01fa8d262303ff93a6e3efdae7667b1eaa984a4b07aa32b56f48d7e154a3645de97 + languageName: node + linkType: hard + "swr@npm:^2.1.2": version: 2.1.5 resolution: "swr@npm:2.1.5"