@stylexjs/babel-plugin 0.10.1 → 0.11.0

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.
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ *
8
+ */
9
+
10
+ import type { NodePath } from '@babel/traverse';
11
+ import type { CompiledNamespaces } from '@stylexjs/shared';
12
+ import * as t from '@babel/types';
13
+ import StateManager from './state-manager';
14
+ /**
15
+ * Adds sourceMap data to objects created with stylex.create.
16
+ * Populates the '$$css' property, which the runtime uses to produce a
17
+ * debug string.
18
+ */
19
+ export declare function addSourceMapData(
20
+ obj: CompiledNamespaces,
21
+ babelPath: NodePath<t.CallExpression>,
22
+ state: StateManager,
23
+ ): CompiledNamespaces;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ * @flow strict
8
+ */
9
+
10
+ import type { NodePath } from '../../flow_modules/@babel/traverse';
11
+ import type { CompiledNamespaces } from '@stylexjs/shared';
12
+
13
+ import * as t from '../../flow_modules/@babel/types';
14
+ import StateManager from './state-manager';
15
+
16
+ /**
17
+ * Adds sourceMap data to objects created with stylex.create.
18
+ * Populates the '$$css' property, which the runtime uses to produce a
19
+ * debug string.
20
+ */
21
+ declare export function addSourceMapData(
22
+ obj: CompiledNamespaces,
23
+ babelPath: NodePath<t.CallExpression>,
24
+ state: StateManager,
25
+ ): CompiledNamespaces;
@@ -9,15 +9,8 @@
9
9
 
10
10
  import type { FlatCompiledStyles } from '../../../shared/src/common-types';
11
11
  import * as t from '@babel/types';
12
- import { IncludedStyles } from '@stylexjs/shared';
13
12
  type NestedStringObject = Readonly<{
14
- [key: string]:
15
- | string
16
- | number
17
- | null
18
- | boolean
19
- | NestedStringObject
20
- | IncludedStyles;
13
+ [key: string]: string | number | null | boolean | NestedStringObject;
21
14
  }>;
22
15
  export declare function convertObjectToAST(
23
16
  obj: NestedStringObject,
@@ -10,16 +10,9 @@
10
10
  import type { FlatCompiledStyles } from '../../../shared/src/common-types';
11
11
 
12
12
  import * as t from '../../flow_modules/@babel/types';
13
- import { IncludedStyles } from '@stylexjs/shared';
14
13
 
15
14
  type NestedStringObject = $ReadOnly<{
16
- [key: string]:
17
- | string
18
- | number
19
- | null
20
- | boolean
21
- | NestedStringObject
22
- | IncludedStyles,
15
+ [key: string]: string | number | null | boolean | NestedStringObject,
23
16
  }>;
24
17
 
25
18
  declare export function convertObjectToAST(
@@ -38,36 +38,44 @@ export type StyleXOptions = Readonly<
38
38
  Omit<
39
39
  RuntimeOptions,
40
40
  keyof ({
41
+ aliases?:
42
+ | null
43
+ | undefined
44
+ | Readonly<{ [$$Key$$: string]: string | ReadonlyArray<string> }>;
45
+ enableDebugClassNames?: boolean;
46
+ enableDebugDataProp?: boolean;
47
+ enableDevClassNames?: boolean;
48
+ genConditionalClasses: boolean;
41
49
  importSources: ReadonlyArray<
42
50
  string | Readonly<{ from: string; as: string }>
43
51
  >;
52
+ rewriteAliases?: boolean;
44
53
  runtimeInjection:
45
54
  | boolean
46
55
  | (null | undefined | string)
47
56
  | Readonly<{ from: string; as: string }>;
48
57
  treeshakeCompensation?: boolean;
49
- genConditionalClasses: boolean;
50
58
  unstable_moduleResolution?: null | undefined | ModuleResolution;
51
- aliases?:
52
- | null
53
- | undefined
54
- | Readonly<{ [$$Key$$: string]: string | ReadonlyArray<string> }>;
55
59
  })
56
60
  > & {
61
+ aliases?:
62
+ | null
63
+ | undefined
64
+ | Readonly<{ [$$Key$$: string]: string | ReadonlyArray<string> }>;
65
+ enableDebugClassNames?: boolean;
66
+ enableDebugDataProp?: boolean;
67
+ enableDevClassNames?: boolean;
68
+ genConditionalClasses: boolean;
57
69
  importSources: ReadonlyArray<
58
70
  string | Readonly<{ from: string; as: string }>
59
71
  >;
72
+ rewriteAliases?: boolean;
60
73
  runtimeInjection:
61
74
  | boolean
62
75
  | (null | undefined | string)
63
76
  | Readonly<{ from: string; as: string }>;
64
77
  treeshakeCompensation?: boolean;
65
- genConditionalClasses: boolean;
66
78
  unstable_moduleResolution?: null | undefined | ModuleResolution;
67
- aliases?:
68
- | null
69
- | undefined
70
- | Readonly<{ [$$Key$$: string]: string | ReadonlyArray<string> }>;
71
79
  }
72
80
  >;
73
81
  type StyleXStateOptions = Readonly<
@@ -81,6 +89,7 @@ type StyleXStateOptions = Readonly<
81
89
  | null
82
90
  | undefined
83
91
  | Readonly<{ [$$Key$$: string]: ReadonlyArray<string> }>;
92
+ rewriteAliases: boolean;
84
93
  })
85
94
  > & {
86
95
  runtimeInjection:
@@ -90,6 +99,7 @@ type StyleXStateOptions = Readonly<
90
99
  | null
91
100
  | undefined
92
101
  | Readonly<{ [$$Key$$: string]: ReadonlyArray<string> }>;
102
+ rewriteAliases: boolean;
93
103
  }
94
104
  >;
95
105
  declare class StateManager {
@@ -135,6 +145,8 @@ declare class StateManager {
135
145
  from: string,
136
146
  options: ImportAdditionOptions,
137
147
  ): t.Identifier;
148
+ get opts(): StyleXStateOptions;
149
+ get isDebug(): boolean;
138
150
  get isDev(): boolean;
139
151
  get isTest(): boolean;
140
152
  get filename(): string | void;
@@ -158,3 +170,13 @@ declare class StateManager {
158
170
  ): void;
159
171
  }
160
172
  export default StateManager;
173
+ export declare const filePathResolver: (
174
+ relativeFilePath: string,
175
+ sourceFilePath: string,
176
+ aliases: StyleXStateOptions['aliases'],
177
+ ) => null | undefined | string;
178
+ export declare const EXTENSIONS: any;
179
+ export declare const matchesFileSuffix: (
180
+ $$PARAM_0$$: string,
181
+ ) => ($$PARAM_0$$: string) => boolean;
182
+ export declare function getRelativePath(from: string, to: string): string;
@@ -42,14 +42,18 @@ type ModuleResolution =
42
42
 
43
43
  export type StyleXOptions = $ReadOnly<{
44
44
  ...RuntimeOptions,
45
+ aliases?: ?$ReadOnly<{ [string]: string | $ReadOnlyArray<string> }>,
46
+ enableDebugClassNames?: boolean,
47
+ enableDebugDataProp?: boolean,
48
+ enableDevClassNames?: boolean,
49
+ genConditionalClasses: boolean,
45
50
  importSources: $ReadOnlyArray<
46
51
  string | $ReadOnly<{ from: string, as: string }>,
47
52
  >,
53
+ rewriteAliases?: boolean,
48
54
  runtimeInjection: boolean | ?string | $ReadOnly<{ from: string, as: string }>,
49
55
  treeshakeCompensation?: boolean,
50
- genConditionalClasses: boolean,
51
56
  unstable_moduleResolution?: ?ModuleResolution,
52
- aliases?: ?$ReadOnly<{ [string]: string | $ReadOnlyArray<string> }>,
53
57
  ...
54
58
  }>;
55
59
 
@@ -57,6 +61,7 @@ type StyleXStateOptions = $ReadOnly<{
57
61
  ...StyleXOptions,
58
62
  runtimeInjection: ?string | $ReadOnly<{ from: string, as: ?string }>,
59
63
  aliases?: ?$ReadOnly<{ [string]: $ReadOnlyArray<string> }>,
64
+ rewriteAliases: boolean,
60
65
  ...
61
66
  }>;
62
67
 
@@ -98,6 +103,8 @@ declare export default class StateManager {
98
103
  from: string,
99
104
  options: ImportAdditionOptions,
100
105
  ): t.Identifier;
106
+ get opts(): StyleXStateOptions;
107
+ get isDebug(): boolean;
101
108
  get isDev(): boolean;
102
109
  get isTest(): boolean;
103
110
  get filename(): string | void;
@@ -120,3 +127,17 @@ declare export default class StateManager {
120
127
  memberExpression: [string, true | string, true | Array<string>],
121
128
  ): void;
122
129
  }
130
+
131
+ // a function that resolves the absolute path of a file when given the
132
+ // relative path of the file from the source file
133
+ declare export const filePathResolver: (
134
+ relativeFilePath: string,
135
+ sourceFilePath: string,
136
+ aliases: StyleXStateOptions['aliases'],
137
+ ) => ?string;
138
+
139
+ declare export const EXTENSIONS: $FlowFixMe;
140
+
141
+ declare export const matchesFileSuffix: (string) => (string) => boolean;
142
+
143
+ declare export function getRelativePath(from: string, to: string): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stylexjs/babel-plugin",
3
- "version": "0.10.1",
3
+ "version": "0.11.0",
4
4
  "description": "StyleX babel plugin.",
5
5
  "main": "lib/index.js",
6
6
  "repository": "https://github.com/facebook/stylex",
@@ -13,12 +13,12 @@
13
13
  "test": "jest"
14
14
  },
15
15
  "dependencies": {
16
- "@babel/helper-module-imports": "^7.22.15",
17
- "@stylexjs/shared": "0.10.1",
18
- "@stylexjs/stylex": "0.10.1",
19
- "@babel/core": "^7.25.8",
20
- "@babel/traverse": "^7.25.7",
21
- "@babel/types": "^7.25.8",
16
+ "@babel/helper-module-imports": "^7.25.9",
17
+ "@stylexjs/shared": "0.11.0",
18
+ "@stylexjs/stylex": "0.11.0",
19
+ "@babel/core": "^7.26.8",
20
+ "@babel/traverse": "^7.26.8",
21
+ "@babel/types": "^7.26.8",
22
22
  "@dual-bundle/import-meta-resolve": "^4.1.0"
23
23
  },
24
24
  "jest": {