diff --git a/packages/zero-next-plugin/src/index.ts b/packages/zero-next-plugin/src/index.ts index 3e4f9c3ac462bd..661e0d0b2fe045 100644 --- a/packages/zero-next-plugin/src/index.ts +++ b/packages/zero-next-plugin/src/index.ts @@ -3,6 +3,7 @@ import type { NextConfig } from 'next'; import { findPagesDir } from 'next/dist/lib/find-pages-dir'; import { webpack as zeroWebpackPlugin, + extendTheme, type PluginOptions as BaseZeroPluginConfig, } from '@mui/zero-unplugin'; @@ -81,3 +82,5 @@ export function withZeroPlugin(nextConfig: NextConfig, zeroConfig: ZeroPluginCon webpack, }; } + +export { extendTheme }; diff --git a/packages/zero-runtime/.gitignore b/packages/zero-runtime/.gitignore index f43d90c8429d5e..606fdd2c759d2a 100644 --- a/packages/zero-runtime/.gitignore +++ b/packages/zero-runtime/.gitignore @@ -1,2 +1,3 @@ /processors/ /utils/ +/extendTheme/ diff --git a/packages/zero-runtime/README.md b/packages/zero-runtime/README.md index f32aab05d20d91..514eb20d7c4fae 100644 --- a/packages/zero-runtime/README.md +++ b/packages/zero-runtime/README.md @@ -319,7 +319,7 @@ const { withZeroPlugin, extendTheme } = require('@mui/zero-next-plugin'); module.exports = withZeroPlugin( { - // ...other nextConfig + // ...nextConfig }, { theme: extendTheme({ diff --git a/packages/zero-runtime/package.json b/packages/zero-runtime/package.json index a0d78db0cb4466..be16dfe490c219 100644 --- a/packages/zero-runtime/package.json +++ b/packages/zero-runtime/package.json @@ -68,7 +68,8 @@ "utils", "package.json", "styles.css", - "theme" + "theme", + "extendTheme" ], "exports": { ".": { @@ -83,6 +84,15 @@ "require": "./theme/index.js", "default": "./theme/index.js" }, + "./extendTheme": { + "types": "./extendTheme/index.d.ts", + "import": { + "default": "./extendTheme/index.mjs", + "types": "./extendTheme/index.d.mts" + }, + "require": "./extendTheme/index.js", + "default": "./extendTheme/index.js" + }, "./styles.css": { "default": "./styles.css" }, diff --git a/packages/zero-runtime/src/extendTheme.ts b/packages/zero-runtime/src/extendTheme.ts index abfee8b62139ab..7af8566e32e99a 100644 --- a/packages/zero-runtime/src/extendTheme.ts +++ b/packages/zero-runtime/src/extendTheme.ts @@ -86,7 +86,7 @@ export type Theme = ExtendTheme; /** * A utility to tell zero-runtime to generate CSS variables for the theme. */ -export default function extendTheme< +export function extendTheme< Options extends { colorScheme: string; tokens: Record; diff --git a/packages/zero-runtime/src/index.ts b/packages/zero-runtime/src/index.ts index fb1923bf0e3803..52c2a5e4bc993f 100644 --- a/packages/zero-runtime/src/index.ts +++ b/packages/zero-runtime/src/index.ts @@ -4,5 +4,3 @@ export { default as keyframes } from './keyframes'; export { generateAtomics, atomics } from './generateAtomics'; export { default as css } from './css'; export { default as createUseThemeProps } from './createUseThemeProps'; -export { default as extendTheme } from './extendTheme'; -export type { Theme, ExtendTheme } from './extendTheme'; diff --git a/packages/zero-runtime/tsup.config.ts b/packages/zero-runtime/tsup.config.ts index 635ac6fa9b2f64..445e63376e2435 100644 --- a/packages/zero-runtime/tsup.config.ts +++ b/packages/zero-runtime/tsup.config.ts @@ -19,6 +19,13 @@ export default defineConfig([ ...baseConfig, entry: ['./src/index.ts', './src/theme.ts'], }, + { + ...baseConfig, + entry: { + index: './src/extendTheme.ts', + }, + outDir: 'extendTheme', + }, { ...baseConfig, entry: processors.map((fn) => `./src/processors/${fn}.ts`), diff --git a/packages/zero-unplugin/src/index.ts b/packages/zero-unplugin/src/index.ts index ab21cb71d0f4d2..79f1f266e6154f 100644 --- a/packages/zero-unplugin/src/index.ts +++ b/packages/zero-unplugin/src/index.ts @@ -19,7 +19,8 @@ import { generateTokenCss, generateThemeTokens, } from '@mui/zero-runtime/utils'; -import type { Theme as BaseTheme } from '@mui/zero-runtime'; +import type { Theme as BaseTheme } from '@mui/zero-runtime/extendTheme'; +import { extendTheme } from '@mui/zero-runtime/extendTheme'; type NextMeta = { type: 'next'; @@ -341,3 +342,5 @@ export const webpack = plugin.webpack as unknown as UnpluginFactoryOutput< PluginOptions, WebpackPluginInstance >; + +export { extendTheme }; diff --git a/packages/zero-vite-plugin/src/index.ts b/packages/zero-vite-plugin/src/index.ts index f494274b65a4d4..f13dc6e73278e8 100644 --- a/packages/zero-vite-plugin/src/index.ts +++ b/packages/zero-vite-plugin/src/index.ts @@ -4,7 +4,7 @@ import { generateTokenCss, generateThemeTokens, } from '@mui/zero-runtime/utils'; -import type { Theme } from '@mui/zero-runtime'; +import type { Theme } from '@mui/zero-runtime/extendTheme'; import { transformAsync } from '@babel/core'; import baseZeroVitePlugin, { type VitePluginOptions } from './zero-vite-plugin';