From ce898c25e26b42b9d6fc342862a467aa9ff0f40a Mon Sep 17 00:00:00 2001 From: Valentin Palkovic Date: Wed, 22 Jan 2025 15:33:17 +0100 Subject: [PATCH] fix: Add styled-jsx/style alias to next-mocks plugin --- package.json | 3 ++- pnpm-lock.yaml | 3 +++ src/plugins/next-mocks/plugin.ts | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index c14c248..cfdbcd8 100644 --- a/package.json +++ b/package.json @@ -87,7 +87,8 @@ "image-size": "^1.1.1", "magic-string": "^0.30.11", "module-alias": "^2.2.3", - "ts-dedent": "^2.2.0" + "ts-dedent": "^2.2.0", + "styled-jsx": "^5.1.6" }, "optionalDependencies": { "sharp": "^0.33.4" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d74f4b7..7716bc1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -23,6 +23,9 @@ importers: module-alias: specifier: ^2.2.3 version: 2.2.3 + styled-jsx: + specifier: ^5.1.6 + version: 5.1.6(react@18.3.1) ts-dedent: specifier: ^2.2.0 version: 2.2.0 diff --git a/src/plugins/next-mocks/plugin.ts b/src/plugins/next-mocks/plugin.ts index 68fe303..082b96d 100644 --- a/src/plugins/next-mocks/plugin.ts +++ b/src/plugins/next-mocks/plugin.ts @@ -1,4 +1,5 @@ import { createRequire } from "node:module"; +import path, { resolve } from "node:path"; import type { Plugin } from "vite"; import { VITEST_PLUGIN_NAME, getExecutionEnvironment } from "../../utils"; @@ -39,6 +40,9 @@ export const getAlias = (env: Env) => ({ "@opentelemetry/api": require.resolve( "next/dist/compiled/@opentelemetry/api", ), + "styled-jsx/style.js": resolve("styled-jsx/style"), + "styled-jsx/style": require.resolve("styled-jsx/style"), + "styled-jsx": path.dirname(require.resolve("styled-jsx/package.json")), "next/dynamic": getEntryPoint("dynamic", env), });