@griffel/postcss-syntax 1.3.11 → 1.3.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md DELETED
@@ -1,263 +0,0 @@
1
- # Change Log - @griffel/postcss-syntax
2
-
3
- <!-- This log was last generated on Thu, 21 May 2026 08:10:29 GMT and should not be manually modified. -->
4
-
5
- <!-- Start content -->
6
-
7
- ## 1.3.11
8
-
9
- Thu, 21 May 2026 08:10:29 GMT
10
-
11
- ### Patches
12
-
13
- - chore(deps): bump postcss from 8.5.12 to 8.5.14 (49699333+dependabot[bot]@users.noreply.github.com)
14
- - Bump @griffel/babel-preset to v1.8.5
15
-
16
- ## 1.3.10
17
-
18
- Mon, 04 May 2026 12:34:39 GMT
19
-
20
- ### Patches
21
-
22
- - chore(deps): bump @babel/helper-plugin-utils (49699333+dependabot[bot]@users.noreply.github.com)
23
- - chore(deps): bump @babel/core from 7.28.5 to 7.29.0 (49699333+dependabot[bot]@users.noreply.github.com)
24
- - Bump @griffel/babel-preset to v1.8.4
25
-
26
- ## 1.3.9
27
-
28
- Thu, 30 Apr 2026 08:33:37 GMT
29
-
30
- ### Patches
31
-
32
- - Bump @griffel/babel-preset to v1.8.3
33
-
34
- ## 1.3.8
35
-
36
- Wed, 29 Apr 2026 17:05:15 GMT
37
-
38
- ### Patches
39
-
40
- - chore(deps): bump postcss from 8.4.47 to 8.5.10 (olfedias@microsoft.com)
41
-
42
- ## 1.3.7
43
-
44
- Wed, 29 Apr 2026 08:41:14 GMT
45
-
46
- ### Patches
47
-
48
- - Bump @griffel/babel-preset to v1.8.2
49
-
50
- ## 1.3.6
51
-
52
- Fri, 06 Mar 2026 15:56:28 GMT
53
-
54
- ### Patches
55
-
56
- - Bump @griffel/babel-preset to v1.8.1
57
-
58
- ## 1.3.5
59
-
60
- Fri, 06 Mar 2026 08:17:06 GMT
61
-
62
- ### Patches
63
-
64
- - Bump @griffel/babel-preset to v1.8.0
65
-
66
- ## 1.3.4
67
-
68
- Mon, 03 Nov 2025 15:43:56 GMT
69
-
70
- ### Patches
71
-
72
- - Bump @griffel/babel-preset to v1.7.0
73
-
74
- ## 1.3.3
75
-
76
- Mon, 28 Jul 2025 09:12:30 GMT
77
-
78
- ### Patches
79
-
80
- - Bump @griffel/babel-preset to v1.6.8
81
-
82
- ## 1.3.2
83
-
84
- Tue, 22 Apr 2025 10:05:48 GMT
85
-
86
- ### Patches
87
-
88
- - Bump @griffel/babel-preset to v1.6.7
89
-
90
- ## 1.3.1
91
-
92
- Mon, 10 Feb 2025 08:07:43 GMT
93
-
94
- ### Patches
95
-
96
- - fix(postcss-syntax): Silenced parse result should be stringifiable (lingfangao@hotmail.com)
97
-
98
- ## 1.3.0
99
-
100
- Tue, 04 Feb 2025 14:53:08 GMT
101
-
102
- ### Minor changes
103
-
104
- - feat: postcss-syntax should silence parse errors on demand (lingfangao@hotmail.com)
105
-
106
- ## 1.2.4
107
-
108
- Thu, 23 Jan 2025 12:09:03 GMT
109
-
110
- ### Patches
111
-
112
- - Bump @griffel/babel-preset to v1.6.6
113
-
114
- ## 1.2.3
115
-
116
- Wed, 22 Jan 2025 13:44:43 GMT
117
-
118
- ### Patches
119
-
120
- - Bump @griffel/babel-preset to v1.6.5
121
-
122
- ## 1.2.2
123
-
124
- Wed, 08 Jan 2025 10:03:24 GMT
125
-
126
- ### Patches
127
-
128
- - fix: Persist filename in postcss syntax (lingfangao@hotmail.com)
129
- - fix: return location of the makeStyles/makeResetStyles call expression when it is not called with object expression (yuanboxue@microsoft.com)
130
- - fix: parse styles with new lines (yuanboxue@microsoft.com)
131
-
132
- ## 1.2.1
133
-
134
- Tue, 12 Nov 2024 09:58:11 GMT
135
-
136
- ### Patches
137
-
138
- - Bump @griffel/babel-preset to v1.6.4
139
-
140
- ## 1.2.0
141
-
142
- Thu, 31 Oct 2024 16:16:50 GMT
143
-
144
- ### Minor changes
145
-
146
- - feat: Support stylelint rule disabling for style slots (lingfangao@hotmail.com)
147
- - Bump @griffel/babel-preset to v1.6.3
148
-
149
- ## 1.1.4
150
-
151
- Mon, 29 Jul 2024 07:31:53 GMT
152
-
153
- ### Patches
154
-
155
- - Bump @griffel/babel-preset to v1.6.2
156
-
157
- ## 1.1.3
158
-
159
- Wed, 10 Jul 2024 14:36:29 GMT
160
-
161
- ### Patches
162
-
163
- - Bump @griffel/babel-preset to v1.6.1
164
-
165
- ## 1.1.2
166
-
167
- Wed, 22 May 2024 08:24:17 GMT
168
-
169
- ### Patches
170
-
171
- - Bump @griffel/babel-preset to v1.6.0
172
-
173
- ## 1.1.1
174
-
175
- Fri, 10 May 2024 10:13:20 GMT
176
-
177
- ### Patches
178
-
179
- - fix: use plugins/presets from options.babelOptions to transform source. (yuanboxue@microsoft.com)
180
- - Bump @griffel/babel-preset to v1.5.9
181
-
182
- ## 1.1.0
183
-
184
- Tue, 07 May 2024 12:51:34 GMT
185
-
186
- ### Minor changes
187
-
188
- - Update `parse` to generate css rules one line per slot(makeStyles)/declaration(makeResetStyles) (yuanboxue@microsoft.com)
189
-
190
- ## 1.0.8
191
-
192
- Thu, 02 May 2024 14:07:14 GMT
193
-
194
- ### Patches
195
-
196
- - Bump @griffel/babel-preset to v1.5.8
197
-
198
- ## 1.0.7
199
-
200
- Tue, 19 Mar 2024 11:33:53 GMT
201
-
202
- ### Patches
203
-
204
- - fix: Remove console.log (lingfangao@hotmail.com)
205
- - Bump @griffel/babel-preset to v1.5.7
206
-
207
- ## 1.0.6
208
-
209
- Fri, 15 Mar 2024 11:30:24 GMT
210
-
211
- ### Patches
212
-
213
- - fix: entrypoint to be correct path (lingfangao@hotmail.com)
214
-
215
- ## 1.0.5
216
-
217
- Fri, 12 Jan 2024 11:08:40 GMT
218
-
219
- ### Patches
220
-
221
- - Bump @griffel/babel-preset to v1.5.6
222
-
223
- ## 1.0.4
224
-
225
- Thu, 30 Nov 2023 16:42:15 GMT
226
-
227
- ### Patches
228
-
229
- - Bump @griffel/babel-preset to v1.5.5
230
-
231
- ## 1.0.3
232
-
233
- Thu, 09 Nov 2023 14:35:07 GMT
234
-
235
- ### Patches
236
-
237
- - Bump @griffel/babel-preset to v1.5.4
238
-
239
- ## 1.0.2
240
-
241
- Mon, 30 Oct 2023 14:08:55 GMT
242
-
243
- ### Patches
244
-
245
- - chore: bump Babel dependencies (olfedias@microsoft.com)
246
- - Bump @griffel/babel-preset to v1.5.3
247
-
248
- ## 1.0.1
249
-
250
- Tue, 03 Oct 2023 19:09:32 GMT
251
-
252
- ### Patches
253
-
254
- - Bump @griffel/babel-preset to v1.5.2
255
-
256
- ## 1.0.0
257
-
258
- Fri, 15 Sep 2023 08:08:42 GMT
259
-
260
- ### Major changes
261
-
262
- - feat: Initial release (lingfangao@hotmail.com)
263
- - Bump @griffel/babel-preset to v1.5.1
package/eslint.config.mjs DELETED
@@ -1,18 +0,0 @@
1
- import baseConfig from '../../eslint.config.mjs';
2
-
3
- export default [
4
- {
5
- ignores: ['**/dist', '**/out-tsc'],
6
- },
7
- ...baseConfig,
8
- {
9
- files: ['**/*.ts', '**/*.tsx'],
10
- // Override or add rules here
11
- rules: {},
12
- },
13
- {
14
- files: ['**/*.js', '**/*.jsx'],
15
- // Override or add rules here
16
- rules: {},
17
- },
18
- ];
package/project.json DELETED
@@ -1,51 +0,0 @@
1
- {
2
- "name": "@griffel/postcss-syntax",
3
- "$schema": "../../node_modules/nx/schemas/project-schema.json",
4
- "sourceRoot": "packages/postcss-syntax/src",
5
- "projectType": "library",
6
- "tags": [],
7
- "targets": {
8
- "lint": {
9
- "executor": "@nx/eslint:lint",
10
- "outputs": ["{options.outputFile}"]
11
- },
12
- "test": {
13
- "executor": "@nx/vitest:test",
14
- "outputs": ["{options.reportsDirectory}"],
15
- "options": {
16
- "reportsDirectory": "{projectRoot}/../../coverage/packages/postcss-syntax"
17
- }
18
- },
19
- "build": {
20
- "executor": "@nx/js:tsc",
21
- "outputs": ["{options.outputPath}"],
22
- "options": {
23
- "outputPath": "dist/packages/postcss-syntax",
24
- "tsConfig": "packages/postcss-syntax/tsconfig.lib.json",
25
- "skipTypeField": true,
26
- "packageJson": "packages/postcss-syntax/package.json",
27
- "main": "packages/postcss-syntax/src/index.ts",
28
- "assets": [
29
- "packages/postcss-syntax/README.md",
30
- {
31
- "glob": "LICENSE.md",
32
- "input": ".",
33
- "output": "."
34
- }
35
- ]
36
- }
37
- },
38
- "type-check": {
39
- "executor": "nx:run-commands",
40
- "options": {
41
- "cwd": "packages/babel-preset",
42
- "commands": [
43
- {
44
- "command": "tsc -b --pretty"
45
- }
46
- ]
47
- },
48
- "outputs": []
49
- }
50
- }
51
- }
package/src/constants.ts DELETED
@@ -1,5 +0,0 @@
1
- export const GRIFFEL_SLOT_RAW = 'griffel-slot';
2
- export const GRIFFEL_SRC_RAW = 'griffel-src';
3
- export const GRIFFEL_DECLARATOR_RAW = 'griffel-declarator';
4
- export const GRIFFEL_SLOT_LOCATION_RAW = 'griffel-slot-location';
5
- export const GRIFFEL_DECLARATOR_LOCATION_RAW = 'griffel-declarator-location';
@@ -1,19 +0,0 @@
1
- import type { BabelPluginOptions } from '@griffel/babel-preset';
2
- import type * as postcss from 'postcss';
3
-
4
- import { parse } from './parse';
5
- import { stringify } from './stringify';
6
-
7
- /**
8
- * Creates a custom syntax with configured options for @griffel/babel-preset
9
- * @param options - Options to configure @griffel/babel-preset
10
- * @returns a postcss custom syntax
11
- */
12
- export function createSyntax(options: BabelPluginOptions): postcss.Syntax {
13
- const extendedParse: postcss.Parser = (css, opts) => parse(css, { ...opts, ...options });
14
-
15
- return {
16
- stringify,
17
- parse: extendedParse,
18
- };
19
- }
@@ -1,206 +0,0 @@
1
- import type { PluginObj, PluginPass, types as t, ConfigAPI } from '@babel/core';
2
- import { declare } from '@babel/helper-plugin-utils';
3
- import type { BabelPluginOptions } from '@griffel/babel-preset';
4
-
5
- export type CommentDirective = [/** directive */ string, /** value */ string];
6
- export type CommentDirectivesBySlot = Record</** slot */ string, CommentDirective[]>;
7
- export type CommentDirectivesByHookDeclarator = Record</** hook declarator */ string, CommentDirectivesBySlot>;
8
-
9
- export type LocationsBySlot = Record</** slot */ string, t.SourceLocation>;
10
- export type LocationsByHookDeclarator = Record</** hook declarator */ string, LocationsBySlot>;
11
-
12
- export type ResetCommentDirectivesByHookDeclarator = Record</** hook declarator */ string, CommentDirective[]>;
13
-
14
- export type ResetLocationsByHookDeclarator = Record</** hook declarator */ string, t.SourceLocation>;
15
-
16
- export interface LocationPluginState extends PluginPass {
17
- callExpressionLocations?: Record</** hook declarator */ string, t.SourceLocation>;
18
- locations?: LocationsByHookDeclarator;
19
- commentDirectives?: CommentDirectivesByHookDeclarator;
20
-
21
- resetCommentDirectives?: ResetCommentDirectivesByHookDeclarator;
22
- resetLocations?: ResetLocationsByHookDeclarator;
23
- }
24
-
25
- export interface LocationPluginMetadata {
26
- callExpressionLocations: Record</** hook declarator */ string, t.SourceLocation>;
27
- locations: LocationsByHookDeclarator;
28
- commentDirectives: CommentDirectivesByHookDeclarator;
29
-
30
- resetCommentDirectives: ResetCommentDirectivesByHookDeclarator;
31
- resetLocations: ResetLocationsByHookDeclarator;
32
- }
33
-
34
- export type LocationPluginOptions = Pick<BabelPluginOptions, 'modules'>;
35
-
36
- /**
37
- * A plugin that parses Griffel code and returns code locations mapped to respective styles and slots
38
- */
39
- const plugin = declare<LocationPluginOptions, PluginObj<LocationPluginState>>((api, options) => {
40
- api.assertVersion(7);
41
-
42
- const {
43
- modules = [
44
- { moduleSource: '@griffel/react', importName: 'makeStyles', resetImportName: 'makeResetStyles' },
45
- { moduleSource: '@fluentui/react-components', importName: 'makeStyles', resetImportName: 'makeResetStyles' },
46
- ],
47
- } = options;
48
-
49
- const functionKinds = modules.map(moduleEntry => {
50
- return moduleEntry.importName ?? 'makeStyles';
51
- });
52
-
53
- const resetFunctionKinds = modules.map(moduleEntry => {
54
- return moduleEntry.resetImportName ?? 'makeResetStyles';
55
- });
56
-
57
- return {
58
- name: '@griffel/slot-location-plugin',
59
-
60
- pre() {
61
- this.callExpressionLocations = {};
62
- this.locations = {};
63
- this.resetLocations = {};
64
- this.commentDirectives = {};
65
- this.resetCommentDirectives = {};
66
- },
67
-
68
- visitor: {
69
- Program: {
70
- exit() {
71
- Object.assign(this.file.metadata, {
72
- callExpressionLocations: this.callExpressionLocations,
73
- locations: this.locations,
74
- resetLocations: this.resetLocations,
75
- commentDirectives: this.commentDirectives,
76
- resetCommentDirectives: this.resetCommentDirectives,
77
- } as LocationPluginMetadata);
78
- },
79
- },
80
-
81
- // eslint-disable-next-line @typescript-eslint/naming-convention
82
- CallExpression(path, state) {
83
- const callee = path.get('callee');
84
- const declarator = path.findParent(p => p.isVariableDeclarator());
85
-
86
- if (!declarator?.isVariableDeclarator()) {
87
- return;
88
- }
89
-
90
- const id = declarator.get('id');
91
- const declaratorId = id.isIdentifier() ? id.node.name : 'unknown';
92
-
93
- if (!callee.isIdentifier()) {
94
- return;
95
- }
96
-
97
- // Technically we should check if these function kinds are from Griffel
98
- // but since we only collect locations, the plugin is idempotent and we
99
- // it's safe enough to avoid doing that check
100
- if (functionKinds.includes(callee.node.name)) {
101
- if (path.node.loc) {
102
- state.callExpressionLocations ??= {};
103
- state.callExpressionLocations[declaratorId] = {
104
- ...path.node.loc,
105
- };
106
- }
107
-
108
- const locations = path.get('arguments')[0];
109
- if (!locations.isObjectExpression()) {
110
- return;
111
- }
112
-
113
- const properties = locations.get('properties');
114
- properties.forEach(property => {
115
- if (!property.isObjectProperty()) {
116
- return;
117
- }
118
-
119
- const key = property.get('key');
120
- if (!key.isIdentifier()) {
121
- return;
122
- }
123
-
124
- if (!property.node.loc) {
125
- return;
126
- }
127
-
128
- state.locations ??= {};
129
- state.locations[declaratorId] ??= {};
130
- state.locations[declaratorId][key.node.name] = {
131
- ...property.node.loc,
132
- };
133
-
134
- const commentDirectives = parseCommentDirectives(property.node.leadingComments);
135
- if (commentDirectives) {
136
- state.commentDirectives ??= {};
137
- state.commentDirectives[declaratorId] ??= {};
138
- state.commentDirectives[declaratorId][key.node.name] = commentDirectives;
139
- }
140
- });
141
- }
142
-
143
- if (resetFunctionKinds.includes(callee.node.name)) {
144
- if (path.node.loc) {
145
- state.callExpressionLocations ??= {};
146
- state.callExpressionLocations[declaratorId] = {
147
- ...path.node.loc,
148
- };
149
- }
150
-
151
- state.resetLocations ??= {};
152
- const resetStyles = path.get('arguments')[0];
153
- if (!resetStyles.isObjectExpression()) {
154
- return;
155
- }
156
-
157
- if (!resetStyles.node.loc) {
158
- return;
159
- }
160
-
161
- state.resetLocations[declaratorId] = resetStyles.node.loc;
162
-
163
- // For reset styles we only care about the comment directives on the variable declaration
164
- // The leading commment can either be attached to a variable declaration of an export declaration (i.e. export const useResetStyles = ...)
165
- const parentDeclaration =
166
- path.findParent(p => p.isExportNamedDeclaration()) ?? path.findParent(p => p.isVariableDeclaration());
167
- if (parentDeclaration) {
168
- const commentDirectives = parseCommentDirectives(parentDeclaration.node.leadingComments);
169
- if (commentDirectives) {
170
- state.resetCommentDirectives ??= {};
171
- state.resetCommentDirectives[declaratorId] = commentDirectives;
172
- }
173
- }
174
- }
175
- },
176
- },
177
- };
178
- });
179
-
180
- function parseCommentDirectives(leadingComments: t.Comment[] | null | undefined): CommentDirective[] | null {
181
- if (!leadingComments) {
182
- return null;
183
- }
184
-
185
- const entries = leadingComments
186
- // We don't support comment blocks
187
- .filter(comment => comment.type === 'CommentLine')
188
- .map(comment => {
189
- const commentValue = comment.value.trim();
190
- if (!commentValue.startsWith('griffel-')) {
191
- return;
192
- }
193
-
194
- const tokens = commentValue.split(' ');
195
- return [tokens[0], tokens[1]];
196
- })
197
- .filter(Boolean) as [string, string][];
198
-
199
- return entries;
200
- }
201
-
202
- export default (babel: ConfigAPI, options: LocationPluginOptions) => {
203
- return {
204
- plugins: [[plugin, options]],
205
- };
206
- };