-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(babel-make-styles): simplify evaluation (#21144)
* refactor(babel-make-styles): simplify evaluation * Update packages/babel-make-styles/src/plugin.ts * Change files * fix fixtures Co-authored-by: KHMakoto <[email protected]>
- Loading branch information
1 parent
fc9a2a4
commit 9e546ae
Showing
14 changed files
with
68 additions
and
535 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/@fluentui-babel-make-styles-483339d1-5946-49b0-81d4-f0b5d9cc738e.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "prerelease", | ||
"comment": "simplify module evaluation", | ||
"packageName": "@fluentui/babel-make-styles", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 4 additions & 12 deletions
16
packages/babel-make-styles/__fixtures__/commonjs/output.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,14 @@ | ||
import { Theme } from '@fluentui/react-theme'; | ||
|
||
const react_make_styles_1 = require('@fluentui/react-make-styles'); | ||
|
||
const useStyles = react_make_styles_1.__styles( | ||
export const useStyles = react_make_styles_1.__styles( | ||
{ | ||
root: { | ||
Be2twd7: 'fkhj508', | ||
Bg96gwp: 'f1i3iumi', | ||
Bhrd7zp: 'figsok6', | ||
Be2twd7: 'fses1vf', | ||
Bg96gwp: 'fp6vxd', | ||
}, | ||
}, | ||
{ | ||
d: [ | ||
'.fkhj508{font-size:var(--fontSizeBase300);}', | ||
'.f1i3iumi{line-height:var(--lineHeightBase300);}', | ||
'.figsok6{font-weight:var(--fontWeightRegular);}', | ||
], | ||
d: ['.fses1vf{font-size:14px;}', '.fp6vxd{line-height:1;}'], | ||
}, | ||
); | ||
|
||
console.log(useStyles); |
13 changes: 4 additions & 9 deletions
13
packages/babel-make-styles/__fixtures__/config-evaluation-rules/code.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,8 @@ | ||
import { makeStyles } from '@fluentui/react-make-styles'; | ||
|
||
const func = () => { | ||
// This assignment has no sense, but it will prevent us from evaluation in AST | ||
// This fixture uses "sampleEvaluator.js" in plugin's config so input we should get a different color | ||
const color = 'red'; | ||
|
||
return { color }; | ||
}; | ||
import { colorRed } from './consts'; | ||
|
||
export const useStyles = makeStyles({ | ||
root: func(), | ||
// This import has no sense, but it will prevent us from evaluation in AST by Babel | ||
// This fixture uses "sampleEvaluator.js" in plugin's config so input we should get a different color | ||
root: { color: colorRed }, | ||
}); |
1 change: 1 addition & 0 deletions
1
packages/babel-make-styles/__fixtures__/config-evaluation-rules/consts.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const colorRed = 'red'; |
11 changes: 1 addition & 10 deletions
11
packages/babel-make-styles/__fixtures__/config-evaluation-rules/output.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 0 additions & 6 deletions
6
packages/babel-make-styles/__fixtures__/error-style-method/fixture.js
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
packages/babel-make-styles/__fixtures__/error-style-property/fixture.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.