Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/cli #561

Merged
merged 39 commits into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
1afed9b
Start working on cli
nmn Feb 1, 2024
6aca831
cli: basic nodejs cli setup
Jta26 Feb 9, 2024
2fe1ba6
[cli] very rough working stylex cli
Jta26 Feb 10, 2024
2ca76a8
[cli] adding relative imports to compiled js files and basic watchman…
Jta26 Feb 12, 2024
0819aca
[cli] restore lockfile
Jta26 Feb 12, 2024
301b3a8
[cli] watch mode that recompiles entire directory on files changed
Jta26 Feb 13, 2024
721feb5
[cli] remove compiled example
Jta26 Feb 13, 2024
4e03371
[cli] add test verifying functionality of cli
Jta26 Feb 14, 2024
5a1f040
[cli] typos
Jta26 Feb 14, 2024
58407e7
[cli] cool ascii art
Jta26 Feb 14, 2024
0a6c6a4
[cli] change bin to lib directory
Jta26 Feb 14, 2024
2a63c5e
[cli] ignore prettier, eslint in compiled test files
Jta26 Feb 14, 2024
dd56fd4
Fix type errors in CLI and minor tweaks
nmn Feb 21, 2024
2d0e8c4
Add syntax plugins
nmn Feb 21, 2024
bef5217
[cli] handle top level dir edge case, clean up on compile failure, un…
Jta26 Feb 26, 2024
43cbdcc
[cli] next swc example
Jta26 Feb 27, 2024
c11130e
[cli] better ascii art
Jta26 Feb 27, 2024
94f697b
[cli] basic .stylex.json config file support
Jta26 Feb 27, 2024
b42644c
[cli] output all as .js, use mkdirp, use babel typescript plugin
Jta26 Feb 27, 2024
85d8b61
cli-example w/ next -> pure stylex compile example
Jta26 Feb 29, 2024
9f88228
[cli] make watch mode only recompile changed files
Jta26 Mar 13, 2024
87ca7a8
[cli] fix tests
Jta26 Mar 13, 2024
4a8cb00
[cli] update README and fix test?
Jta26 Mar 13, 2024
117a154
fix: typo in readme
nmn Apr 9, 2024
716b28b
Handle options from both CLI and config file
nmn Apr 23, 2024
2ab98a5
[cli] kinda working node_modules compilation
Jta26 Mar 13, 2024
d0f5a66
[cli] mark node modules compilation feature as experimental
Jta26 Apr 27, 2024
62e67ce
rebase and update to 0.6.1
Jta26 Apr 29, 2024
153bb61
[cli] support passthrough babel presets in config
Jta26 May 1, 2024
0e29ecb
[cli] multi-directory input/output
Jta26 May 6, 2024
2097ae1
[cli] make docs site use cli
Jta26 May 6, 2024
6778c15
[cli] add cli to docs package.json
Jta26 May 6, 2024
9730510
[cli] package-lock docs stylex cli
Jta26 May 7, 2024
ca4daa7
[cli] add test for multiple directories
Jta26 May 8, 2024
47485dc
Revert "[cli] make docs site use cli"
Jta26 May 8, 2024
8b4ea06
[cli] improve multi-directory test
Jta26 May 8, 2024
c6f98db
[cli] add test ensuring inputs and output are properly resolved
Jta26 May 9, 2024
fa34cc0
remove TODO comments
Jta26 May 10, 2024
bfa0ffc
[cli] allow ignoring subdirectories in compiled node modules
Jta26 May 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ module.exports = {
'node_modules',
'next-env.d.ts',
'next.config.js',
'**/__mocks__/snapshot*',
],
globals: {
$Call: 'readonly',
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ coverage
lib
node_modules
*.mdx
**/__mocks__/snapshot*
4 changes: 4 additions & 0 deletions apps/cli-example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# stylex compiled
src
12 changes: 12 additions & 0 deletions apps/cli-example/.stylex.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"input": ["./source"],
"output": ["./src"],
"cssBundleName": "stylex_bundle.css",
"babelPresets": [
["@babel/preset-typescript", { "allExtensions": "true", "isTSX": "true" }],
"@babel/preset-react"
],
"modules_EXPERIMENTAL": ["@stylexjs/open-props"],
"watch": "true"
}

13 changes: 13 additions & 0 deletions apps/cli-example/.stylex.json5
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
input: ['./source'],
output: ['./src'],
cssBundleName: 'stylex_bundle.css',
babelPresets: [
['@babel/preset-typescript', { allExtensions: true, isTSX: true }],
'@babel/preset-react',
],
modules_EXPERIMENTAL: [
['@stylexjs/open-props', { ignore: ['src', '__tests__'] }],
],
// watch: true,
}
Empty file added apps/cli-example/README.md
Empty file.
21 changes: 21 additions & 0 deletions apps/cli-example/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "stylex-cli-example",
"version": "0.6.1",
"private": true,
"scripts": {
"transform": "stylex --config .stylex.json5"
},
"dependencies": {
"@stylexjs/open-props": "0.6.1",
"react": "^18",
"react-dom": "^18"
},
"devDependencies": {
"@babel/preset-react": "^7.24.1",
"@babel/preset-typescript": "^7.24.1",
"@stylexjs/cli": "0.6.1",
"@types/react": "^18",
"@types/react-dom": "^18",
"typescript": "^5"
}
}
14 changes: 14 additions & 0 deletions apps/cli-example/source/app/CardTokens.stylex.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/

import * as stylex from '@stylexjs/stylex';

export const tokens = stylex.defineVars({
arrowTransform: 'translateX(0)',
});
101 changes: 101 additions & 0 deletions apps/cli-example/source/app/Counter.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*
*/

'use client';

import * as stylex from '@stylexjs/stylex';
import { spacing, text, globalTokens as $ } from './globalTokens.stylex';
import { colors } from '@stylexjs/open-props/lib/colors.stylex';
import { useState } from 'react';

export default function Counter() {
const [count, setCount] = useState(0);

return (
<div {...stylex.props(styles.container)}>
<button
{...stylex.props(styles.button)}
onClick={() => setCount((c) => c - 1)}
>
-
</button>
<div
{...stylex.props(
styles.count,
Math.abs(count) > 99 && styles.largeNumber,
)}
>
{count}
</div>
<button
{...stylex.props(styles.button)}
onClick={() => setCount((c) => c + 1)}
>
+
</button>
</div>
);
}

const DARK = '@media (prefers-color-scheme: dark)' as const;

const styles = stylex.create({
container: {
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
flexDirection: 'row',
borderRadius: spacing.md,
borderWidth: 1,
borderStyle: 'solid',
borderColor: colors.blue7,
padding: spacing.xxxs,
fontFamily: $.fontSans,
gap: spacing.xs,
},
button: {
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
height: '6rem',
aspectRatio: 1,
color: colors.blue7,
backgroundColor: {
default: colors.gray3,
':hover': colors.gray4,
[DARK]: {
default: colors.gray9,
':hover': colors.gray8,
},
},
borderWidth: 0,
borderStyle: 'none',
borderRadius: spacing.xs,
padding: spacing.xs,
margin: spacing.xs,
cursor: 'pointer',
fontSize: text.h2,
transform: {
default: null,
':hover': 'scale(1.025)',
':active': 'scale(0.975)',
},
},
count: {
fontSize: text.h2,
fontWeight: 100,
color: colors.lime7,
minWidth: '6rem',
textAlign: 'center',
fontFamily: $.fontMono,
},
largeNumber: {
fontSize: text.h3,
},
});
Binary file added apps/cli-example/source/app/favicon.ico
Binary file not shown.