Skip to content

Commit

Permalink
update experiment with stylex cli
Browse files Browse the repository at this point in the history
  • Loading branch information
mattstyles committed Jul 7, 2024
1 parent 0fc7709 commit 26e3aef
Show file tree
Hide file tree
Showing 10 changed files with 134 additions and 41 deletions.
2 changes: 1 addition & 1 deletion apps/x/babel.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"presets": ["next/babel"],
"plugins": [[
"@stylexjs/babel-plugin", {
"dev": true,
"dev": false,
"stylexSheetName": "<>",
"useCSSLayers": true,
"unstable_moduleResolution": {
Expand Down
10 changes: 6 additions & 4 deletions apps/x/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "biome lint src"
"lint": "biome lint src",
"test:generate": "stylex --config stylex.config.jsonc"
},
"devDependencies": {
"@stylexjs/babel-plugin": "^0.5.1",
"@stylexjs/nextjs-plugin": "^0.5.1",
"@stylexjs/babel-plugin": "^0.7.5",
"@stylexjs/cli": "^0.7.5",
"@stylexjs/nextjs-plugin": "^0.7.5",
"@types/node": "^20.4.5",
"@types/react": "18.2.17",
"@types/react-dom": "^18.2.7",
Expand All @@ -20,7 +22,7 @@
"typescript": "^5.4.3"
},
"dependencies": {
"@stylexjs/stylex": "^0.5.1",
"@stylexjs/stylex": "^0.7.5",
"@urban-ui/flex": "workspace:*",
"@urban-ui/testx": "workspace:*",
"@urban-ui/theme": "workspace:*",
Expand Down
70 changes: 39 additions & 31 deletions apps/x/src/app/flex/page.tsx
Original file line number Diff line number Diff line change
@@ -1,39 +1,47 @@
import stylex from "@stylexjs/stylex";
import { Flex } from "@urban-ui/flex";
import { spacing } from "@urban-ui/theme/spacing.stylex";
import stylex from '@stylexjs/stylex'
import { Flex } from '@urban-ui/flex'
import { spacing } from '@urban-ui/theme/spacing.stylex'

const styles = stylex.create({
block: {
backgroundColor: "hotpink",
width: spacing.xl,
height: spacing.xl,
},
});
block: {
backgroundColor: 'hotpink',
width: spacing.xl,
height: spacing.xl,
},
})

function Block() {
return <div {...stylex.props(styles.block)} />;
return <div {...stylex.props(styles.block)} />
}

export default function FlexPage() {
return (
<>
<h1>Flex</h1>
<Flex orientation="v" gap="xl">
<div>gap: sm</div>
<Flex gap="sm">
<Block />
<Block />
<Block />
<Block />
</Flex>
<div>gap: md</div>
<Flex gap="md">
<Block />
<Block />
<Block />
<Block />
</Flex>
</Flex>
</>
);
return (
<>
<h1>Flex</h1>
<Flex orientation="v" gap="sm">
<div>gap: sm</div>
<Flex gap="sm">
<Block />
<Block />
<Block />
<Block />
</Flex>
<div>gap: md</div>
<Flex gap="md">
<Block />
<Block />
<Block />
<Block />
</Flex>
<div>gap: lg</div>
<Flex gap="lg">
<Block />
<Block />
<Block />
<Block />
</Flex>
</Flex>
<div style={{ paddingBottom: 24 }} />
</>
)
}
14 changes: 14 additions & 0 deletions apps/x/stylex.config.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"input": "./src/app",
// "input": "./dist",
// "input": "./disttest",
"output": "./generated/stylex",
// "modules_EXPERIMENTAL": ["@stylexjs/open-props", "@urban-ui/theme"],
// "modules_EXPERIMENTAL": ["@stylexjs/open-props"],
// "babelPresets": [
// ["@babel/preset-typescript", { "allExtensions": true, "isTSX": true }],
// "@babel/preset-react"
// ],
"styleXBundleName": "stylex_bundle.css",
"watch": false
}
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion packages/core/theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"dependencies": {
"@capsizecss/core": "^3.1.1",
"@capsizecss/metrics": "^1.2.0",
"@stylexjs/stylex": "^0.5.1"
"@stylexjs/stylex": "^0.7.5"
},
"peerDependencies": {
"react": "^18.2.0"
Expand Down
14 changes: 14 additions & 0 deletions packages/layout/flex/___babel.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"presets": ["next/babel"],
"plugins": [[
"@stylexjs/babel-plugin", {
"dev": true,
"stylexSheetName": "<>",
"useCSSLayers": true,
"unstable_moduleResolution": {
"type": "commonJS",
"rootDir": "../../"
}
}
]]
}
39 changes: 39 additions & 0 deletions packages/layout/flex/arc.config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,51 @@
import cp from 'node:child_process'
import path from 'node:path'
import util from 'node:util'
import type { Config } from '@urban-ui/arc'
import { getTsConfig } from '@urban-ui/arc/ts'

// const spawn = util.promisify(cp.spawn)

const tsconfig = await getTsConfig()

const config: Config = {
include: [tsconfig.compilerOptions?.rootDir ?? 'src', '!**/*.test.ts*'],
outDir: 'dist',
rootDir: tsconfig.compilerOptions?.rootDir ?? 'src',
events: {
complete: async () => {
console.log('🎉')
await spawn('del', ['disttest2'])
console.log(process.cwd(), __dirname)
await spawn('stylex', [
'--config',
path.join(__dirname, 'stylex.config.jsonc'),
])
// await new Promise((res) => {
// const pipe = cp.spawn('stylex', ['-i', 'disttest', '-o', 'disttest2'], {
// stdio: [0, 1, 2],
// })
// pipe.on('data', (chunk) => {
// console.log(chunk)
// })
// pipe.on('close', () => {
// console.log('👩‍🎤')
// res(null)
// })
// })
console.log('❤️')
},
},
}

export default config

function spawn(cmd: string, params: Array<string>) {
return new Promise((res) => {
const pipe = cp.spawn(cmd, params, {
stdio: [0, 1, 2],
})
pipe.on('data', console.log)
pipe.on('close', res)
})
}
11 changes: 7 additions & 4 deletions packages/layout/flex/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,20 @@
},
"dependencies": {
"@radix-ui/react-slot": "^1.0.2",
"@stylexjs/stylex": "^0.5.1",
"@stylexjs/stylex": "^0.7.5",
"@urban-ui/theme": "^0.4.0"
},
"peerDependencies": {
"react": "^18.2.0"
},
"devDependencies": {
"@babel/preset-react": "^7.24.7",
"@babel/preset-typescript": "^7.24.7",
"@happy-dom/global-registrator": "^14.7.1",
"@stylexjs/babel-plugin": "^0.5.1",
"@stylexjs/dev-runtime": "^0.5.1",
"@stylexjs/nextjs-plugin": "^0.5.1",
"@stylexjs/babel-plugin": "^0.7.5",
"@stylexjs/cli": "^0.7.5",
"@stylexjs/dev-runtime": "^0.7.5",
"@stylexjs/nextjs-plugin": "^0.7.5",
"@types/node": "^20.12.2",
"@types/react": "^18.2.0",
"@types/react-dom": "^18.2.0",
Expand Down
13 changes: 13 additions & 0 deletions packages/layout/flex/stylex.config.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"input": "./src",
// "input": "./dist",
// "input": "./disttest",
"output": "./disttest2",
// "modules_EXPERIMENTAL": ["@stylexjs/open-props"],
"babelPresets": [
["@babel/preset-typescript", { "allExtensions": true, "isTSX": true }],
"@babel/preset-react"
],
"styleXBundleName": "stylex_bundle.css",
"watch": false
}

0 comments on commit 26e3aef

Please sign in to comment.