Skip to content

Commit 1f7b76f

Browse files
committed
chore: migrate to to wyw-in-js
1 parent d25676d commit 1f7b76f

File tree

105 files changed

+330
-2152
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+330
-2152
lines changed

apps/website/docs/react/ahead-of-time-compilation/with-babel.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ import TabItem from '@theme/TabItem';
1313
<TabItem value="yarn" label="Yarn">
1414

1515
```shell
16-
yarn add --dev @griffel/babel-preset
16+
yarn add --dev @griffel/babel-preset @griffel/tag-processor
1717
```
1818

1919
</TabItem>
2020
<TabItem value="npm" label="NPM">
2121

2222
```shell
23-
npm install --save-dev @griffel/babel-preset
23+
npm install --save-dev @griffel/babel-preset @griffel/tag-processor
2424
```
2525

2626
</TabItem>

apps/website/docs/react/ahead-of-time-compilation/with-webpack.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ import TabItem from '@theme/TabItem';
1313
<TabItem value="yarn" label="Yarn">
1414

1515
```shell
16-
yarn add --dev @griffel/webpack-loader
16+
yarn add --dev @griffel/tag-processor @griffel/webpack-loader
1717
```
1818

1919
</TabItem>
2020
<TabItem value="npm" label="NPM">
2121

2222
```shell
23-
npm install --save-dev @griffel/webpack-loader
23+
npm install --save-dev @griffel/tag-processor @griffel/webpack-loader
2424
```
2525

2626
</TabItem>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "major",
3+
"comment": "BREAKING: migrate to to wyw-in-js",
4+
"packageName": "@griffel/babel-preset",
5+
"email": "olfedias@microsoft.com",
6+
"dependentChangeType": "patch"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "chore: add meta to package.json for @griffel/tag-processor",
4+
"packageName": "@griffel/react",
5+
"email": "olfedias@microsoft.com",
6+
"dependentChangeType": "patch"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "major",
3+
"comment": "BREAKING: migrate to to wyw-in-js",
4+
"packageName": "@griffel/webpack-loader",
5+
"email": "olfedias@microsoft.com",
6+
"dependentChangeType": "patch"
7+
}

e2e/nextjs/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"$schema": "../../node_modules/nx/schemas/project-schema.json",
44
"sourceRoot": "e2e/nextjs/src",
55
"projectType": "library",
6-
"implicitDependencies": ["@griffel/webpack-loader"],
6+
"implicitDependencies": ["@griffel/tag-processor", "@griffel/webpack-loader"],
77
"targets": {
88
"test": {
99
"executor": "nx:run-commands",

e2e/nextjs/src/test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ async function performTest() {
2626
packLocalPackage(rootDir, tempDir, '@griffel/style-types'),
2727
packLocalPackage(rootDir, tempDir, '@griffel/core'),
2828
packLocalPackage(rootDir, tempDir, '@griffel/react'),
29+
packLocalPackage(rootDir, tempDir, '@griffel/tag-processor'),
2930
packLocalPackage(rootDir, tempDir, '@griffel/webpack-extraction-plugin'),
3031
packLocalPackage(rootDir, tempDir, '@griffel/webpack-loader'),
3132
packLocalPackage(rootDir, tempDir, '@griffel/next-extraction-plugin'),

package.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,12 @@
4747
"@nrwl/web": "15.3.3",
4848
"@nrwl/workspace": "15.3.3",
4949
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.10",
50+
"@rspack/cli": "^0.3.6",
5051
"@storybook/addon-essentials": "6.5.15",
5152
"@storybook/builder-webpack5": "6.5.15",
5253
"@storybook/manager-webpack5": "6.5.15",
5354
"@storybook/react": "6.5.15",
55+
"@swc/core": "^1.3.19",
5456
"@testing-library/jest-dom": "5.16.1",
5557
"@testing-library/react": "13.4.0",
5658
"@tsconfig/docusaurus": "^1.0.4",
@@ -149,15 +151,10 @@
149151
"@babel/template": "^7.22.15",
150152
"@babel/traverse": "^7.23.2",
151153
"@emotion/hash": "^0.9.0",
152-
"@linaria/babel-preset": "^3.0.0-beta.24",
153-
"@linaria/shaker": "^3.0.0-beta.22",
154-
"@rspack/cli": "^0.3.6",
155-
"@swc/core": "^1.3.19",
156154
"@typescript-eslint/utils": "^5.47.0",
157155
"ajv": "^8.4.0",
158156
"browserslist": "^4.19.1",
159157
"csstype": "^3.1.3",
160-
"enhanced-resolve": "^5.8.2",
161158
"rtl-css-js": "^1.16.1",
162159
"source-map-js": "1.0.2",
163160
"stylis": "^4.2.0",

packages/babel-preset/README.md

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ A Babel preset that performs build time transforms for [`@griffel/react`](../rea
2222
## Install
2323

2424
```bash
25-
yarn add --dev @griffel/babel-preset
25+
yarn add --dev @griffel/babel-preset @griffel/tag-processor
2626
# or
27-
npm install --save-dev @griffel/babel-preset
27+
npm install --save-dev @griffel/babel-preset @griffel/tag-processor
2828
```
2929

3030
## When to use it?
@@ -50,22 +50,27 @@ import { makeStyles } from 'custom-package';
5050
import { createStyles } from 'custom-package';
5151
```
5252

53-
By default, preset handles imports from `@griffel/react` & `@fluentui/react-components`, to handle imports from custom packages settings should be tweaked:
53+
By default, preset handles imports from `@griffel/react` & `@fluentui/react-components`, to handle imports from custom packages settings you need to include meta information to a matching `package.json`:
5454

5555
```json
5656
{
57-
"presets": [
58-
[
59-
"@griffel",
60-
{
61-
"modules": [{ "moduleSource": "custom-package", "importName": "makeStyles" }]
62-
}
63-
]
64-
]
57+
"name": "custom-package",
58+
"version": "1.0.0",
59+
"linaria": {
60+
"tags": {
61+
"makeStyles": "@griffel/tag-processor/make-styles",
62+
"makeResetStyles": "@griffel/tag-processor/make-reset-styles"
63+
}
64+
}
6565
}
6666
```
6767

68-
> **Note**: "custom-package" should re-export `__styles` function from `@griffel/react`
68+
> **Note**: "custom-package" should re-export following functions from `@griffel/react`:
69+
>
70+
> - `__styles`
71+
> - `__css`
72+
> - `__resetStyles`
73+
> - `__resetCSS`
6974
7075
### Configuring Babel settings
7176

@@ -157,9 +162,9 @@ const useStyles = makeStyles({
157162
roughly to
158163

159164
```js
160-
import { __styles } from '@griffel/react';
165+
import { __styles as _styles } from '@griffel/react';
161166

162-
const useStyles = __styles(/* resolved styles */);
167+
const useStyles = _styles(/* resolved styles */);
163168
```
164169

165170
## Access CSS output from code
@@ -218,7 +223,7 @@ However, the concepts are not coupled to the repo setup.
218223

219224
### Module evaluation
220225

221-
The preset uses tools from [linaria](https://github.com/callstack/linaria) to evaluate runtime calls of `makeStyles`.
226+
The preset reuses `@linaria/babel-preset` from [linaria](https://github.com/callstack/linaria) to evaluate runtime calls of `makeStyles` and `makeResetStyles`.
222227
[Linaria's debugging documentation can help here](https://github.com/callstack/linaria/blob/master/CONTRIBUTING.md#debugging-and-deep-dive-into-babel-plugin).
223228

224229
Debugging output can be activated with following environment variables:
@@ -232,9 +237,3 @@ On Windows it's required to set environment variables via [`set`](https://docs.m
232237
```sh
233238
$ cross-env DEBUG=linaria\* LINARIA_LOG=debug yarn build
234239
```
235-
236-
The debug output will include:
237-
238-
- Prepared code
239-
- Evaluated code
240-
- AST that indicates what code has been shaken with `@linaria/shaker`
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1+
import { __styles as _styles } from '@griffel/react';
12
import _asset2 from './empty.jpg';
23
import _asset from './blank.jpg';
3-
import { __styles } from '@griffel/react';
4-
import blank from './blank.jpg';
5-
import empty from './empty.jpg';
6-
export const useStyles = __styles(
4+
export const useStyles = /*#__PURE__*/ _styles(
75
{
86
root: {
9-
Bcmaq0h: 'fp00rh9',
7+
Bcmaq0h: 'f1surbjy',
108
},
119
},
1210
{
13-
d: [`.fp00rh9{background-image:url(${_asset}),url(${_asset2});}`],
11+
d: [`.f1surbjy{background-image:url(${_asset}),url(${_asset2});}`],
1412
},
1513
);

0 commit comments

Comments
 (0)