@astryxdesign/build 0.7.0-canary.4ec1f4e → 0.7.0-canary.516c454

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/dist/vite.d.ts CHANGED
@@ -1,11 +1,9 @@
1
1
  import type { Plugin } from 'vite';
2
2
  import stylex from '@stylexjs/unplugin';
3
3
  /**
4
- * Browser targets matching Astryx's native `light-dark()` support floor.
5
- *
6
- * These are the source-build default so Lightning CSS preserves
7
- * `light-dark()` instead of lowering it into helper variables. Consumers may
8
- * supply a stricter supported floor when their product requires one.
4
+ * Browser targets for lightningcss (opt-in).
5
+ * Only needed if your StyleX version lowers light-dark() without them.
6
+ * Exported for consumers who want to opt in explicitly.
9
7
  */
10
8
  export declare const LIGHTNINGCSS_TARGETS: {
11
9
  chrome: number;
@@ -52,12 +50,10 @@ export interface AstryxVitePluginOptions {
52
50
  product?: string;
53
51
  };
54
52
  /**
55
- * Lightning CSS browser targets.
56
- *
57
- * Defaults to Astryx's native `light-dark()` support floor. Older targets
58
- * may lower `light-dark()` and are outside the supported theme contract.
59
- *
60
- * @default LIGHTNINGCSS_TARGETS
53
+ * LightningCSS browser targets. Only needed if your StyleX version
54
+ * lowers light-dark() without them. Most recent versions preserve
55
+ * light-dark() by default.
56
+ * @default undefined (no targets set)
61
57
  */
62
58
  lightningcssTargets?: Record<string, number>;
63
59
  /**
package/dist/vite.mjs CHANGED
@@ -26,13 +26,12 @@ function astryxStylex(options = {}) {
26
26
  rootDir = process.cwd(),
27
27
  libraryPattern = LIBRARY_PATTERN,
28
28
  layers = {},
29
- lightningcssTargets = LIGHTNINGCSS_TARGETS,
29
+ lightningcssTargets,
30
30
  stylexPrefix = "astryx",
31
31
  stylexOverrides = {}
32
32
  } = opts;
33
33
  const libraryLayer = layers.library ?? "astryx-base";
34
34
  const productLayer = layers.product ?? "product";
35
- const overrideLightningcssOptions = stylexOverrides.lightningcssOptions;
36
35
  const stylexOptions = {
37
36
  dev,
38
37
  runtimeInjection: false,
@@ -42,11 +41,10 @@ function astryxStylex(options = {}) {
42
41
  type: "commonJS",
43
42
  rootDir
44
43
  },
45
- ...stylexOverrides,
46
- lightningcssOptions: {
47
- targets: lightningcssTargets,
48
- ...overrideLightningcssOptions
49
- }
44
+ ...lightningcssTargets && {
45
+ lightningcssOptions: { targets: lightningcssTargets }
46
+ },
47
+ ...stylexOverrides
50
48
  };
51
49
  const astryxBabelPlugin = path.resolve(__dirname, "../src/babel.js");
52
50
  const basePlugin = stylex.vite({
@@ -307,14 +305,9 @@ function astryxStylexLegacy(options) {
307
305
  } = options;
308
306
  const libraryLayer = layers.library ?? "astryx-base";
309
307
  const productLayer = layers.product ?? "product";
310
- const legacyLightningcssOptions = stylexOptions.lightningcssOptions;
311
308
  const validatedStylexOptions = {
312
309
  propertyValidationMode: "throw",
313
- ...stylexOptions,
314
- lightningcssOptions: {
315
- targets: LIGHTNINGCSS_TARGETS,
316
- ...legacyLightningcssOptions
317
- }
310
+ ...stylexOptions
318
311
  };
319
312
  const astryxBabelPlugin = path.resolve(__dirname, "../src/babel.js");
320
313
  const existingPlugins = validatedStylexOptions.babelConfig?.plugins ?? [];
@@ -389,7 +382,7 @@ function astryxStylexLegacy(options) {
389
382
  libraryPattern,
390
383
  libraryLayer,
391
384
  productLayer,
392
- lightningcssOptions: validatedStylexOptions.lightningcssOptions
385
+ lightningcssOptions: stylexOptions?.lightningcssOptions
393
386
  })
394
387
  ];
395
388
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astryxdesign/build",
3
- "version": "0.7.0-canary.4ec1f4e",
3
+ "version": "0.7.0-canary.516c454",
4
4
  "description": "Build plugins for Astryx source builds — babel, PostCSS, and Vite integrations",
5
5
  "author": "Meta Open Source",
6
6
  "license": "MIT",
@@ -210,17 +210,6 @@ function itSplitsCorrectly(get: () => Built) {
210
210
  expect(get().css).toContain('-webkit-user-select');
211
211
  });
212
212
 
213
- // Source-built tokens must stay native at the same browser floor Astryx
214
- // documents. Lowering `light-dark()` here rewrites root variables through
215
- // mode helpers that exist only on Theme wrappers, so inherited data colors
216
- // become invalid before a theme can use them.
217
- it('preserves native light-dark() token values', () => {
218
- const {css} = get();
219
- expect(css).toContain('light-dark(');
220
- expect(css).not.toContain('--lightningcss-light');
221
- expect(css).not.toContain('--lightningcss-dark');
222
- });
223
-
224
213
  it('links the stylesheet from the page', () => {
225
214
  const {html, cssName} = get();
226
215
  expect(html).toContain(cssName);
package/src/vite.test.ts CHANGED
@@ -12,8 +12,7 @@ import {mkdtempSync, mkdirSync, rmSync} from 'node:fs';
12
12
  import {tmpdir} from 'node:os';
13
13
  import path from 'node:path';
14
14
  import {fileURLToPath, pathToFileURL} from 'node:url';
15
- import stylex from '@stylexjs/unplugin';
16
- import {astryxStylex, LIGHTNINGCSS_TARGETS} from './vite';
15
+ import {astryxStylex} from './vite';
17
16
 
18
17
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
19
18
 
@@ -74,44 +73,6 @@ describe('astryxStylex layer order (legacy API)', () => {
74
73
  });
75
74
  });
76
75
 
77
- describe('astryxStylex Lightning CSS defaults (modern API)', () => {
78
- type StylexOptions = {
79
- lightningcssOptions: {
80
- targets: Record<string, number>;
81
- drafts?: {nesting: boolean};
82
- };
83
- };
84
-
85
- function getStylexOptions(
86
- options: Parameters<typeof astryxStylex>[0] = {},
87
- ): StylexOptions {
88
- const vite = vi.spyOn(stylex, 'vite');
89
- try {
90
- astryxStylex(options);
91
- return vite.mock.calls.at(-1)?.[0] as StylexOptions;
92
- } finally {
93
- vite.mockRestore();
94
- }
95
- }
96
-
97
- it('preserves native light-dark() at the supported browser floor', () => {
98
- expect(getStylexOptions().lightningcssOptions.targets).toEqual(
99
- LIGHTNINGCSS_TARGETS,
100
- );
101
- });
102
-
103
- it('keeps the floor when a consumer supplies another Lightning CSS option', () => {
104
- const options = getStylexOptions({
105
- stylexOverrides: {lightningcssOptions: {drafts: {nesting: true}}},
106
- }).lightningcssOptions;
107
-
108
- expect(options).toEqual({
109
- targets: LIGHTNINGCSS_TARGETS,
110
- drafts: {nesting: true},
111
- });
112
- });
113
- });
114
-
115
76
  /**
116
77
  * A production build had no equivalent of the dev server's split-layer plugin,
117
78
  * so StyleX's `@layer priorityN` blocks sat outside the declared order and
package/src/vite.ts CHANGED
@@ -15,11 +15,9 @@ const LIBRARY_PATTERN = 'node_modules/@astryxdesign/';
15
15
  const STYLEX_CSS_PATH = '/virtual:stylex.css';
16
16
 
17
17
  /**
18
- * Browser targets matching Astryx's native `light-dark()` support floor.
19
- *
20
- * These are the source-build default so Lightning CSS preserves
21
- * `light-dark()` instead of lowering it into helper variables. Consumers may
22
- * supply a stricter supported floor when their product requires one.
18
+ * Browser targets for lightningcss (opt-in).
19
+ * Only needed if your StyleX version lowers light-dark() without them.
20
+ * Exported for consumers who want to opt in explicitly.
23
21
  */
24
22
  export const LIGHTNINGCSS_TARGETS = {
25
23
  chrome: 123 << 16,
@@ -72,12 +70,10 @@ export interface AstryxVitePluginOptions {
72
70
  };
73
71
 
74
72
  /**
75
- * Lightning CSS browser targets.
76
- *
77
- * Defaults to Astryx's native `light-dark()` support floor. Older targets
78
- * may lower `light-dark()` and are outside the supported theme contract.
79
- *
80
- * @default LIGHTNINGCSS_TARGETS
73
+ * LightningCSS browser targets. Only needed if your StyleX version
74
+ * lowers light-dark() without them. Most recent versions preserve
75
+ * light-dark() by default.
76
+ * @default undefined (no targets set)
81
77
  */
82
78
  lightningcssTargets?: Record<string, number>;
83
79
 
@@ -129,7 +125,7 @@ export function astryxStylex(
129
125
  rootDir = process.cwd(),
130
126
  libraryPattern = LIBRARY_PATTERN,
131
127
  layers = {},
132
- lightningcssTargets = LIGHTNINGCSS_TARGETS,
128
+ lightningcssTargets,
133
129
  stylexPrefix = 'astryx',
134
130
  stylexOverrides = {},
135
131
  } = opts;
@@ -137,13 +133,7 @@ export function astryxStylex(
137
133
  const libraryLayer = layers.library ?? 'astryx-base';
138
134
  const productLayer = layers.product ?? 'product';
139
135
 
140
- const overrideLightningcssOptions = (
141
- stylexOverrides as {lightningcssOptions?: Record<string, unknown>}
142
- ).lightningcssOptions;
143
-
144
- // Build StyleX options with sensible defaults. Merge Lightning CSS options
145
- // separately so an unrelated override cannot silently discard the browser
146
- // floor that keeps theme values native.
136
+ // Build StyleX options with sensible defaults
147
137
  const stylexOptions: Record<string, unknown> = {
148
138
  dev,
149
139
  runtimeInjection: false,
@@ -153,11 +143,10 @@ export function astryxStylex(
153
143
  type: 'commonJS',
154
144
  rootDir,
155
145
  },
146
+ ...(lightningcssTargets && {
147
+ lightningcssOptions: {targets: lightningcssTargets},
148
+ }),
156
149
  ...stylexOverrides,
157
- lightningcssOptions: {
158
- targets: lightningcssTargets,
159
- ...overrideLightningcssOptions,
160
- },
161
150
  };
162
151
 
163
152
  // Inject our babel wrapper as a user plugin — it runs before the
@@ -581,16 +570,9 @@ function astryxStylexLegacy(options: AstryxVitePluginLegacyOptions): Plugin[] {
581
570
  const libraryLayer = layers.library ?? 'astryx-base';
582
571
  const productLayer = layers.product ?? 'product';
583
572
 
584
- const legacyLightningcssOptions = (
585
- stylexOptions as {lightningcssOptions?: Record<string, unknown>}
586
- ).lightningcssOptions;
587
573
  const validatedStylexOptions = {
588
574
  propertyValidationMode: 'throw',
589
575
  ...(stylexOptions as any),
590
- lightningcssOptions: {
591
- targets: LIGHTNINGCSS_TARGETS,
592
- ...legacyLightningcssOptions,
593
- },
594
576
  };
595
577
  const astryxBabelPlugin = path.resolve(__dirname, 'babel.js');
596
578
  const existingPlugins = validatedStylexOptions.babelConfig?.plugins ?? [];
@@ -674,9 +656,8 @@ function astryxStylexLegacy(options: AstryxVitePluginLegacyOptions): Plugin[] {
674
656
  libraryPattern,
675
657
  libraryLayer,
676
658
  productLayer,
677
- lightningcssOptions: (
678
- validatedStylexOptions as {lightningcssOptions?: unknown}
679
- ).lightningcssOptions,
659
+ lightningcssOptions: (stylexOptions as {lightningcssOptions?: unknown})
660
+ ?.lightningcssOptions,
680
661
  }),
681
662
  ];
682
663
  }