From 8141ad30afc711506b0ed461e10c7b020730c17f Mon Sep 17 00:00:00 2001 From: Brijesh Bittu Date: Wed, 31 Jan 2024 12:32:04 +0530 Subject: [PATCH] Final fixes --- apps/zero-runtime-vite-app/src/App.tsx | 8 ++------ apps/zero-runtime-vite-app/vite.config.ts | 8 ++++++++ packages/zero-runtime/package.json | 2 +- .../src/processors/generateAtomics.ts | 1 - packages/zero-runtime/src/processors/styled.ts | 1 + .../src/utils/sxObjectExtractor.ts | 10 +++++----- packages/zero-unplugin/src/index.ts | 3 --- packages/zero-vite-plugin/src/index.ts | 4 ++-- .../zero-vite-plugin/src/zero-vite-plugin.ts | 5 ----- pnpm-lock.yaml | 18 +++++++++--------- 10 files changed, 28 insertions(+), 32 deletions(-) diff --git a/apps/zero-runtime-vite-app/src/App.tsx b/apps/zero-runtime-vite-app/src/App.tsx index 68ea0c65703846..07b4e0f494bf22 100644 --- a/apps/zero-runtime-vite-app/src/App.tsx +++ b/apps/zero-runtime-vite-app/src/App.tsx @@ -1,5 +1,5 @@ import * as React from 'react'; -import { styled, generateAtomics, css } from '@mui/zero-runtime'; +import { styled, generateAtomics } from '@mui/zero-runtime'; import type { Breakpoint } from '@mui/system'; import { Button, bounceAnim } from 'local-ui-lib'; import Slider from './Slider/ZeroSlider'; @@ -58,11 +58,7 @@ export function App({ isRed }: AppProps) { const [isHorizontal, setIsHorizontal] = React.useState(true); return ( -
+
diff --git a/apps/zero-runtime-vite-app/vite.config.ts b/apps/zero-runtime-vite-app/vite.config.ts index 59341474b75dc4..8d26341e9f4769 100644 --- a/apps/zero-runtime-vite-app/vite.config.ts +++ b/apps/zero-runtime-vite-app/vite.config.ts @@ -22,4 +22,12 @@ export default defineConfig({ reactPlugin(), splitVendorChunkPlugin(), ], + resolve: { + alias: [ + { + find: /^@mui\/system\/(.*)/, + replacement: '@mui/system/esm/$1', + }, + ], + }, }); diff --git a/packages/zero-runtime/package.json b/packages/zero-runtime/package.json index ca3aeeabcd68a0..04d3c28a6290dd 100644 --- a/packages/zero-runtime/package.json +++ b/packages/zero-runtime/package.json @@ -47,7 +47,7 @@ "publishConfig": { "access": "public" }, - "linaria": { + "wyw-in-js": { "tags": { "styled": "./exports/styled.js", "default": "./exports/styled.js", diff --git a/packages/zero-runtime/src/processors/generateAtomics.ts b/packages/zero-runtime/src/processors/generateAtomics.ts index 4a9efab06fdea4..1780a386f2f02e 100644 --- a/packages/zero-runtime/src/processors/generateAtomics.ts +++ b/packages/zero-runtime/src/processors/generateAtomics.ts @@ -95,7 +95,6 @@ export class GenerateAtomicsProcessor extends BaseProcessor { } doRuntimeReplacement(): void { - console.log(this.runtimeConfig); if (!this.runtimeConfig) { this.doEvaltimeReplacement(); return; diff --git a/packages/zero-runtime/src/processors/styled.ts b/packages/zero-runtime/src/processors/styled.ts index aa0cc3e06dbf0e..b2fbc941a8fefa 100644 --- a/packages/zero-runtime/src/processors/styled.ts +++ b/packages/zero-runtime/src/processors/styled.ts @@ -15,6 +15,7 @@ import { type Replacements, type Rules, } from '@wyw-in-js/shared'; +import { CSSObject } from '@emotion/serialize'; import type { PluginCustomOptions } from '../utils/cssFnValueToVariable'; import { cssFnValueToVariable } from '../utils/cssFnValueToVariable'; import { processCssObject } from '../utils/processCssObject'; diff --git a/packages/zero-runtime/src/utils/sxObjectExtractor.ts b/packages/zero-runtime/src/utils/sxObjectExtractor.ts index 58bf62c50d575e..c5dc53b8b078c8 100644 --- a/packages/zero-runtime/src/utils/sxObjectExtractor.ts +++ b/packages/zero-runtime/src/utils/sxObjectExtractor.ts @@ -26,13 +26,13 @@ function validateObjectKey( throw keyPath.buildCodeFrameError('Expressions in css object keys are not supported.'); } if ( - !identifiers.every((item: any) => { + !identifiers.every((item) => { const binding = item.scope.getBinding(item.node.name); if (!binding) { return false; } if ( - binding.path.findParent((parent: any) => parent === parentCall) || + binding.path.findParent((parent) => parent === parentCall) || binding.path.scope === rootScope ) { return true; @@ -72,7 +72,7 @@ function traverseObjectExpression( const identifiers = findIdentifiers([value], 'reference'); const themeIdentifiers: NodePath[] = []; const localIdentifiers: NodePath[] = []; - identifiers.forEach((id: any) => { + identifiers.forEach((id) => { if (!id.isIdentifier()) { return; } @@ -80,7 +80,7 @@ function traverseObjectExpression( if (!binding) { return; } - if (binding.path.findParent((parent: any) => parent === parentCall)) { + if (binding.path.findParent((parent) => parent === parentCall)) { themeIdentifiers.push(id); } else if (binding.scope !== rootScope) { localIdentifiers.push(id); @@ -101,7 +101,7 @@ function traverseObjectExpression( } else if (property.isSpreadElement()) { const identifiers = findIdentifiers([property.get('argument')]); if ( - !identifiers.every((id: any) => { + !identifiers.every((id) => { const binding = property.scope.getBinding(id.node.name); if (!binding || binding.scope !== rootScope) { return false; diff --git a/packages/zero-unplugin/src/index.ts b/packages/zero-unplugin/src/index.ts index 4892439b5dfed1..3958342f8c6f61 100644 --- a/packages/zero-unplugin/src/index.ts +++ b/packages/zero-unplugin/src/index.ts @@ -14,9 +14,6 @@ import { createUnplugin, UnpluginOptions, } from 'unplugin'; -// import type { PluginOptions as LinariaPluginOptions, Preprocessor } from '@linaria/babel-preset'; -// import { TransformCacheCollection, transform } from '@linaria/babel-preset'; -// import { createPerfMeter, asyncResolveFallback, slugify } from '@linaria/utils'; import { preprocessor as basePreprocessor, generateTokenCss, diff --git a/packages/zero-vite-plugin/src/index.ts b/packages/zero-vite-plugin/src/index.ts index fd922092df4e15..aef0933c855c65 100644 --- a/packages/zero-vite-plugin/src/index.ts +++ b/packages/zero-vite-plugin/src/index.ts @@ -73,10 +73,10 @@ export function zeroVitePlugin(options: ZeroVitePluginOptions) { }, load(id) { if (id === VIRTUAL_CSS_FILE) { - return generateTokenCss(theme); + return generateTokenCss(theme as BaseTheme); } if (id === VIRTUAL_THEME_FILE) { - return `export default ${JSON.stringify(generateThemeTokens(theme))};`; + return `export default ${JSON.stringify(generateThemeTokens(theme as BaseTheme))};`; } return null; }, diff --git a/packages/zero-vite-plugin/src/zero-vite-plugin.ts b/packages/zero-vite-plugin/src/zero-vite-plugin.ts index 38a0c488559179..0db85c53f7d4f0 100644 --- a/packages/zero-vite-plugin/src/zero-vite-plugin.ts +++ b/packages/zero-vite-plugin/src/zero-vite-plugin.ts @@ -10,11 +10,6 @@ import path from 'node:path'; import type { ModuleNode, Plugin, ResolvedConfig, ViteDevServer, FilterPattern } from 'vite'; import { optimizeDeps, createFilter } from 'vite'; -// import { transform, slugify, TransformCacheCollection } from '@linaria/babel-preset'; -// import type { PluginOptions, Preprocessor } from '@linaria/babel-preset'; -// import { linariaLogger } from '@linaria/logger'; -// import type { IPerfMeterOptions } from '@linaria/utils'; -// import { createPerfMeter, getFileIdx, syncResolve } from '@linaria/utils'; import { slugify, logger as wywLogger, syncResolve } from '@wyw-in-js/shared'; import { TransformCacheCollection, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fbdc1132ac4329..73df3a28d12116 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -877,7 +877,7 @@ importers: version: 1.8.8 '@types/stylis': specifier: ^4.2.0 - version: 4.2.0 + version: 4.2.5 chai: specifier: ^4.4.1 version: 4.4.1 @@ -1546,7 +1546,7 @@ importers: version: 2.1.0 csstype: specifier: ^3.1.2 - version: 3.1.2 + version: 3.1.3 prop-types: specifier: ^15.8.1 version: 15.8.1 @@ -1803,7 +1803,7 @@ importers: version: 11.11.0 csstype: specifier: ^3.1.2 - version: 3.1.2 + version: 3.1.3 prop-types: specifier: ^15.8.1 version: 15.8.1 @@ -1841,7 +1841,7 @@ importers: version: 7.23.9 csstype: specifier: ^3.1.2 - version: 3.1.2 + version: 3.1.3 hoist-non-react-statics: specifier: ^3.3.2 version: 3.3.2 @@ -1897,7 +1897,7 @@ importers: version: 2.1.0 csstype: specifier: ^3.1.2 - version: 3.1.2 + version: 3.1.3 hoist-non-react-statics: specifier: ^3.3.2 version: 3.3.2 @@ -1983,7 +1983,7 @@ importers: version: 2.1.0 csstype: specifier: ^3.1.2 - version: 3.1.2 + version: 3.1.3 prop-types: specifier: ^15.8.1 version: 15.8.1 @@ -5251,7 +5251,7 @@ packages: '@types/react': 18.2.48 '@types/react-transition-group': 4.4.10 clsx: 2.1.0 - csstype: 3.1.2 + csstype: 3.1.3 prop-types: 15.8.1 react: 18.2.0 react-dom: 18.2.0(react@18.2.0) @@ -7863,7 +7863,7 @@ packages: dependencies: '@types/prop-types': 15.7.11 '@types/scheduler': 0.16.2 - csstype: 3.1.2 + csstype: 3.1.3 /@types/resolve@0.0.8: resolution: {integrity: sha512-auApPaJf3NPfe18hSoJkp8EbZzer2ISk7o8mCC3M9he/a04+gbMF97NkpD2S8riMGvm4BMRI59/SZQSaLTKpsQ==} @@ -14672,7 +14672,7 @@ packages: resolution: {integrity: sha512-cqsOTS7jqPsPMjtKYDUpdFC0AbhYFLTcuGRqymgmdJIeQ8cH7+AgX7YSgQy79wXloZq2VvATYxUOUQEvS1V/Zw==} dependencies: '@babel/runtime': 7.23.9 - csstype: 3.1.2 + csstype: 3.1.3 is-in-browser: 1.1.3 tiny-warning: 1.0.3 dev: false