-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add "classNameHashSalt" for AOT (#557)
* feat: add "classNameHashSalt" for AOT * remove unrelated code
- Loading branch information
1 parent
3cac9f0
commit 1a56464
Showing
16 changed files
with
124 additions
and
8 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/@griffel-babel-preset-5f01fbba-7bfc-453f-9e5b-60dcdaf7f65f.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": "minor", | ||
"comment": "feat: add \"classNameHashSalt\" for AOT", | ||
"packageName": "@griffel/babel-preset", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch" | ||
} |
7 changes: 7 additions & 0 deletions
7
change/@griffel-core-1200d9cd-dfd9-46bd-b88a-6c2a7b30a7e7.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": "minor", | ||
"comment": "feat: add \"classNameHashSalt\" for AOT", | ||
"packageName": "@griffel/core", | ||
"email": "[email protected]", | ||
"dependentChangeType": "patch" | ||
} |
5 changes: 5 additions & 0 deletions
5
packages/babel-preset/__fixtures__/config-classname-hash-salt/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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { makeStyles } from '@griffel/react'; | ||
|
||
export const useStyles = makeStyles({ | ||
root: { color: 'red', paddingLeft: '4px' }, | ||
}); |
12 changes: 12 additions & 0 deletions
12
packages/babel-preset/__fixtures__/config-classname-hash-salt/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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { __styles } from '@griffel/react'; | ||
export const useStyles = __styles( | ||
{ | ||
root: { | ||
sj55zd: 'feohi3x', | ||
uwmqm3: ['f1rwgqon', 'f1tyzn0d'], | ||
}, | ||
}, | ||
{ | ||
d: ['.feohi3x{color:red;}', '.f1rwgqon{padding-left:4px;}', '.f1tyzn0d{padding-right:4px;}'], | ||
}, | ||
); |
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 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 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { hashClassName } from './hashClassName'; | ||
|
||
const defaultOptions = { | ||
property: 'color', | ||
selector: '', | ||
value: 'red', | ||
|
||
salt: '', | ||
}; | ||
const defaultAtRules = { | ||
container: '', | ||
media: '', | ||
layer: '', | ||
supports: '', | ||
}; | ||
|
||
describe('hashClassName', () => { | ||
it('should hash the className', () => { | ||
expect(hashClassName(defaultOptions, defaultAtRules)).toMatchInlineSnapshot(`"fe3e8s9"`); | ||
}); | ||
|
||
it('should use salt for hash', () => { | ||
const withoutSalt = hashClassName(defaultOptions, defaultAtRules); | ||
const withSalt = hashClassName({ ...defaultOptions, salt: 'HASH_SALT' }, defaultAtRules); | ||
|
||
expect(withoutSalt).not.toEqual(withSalt); | ||
|
||
expect(withoutSalt).toMatchInlineSnapshot(`"fe3e8s9"`); | ||
expect(withSalt).toMatchInlineSnapshot(`"f3mwu0g"`); | ||
}); | ||
}); |
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
5 changes: 5 additions & 0 deletions
5
packages/webpack-loader/__fixtures__/config-classname-hash-salt/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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { makeStyles } from '@griffel/react'; | ||
|
||
export const styles = makeStyles({ | ||
root: { color: 'red', paddingLeft: '10px' }, | ||
}); |
12 changes: 12 additions & 0 deletions
12
packages/webpack-loader/__fixtures__/config-classname-hash-salt/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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { __styles } from '@griffel/react'; | ||
export const styles = __styles( | ||
{ | ||
root: { | ||
sj55zd: 'f3mwu0g', | ||
uwmqm3: ['f1rfztu6', 'f1h66kgv'], | ||
}, | ||
}, | ||
{ | ||
d: ['.f3mwu0g{color:red;}', '.f1rfztu6{padding-left:10px;}', '.f1h66kgv{padding-right:10px;}'], | ||
}, | ||
); |
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