@astryxdesign/build 0.7.17-canary.gffd1fc0 → 0.7.17

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.mjs CHANGED
@@ -37,6 +37,12 @@ function isSwizzledSource(filePath, memo) {
37
37
  return markerReader.isSwizzledSource(filePath, memo);
38
38
  }
39
39
  var LIBRARY_PATTERN = "node_modules/@astryxdesign/";
40
+ function corePrebuiltStylesheet() {
41
+ const { PREBUILT_STYLESHEETS } = createRequire(import.meta.url)(
42
+ path.resolve(__dirname, "../src/source-stylesheet.js")
43
+ );
44
+ return PREBUILT_STYLESHEETS["@astryxdesign/core"];
45
+ }
40
46
  var STYLEX_CSS_PATH = "/virtual:stylex.css";
41
47
  var LIGHTNINGCSS_TARGETS = {
42
48
  chrome: 123 << 16,
@@ -124,9 +130,14 @@ function astryxStylex(options = {}) {
124
130
  "node_modules/@astryxdesign/core"
125
131
  );
126
132
  const coreSourceDir = path.join(corePackageDir, "src");
133
+ const prebuiltAlias = {
134
+ find: `@astryxdesign/core/${corePrebuiltStylesheet().slice(2)}`,
135
+ replacement: path.resolve(__dirname, "../src/replaced-stylesheet.css")
136
+ };
127
137
  return {
128
138
  resolve: {
129
139
  alias: [
140
+ prebuiltAlias,
130
141
  {
131
142
  find: /^@astryxdesign\/core\/locales\/(.+)\.generated\.js$/,
132
143
  replacement: path.join(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astryxdesign/build",
3
- "version": "0.7.17-canary.gffd1fc0",
3
+ "version": "0.7.17",
4
4
  "description": "Build plugins for Astryx source builds — babel, PostCSS, and Vite integrations",
5
5
  "author": "Meta Open Source",
6
6
  "license": "MIT",
@@ -0,0 +1,7 @@
1
+ /* Copyright (c) Meta Platforms, Inc. and affiliates. */
2
+
3
+ /*
4
+ * What a Vite source build loads for Core's prebuilt stylesheet. StyleX
5
+ * compiles Core's rules from its source, so a second copy would duplicate
6
+ * them; this file holds no rules.
7
+ */
@@ -412,31 +412,13 @@ async function compileRules(file, options) {
412
412
  /** The cascade-layer order every Astryx stylesheet registers before its rules. */
413
413
  const LAYER_ORDER = '@layer reset, astryx-base, astryx-theme;';
414
414
 
415
- /**
416
- * The one block Core's stylesheet carries outside `astryx-base`
417
- * (spec:AST-080 FR3): with no forced mode on the root, the page root follows
418
- * the reader's light or dark preference without `reset.css`. It is
419
- * `reset.css`'s own rule for that case, so either file can load last. A
420
- * `system` Theme takes the root's scheme (component:Theme FR2). Zero
421
- * specificity in the lowest layer, so a host or an app that sets the root's
422
- * scheme wins.
423
- */
424
- const CORE_ROOT_BLOCK =
425
- '@layer reset {\n :where(html:not([data-theme])) {\n color-scheme: light dark;\n }\n}';
426
-
427
- /**
428
- * A stylesheet's block: the layer order, then `css` inside `@layer astryx-base`.
429
- * Core's begins with its root block.
430
- * @param {string} css
431
- * @param {{core?: boolean}} [options]
432
- */
433
- function layerBlock(css, {core = false} = {}) {
415
+ /** A stylesheet's block: the layer order, then `css` inside `@layer astryx-base`. */
416
+ function layerBlock(css) {
434
417
  const body = css
435
418
  .split('\n')
436
419
  .map(line => ` ${line}`)
437
420
  .join('\n');
438
- const root = core ? `${CORE_ROOT_BLOCK}\n\n` : '';
439
- return `${LAYER_ORDER}\n\n${root}@layer astryx-base {\n${body}\n}\n`;
421
+ return `${LAYER_ORDER}\n\n@layer astryx-base {\n${body}\n}\n`;
440
422
  }
441
423
 
442
424
  /** StyleX's CSS for `rules`, from the copy of StyleX that compiled them. */
@@ -449,9 +431,9 @@ function processRules(rules) {
449
431
  * when there are no rules. Each block carries the order, so the order holds
450
432
  * whichever block or chunk loads first. The product needs no line of its own.
451
433
  */
452
- function renderPackage(rules, options) {
434
+ function renderPackage(rules) {
453
435
  const css = processRules(rules);
454
- return css.trim() ? layerBlock(css, options) : '';
436
+ return css.trim() ? layerBlock(css) : '';
455
437
  }
456
438
 
457
439
  /**
@@ -469,7 +451,7 @@ async function sourceStylesheet({cwd}) {
469
451
  if (pkg.name === CORE) {
470
452
  provided = new Set([...modules].filter(file => STYLEX_MODULE.test(file)));
471
453
  }
472
- blocks.push(renderPackage(rules, {core: pkg.name === CORE}));
454
+ blocks.push(renderPackage(rules));
473
455
  }
474
456
  return {css: blocks.filter(Boolean).join('\n'), packages};
475
457
  }
@@ -482,7 +464,6 @@ module.exports = {
482
464
  STYLEX_ENTRIES,
483
465
  STYLEX_MODULE,
484
466
  LAYER_ORDER,
485
- CORE_ROOT_BLOCK,
486
467
  prebuiltStylesheet,
487
468
  findPackageDir,
488
469
  sourcePackages,
package/src/vite.ts CHANGED
@@ -22,6 +22,18 @@ function isSwizzledSource(filePath: string, memo: Map<string, boolean>) {
22
22
  }
23
23
 
24
24
  const LIBRARY_PATTERN = 'node_modules/@astryxdesign/';
25
+
26
+ /**
27
+ * Core's prebuilt stylesheet export, as the PostCSS integration names it
28
+ * (`./astryx.css`), read from beside babel.js like the marker reader.
29
+ */
30
+ function corePrebuiltStylesheet(): string {
31
+ const {PREBUILT_STYLESHEETS} = createRequire(import.meta.url)(
32
+ path.resolve(__dirname, 'source-stylesheet.js'),
33
+ ) as {PREBUILT_STYLESHEETS: Record<string, string>};
34
+ return PREBUILT_STYLESHEETS['@astryxdesign/core'];
35
+ }
36
+
25
37
  const STYLEX_CSS_PATH = '/virtual:stylex.css';
26
38
 
27
39
  /**
@@ -236,10 +248,20 @@ export function astryxStylex(
236
248
  'node_modules/@astryxdesign/core',
237
249
  );
238
250
  const coreSourceDir = path.join(corePackageDir, 'src');
251
+ // StyleX compiles Core's rules from source. The prebuilt
252
+ // `astryx.css` holds a second copy of them, so its import loads an
253
+ // empty stylesheet. A real file serves a CSS `@import` too, which
254
+ // Vite reads from disk. The package-wide alias below maps the other
255
+ // stylesheets (`reset.css`) to their files in `src`.
256
+ const prebuiltAlias = {
257
+ find: `@astryxdesign/core/${corePrebuiltStylesheet().slice(2)}`,
258
+ replacement: path.resolve(__dirname, 'replaced-stylesheet.css'),
259
+ };
239
260
 
240
261
  return {
241
262
  resolve: {
242
263
  alias: [
264
+ prebuiltAlias,
243
265
  {
244
266
  find: /^@astryxdesign\/core\/locales\/(.+)\.generated\.js$/,
245
267
  replacement: path.join(