Skip to content

feat(build): build Astryx from source under Turbopack - #7754

Merged
cixzhang merged 1 commit into
meta:mainfrom
vjeux:build-next-turbopack
Nov 2, 2026
Merged

cixzhang merged 1 commit into
meta:mainfrom
vjeux:build-next-turbopack

Conversation

@vjeux

@vjeux vjeux commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

User need

A Next.js 16 app that wants AST-080's source build (only the CSS it uses) can't have it under Turbopack, Next.js 16's default bundler.

Problem and solution fit

withAstryx() configured only nextConfig.webpack, which Turbopack never calls. Under Turbopack it now aliases Core, Lab, Charts and Rich Text to their source, compiles it as the prebuilt stylesheets are compiled, and keeps the app's rules off it. @astryxdesign/build/next/postcss replaces the app stylesheet's @astryx; with each package's prebuilt stylesheet compiled from that source.

Current specification

spec:AST-080 FR9 and DEC-6 (Turbopack source builds through a loader; the fast path is a known gap) and FR7 (prebuilt rules in order). This PR adds FR9's stylesheet-entry rule for @astryxdesign/build/next/postcss, records the Turbopack build and the webpack gaps in the present tense, and adds a path-applicability block. It needs an engineering owner's /approve-spec at this head.

Public delta and caller burden

  • Under Turbopack, withAstryx() returns merged transpilePackages, turbopack.resolveAlias and turbopack.rules. Under webpack nothing changes.
  • New export @astryxdesign/build/next/postcss (option cwd): list it in the PostCSS config, with one @astryx; in the global stylesheet.
  • Importing a source-built package's prebuilt stylesheet fails.
  • Under Turbopack, @astryxdesign/build/postcss throws beside withAstryx(), instead of building unstyled.
  • A malformed installed package.json fails the source build instead of being left out.

Design and alternatives

  • Webpack only: loses the default bundler.
  • Published CSS with app-only StyleX (Migrate Next source example to precompiled Astryx CSS #6841): never source-builds Astryx.
  • StyleX's PostCSS plugin: one option set per app, so Astryx misses the published rules.
  • Chosen: this source build, the one route with the published rules (FR7).
  • source-stylesheet.js repeats scripts/build-css.mjs's module walk, compile options and layer wrapper. Routing every published stylesheet through it is a separate change with its own byte-identity check. Meanwhile the parity test fails on any drift, byte for byte, for all four packages.

Evidence

Speed, median of 5 runs, prebuilt → source, under other load: next build 16.0 → 25.2 s, next dev cold start 12.6 → 25.5 s, hot update 0.16 → 0.54 s. The loader ran 1,485 times on 742 files; packages/build/scripts/turbopack-speed.mjs repeats it.

Writing rubric results

  • R1 narration: the webpack gap line named a release; now present tense. So is the new FR9 rule.
  • R2 research: none; the speed figures stay here.
  • R3 evidence: no cell changed.
  • R4 rejected alternatives: none added.
  • R5 change references: none.
  • R6 open questions: none touched.

Scope

  • One capability is added.
  • Unrelated fixes, cleanup, and policy changes were removed or split.
  • Consumer docs, focused tests, and migration evidence ship with the feature.
  • Public text and artifacts contain no internal Meta context.

Testing

  • pnpm exec vitest run --project node packages/build: unit and parity tests, including a source build of every Core, Lab, Charts and Rich Text module that prints each prebuilt stylesheet byte for byte.
  • pnpm test:build runs ASTRYX_TURBOPACK_E2E=1 vitest run packages/build/src/next.turbopack.test.mjs --project node --maxWorkers=1 on the Build package's CI job. It builds a Next.js app with Core linked and Lab, Charts and Rich Text installed, every installed prebuilt stylesheet deleted. In Chromium, served and under next dev, per package the product's class and StyleX rule beat the base, and a theme beats the base in either load order, also with the page's stylesheet chunks reversed. Importing a prebuilt stylesheet fails the build, and an app with Core alone keeps Core's data colours. Each check fails without its fix.
  • Local gates at 1c496ae: pnpm test:build 0 (Turbopack check 10 of 10); pnpm exec vitest run --project node 858 files, 16,022 tests passed; the CI routing test 31 of 31; api:report --check, check:knowledge, check:repo and Prettier 0; ASTRYX_STRICT_LINT=1 pnpm lint 0 errors. The comment-provenance baseline --check fails on main itself (stale entries for Item, Token, ChatComposer and layerSurfacePress); this PR touches no entry.

@vercel

vercel Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 2, 2026 9:57pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 20, 2026
@github-actions github-actions Bot added the needs:design-review Affects visuals — Design should review label Oct 20, 2026
@astracat-bot

astracat-bot Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 2, 2026, 10:04 PM UTC

@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 1c496ae

Storybook · Sandbox · built from this PR's head

Package size: @astryxdesign/build 31.6 kB packed (+7.0 kB) 🔴; no new dependencies.

API changes: build +1 · ~1 · −0

Committed API report behind this build: core 18 rows; run pnpm api:report.

2 API changes (advisory)
Package Where Signature Usage
+ build ./next/postcss · Values · module.exports module.exports import {module.exports} from '@astryxdesign/build/next/postcss'
~ build ./next · Functions · function withAstryx function withAstryx: (nextConfig?: {}) => { transpilePackages: any[]; webpack: (config: any, context: any) => any } → function withAstryx: (nextConfig?: {}) => { transpilePackages: any[]; turbopack: {} } | { transpilePackages: any[]; webpack: (config: any, context: any) => any } import {withAstryx} from '@astryxdesign/build/next'; withAstryx(…)

Not run on this PR: add ci:run-visual, ci:run-a11y or ci:run-rtl to run them.


Generated by PR Enrichment workflow | View full report

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Core output matches astryx.css byte for byte and the Turbopack fixture builds correctly with Core installed in node_modules, but approval waits on a maintainer decision. spec:AST-080 leaves bundler wiring and module selection out of scope, so a maintainer needs to provide or identify the governing spec for Turbopack support in withAstryx() (including the condition it adds to the app's own turbopack.rules), the new @astryxdesign/build/next/postcss export with @astryx;, include and cwd, and how a source build picks its modules. Independently of that decision, please fix:

  • With Core workspace-linked (a monorepo package, pnpm link or file:), the fixture still builds, but every Astryx class takes the app's StyleX prefix and has no rule, because the loader glob and the keep-off condition in next.js match only unresolved node_modules paths.
  • With @astryxdesign/lab installed, @astryx; throws on Lab's CodeEditor because stylexOptions() adds propertyValidationMode: 'throw', which the prebuilt build does not use; without it, Lab compiles to lab.css byte for byte.
  • The include default is documented as every source file but skips .mdx, and FR7's development-build and theme-override states have no test.

[Automated review]

Comment thread packages/build/src/next.js Outdated
Comment on lines +270 to +286
const escaped = packages.map(pkg =>
sourcePath(pkg).replace(/[.*+?^${}()|[\]\\]/g, '\\$&'),
);
const astryxSource = {
path: new RegExp(`(^|/)node_modules/(${escaped.join('|')})/`),
};
const rules = {};
for (const [glob, collection] of Object.entries(turbopack.rules || {})) {
rules[glob] = keepOffAstryx(collection, astryxSource);
}
for (const pkg of packages) {
rules[`**/node_modules/${sourcePath(pkg)}/**/*.{ts,tsx}`] = {
loaders: [
{loader: TURBOPACK_LOADER, options: stylexOptions(pkg, packages)},
],
as: '*',
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The loader glob and the keep-off condition are built from the unresolved node_modules path that findPackageDir() returns, but Turbopack matches rules against the resolved file. With Core workspace-linked (a monorepo package, pnpm link, file:), the resolved path is packages/core/src/…, so Astryx is compiled with the app's StyleX options (its *.tsx rule or Babel config) instead: the fixture builds with no warning, yet all 58 Astryx classes come out p… with no rule. Deriving both patterns from fs.realpathSync(pkg.srcDir) as well, or refusing when a package resolves outside node_modules, plus a linked-layout case in next.turbopack.test.mjs, would close it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 86ab34b. Each package's rule now also matches its resolved path, taken from the closest directory that holds both the app and the package's real source (packages/core/src for a workspace link), next to the unresolved node_modules path. The condition that keeps caller rules off Astryx uses the same patterns, and the Astryx rules share one *.{ts,tsx} key, so a caller rule under that key is merged, not replaced.

The e2e fixture now links Core from outside node_modules (its app loader refuses any linked or installed Astryx file) and checks that every Astryx class is x… with a rule; on the previous head the app's *.tsx rule reached that Core (312 build errors). A unit test covers a monorepo layout.

Comment thread packages/build/src/source-stylesheet.js Outdated
return {
dev: false,
runtimeInjection: false,
propertyValidationMode: 'throw',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scripts/build-css.mjs does not set propertyValidationMode, so this option makes the source build stricter than the prebuilt one. Because sourceStylesheet() compiles every module of every installed source package, an app with @astryxdesign/lab installed fails on CodeEditor.tsx ("border is not supported") even if it imports only Core's Button. Without this line the Lab every-module compile equals lab.css byte for byte; a Lab parity test beside Core's would keep it that way.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 86ab34b: stylexOptions() no longer sets propertyValidationMode, matching scripts/build-css.mjs. A parity test now compiles every Lab module and compares the result with lab.css as build-css.mjs builds it, byte for byte (Core likewise against astryx.css); on the previous head it fails on CodeEditor's border. The e2e fixture installs Lab and renders a Lab Stat.

Comment thread packages/build/README.md Outdated
Comment on lines +74 to +75
`include` takes globs of the files whose Astryx imports count; the default is
every source file outside `node_modules` and `.next`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default glob is **/*.{js,jsx,mjs,cjs,ts,tsx}, so .mdx pages are not covered: a component used only in MDX gets no rules, and adding **/*.mdx to include throws a parse error. Saying "JS and TS files" here and in next-postcss.js (or reading MDX imports) would match the behavior.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 86ab34b: the default include now covers .mdx (the plugin reads the import and export statements in an MDX file's ESM blocks), documented as JS, TS and MDX files outside node_modules and .next, with a test.

For FR7's states, next.turbopack.test.mjs now also runs next dev on the fixture, and checks in Chromium that a theme override in @layer astryx-theme beats the source-built rules whichever stylesheet loads first. The test-node job installs Chromium before the Node suite so that check runs in CI.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

include and its .mdx default moved to the follow-up with module selection (vjeux:build-next-source-subset), along with the tests for them. This PR no longer reads the app's files. The development-build and theme-override tests stay here.

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workspace-link and Lab fixes work, MDX imports are now read, and the new Turbopack tests pass, but approval still waits on a maintainer decision: spec:AST-080 leaves bundler wiring and module selection out of scope, so a maintainer needs to provide or identify the governing spec for Turbopack support in withAstryx() (including the condition it adds to the app's own turbopack.rules), the @astryxdesign/build/next/postcss export with @astryx;, include and cwd, and how a source build picks its modules. Independently of that decision, please fix:

  • With the README's default include and an Astryx package linked from a pnpm workspace, next build runs out of memory: the dir-dependency glob reported at source-stylesheet.js:711 lets Turbopack walk node_modules and its symlinks, while include: ['src/**/*.{ts,tsx}'] builds the same app in 17 s.
  • An .mdx file whose code example has a blank line before export, or a .ts file with an angle-bracket assertion, stops next build with a parse error (source-stylesheet.js:365-378).
  • Nothing tests the default include or FR7's "Core source-built beside a prebuilt Lab stylesheet" state.

[Automated review]

Comment thread packages/build/src/source-stylesheet.js Outdated
*/
async function sourceStylesheet({cwd, include = [CODE_GLOB]}) {
const packages = sourcePackages(cwd);
const watch = include.map(glob => ({dir: cwd, glob}));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the default include, this reports {dir: cwd, glob: '**/*.{js,jsx,mjs,cjs,ts,tsx,mdx}'} as a dir-dependency, and the IGNORE list doesn't travel with it, so Turbopack tracks the glob through the app's node_modules and follows its symlinks. With Core linked from this repository's workspace (packages/core/node_modules/@astryxdesign/cli links back to Core through packages/cli), the README's setup made next build pass 14 GiB in 15 s (76.9 GB before the kernel killed it when unguarded); with include: ['src/**/*.{ts,tsx}'] the same app builds in 17 s. Reporting only globs that can't reach node_modules or .next (for example one dir-dependency per top-level entry of the app other than those), plus a fixture build with the default include and a linked package that has its own node_modules, would close it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 6f07dd5. The plugin now reports only globs that can't reach node_modules, a dot directory such as .next, or a symlink. It walks each include pattern from its static directory: a tree with none of those gets one deep glob, and any other directory gets a glob for its own files plus the globs of each subtree.

A unit test checks the exact globs for an app with node_modules, .next, a nested node_modules and a symlinked directory; it fails on the previous head. The Turbopack fixture now uses the default include, with Core linked from outside the app with its own node_modules, and builds and serves under next dev.

On the review's last point: that fixture build is the default-include test, and a new compile test covers FR7's "Core source-built beside a prebuilt Lab stylesheet" state: a Core build of a one-component app defines every Core variable and keyframes that lab.css uses.

One limit found along the way, now in the README: in next dev, Turbopack re-runs PostCSS only for changes inside the app (a dependency on a linked package's source, by real path or through node_modules, never fires), so a linked package's rules refresh when next dev restarts. The previous head registered no such dependency either.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The app's watch globs moved to the follow-up with include (vjeux:build-next-source-subset), along with this test. This PR's output depends on no app file. It registers one dependency per source-built package, on that package's source, so an upgrade rebuilds the stylesheet under Turbopack's persistent cache.

Comment thread packages/build/src/source-stylesheet.js Outdated
Comment on lines +365 to +378
if (file.endsWith('.mdx')) {
// MDX keeps imports and exports in top-level ESM blocks; a blank line ends one.
code = code
.split(/\n[ \t]*\n/)
.filter(block => /^(import|export)\b/.test(block.trimStart()))
.join('\n\n');
}
const ast = babel().parseSync(code, {
filename: file,
babelrc: false,
configFile: false,
sourceType: 'unambiguous',
parserOpts: {
plugins: /\.[cm]?tsx?$/.test(file) ? ['typescript', 'jsx'] : ['jsx'],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two inputs a Next.js app can hold make this parse throw, and the error stops next build: an .mdx page whose fenced example has a blank line before export default function … (the kept block ends with the closing fence, which Babel reads as a template literal: "Unterminated template"), and a .ts file with an angle-bracket assertion such as <HTMLElement>document.body, which the jsx plugin rejects ("Unterminated JSX contents"). Skipping fenced code when collecting MDX's ESM blocks and enabling jsx only for .tsx, .jsx, .js and MDX would fix both; a test for each would keep it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 6f07dd5. MDX's ESM blocks are now collected outside fenced code, and jsx is enabled only where JSX can appear (.tsx, JavaScript and MDX), so <HTMLElement>document.body parses in a .ts file.

A file the parser still can't read no longer stops the build either: the plugin warns and keeps every module the file names, whole, so no import it really has is dropped. Tests cover both inputs and the fallback; on the previous head the three inputs throw Unterminated template, Unterminated JSX contents and Unexpected token.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parsing the app's files moved to the follow-up with module selection (vjeux:build-next-source-subset). The MDX, .ts and unparseable-file handling and their tests moved with it. This PR never parses app files.

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The earlier memory, MDX and TypeScript-parse problems are fixed and the Turbopack tests pass, but approval waits on a maintainer decision: spec:AST-080 leaves how @astryxdesign/build plugs into each bundler and how a source build picks its modules out of scope, so a maintainer needs to provide or identify the governing spec for Turbopack support in withAstryx() (including the condition it adds to the app's own turbopack.rules), the @astryxdesign/build/next/postcss export with @astryx;, include and cwd, and import-based module selection. Independently of that decision, please fix two things:

  • In a turbopack.rules list that mixes bare loaders with rule objects, keepOffAstryx() leaves the bare loaders running on Astryx source (packages/build/src/next.js:244), although the README says the app's own rules are kept off it.
  • The new "Install Playwright for the Node suite's browser checks" step in test-node needs the same tooling_only != 'true' guard as the theme-family step below it, so the node-tooling lane keeps skipping browser work.

[Automated review]

Comment thread packages/build/src/next.js Outdated
if (!collection.some(isRule)) {
return [exclude({loaders: collection})];
}
return collection.map(item => (isRule(item) ? exclude(item) : item));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a list that mixes bare loaders with rule objects, the bare items come back unchanged, and Turbopack runs them on every matching file: with '*.tsx': [{loader: probe}, {loaders: [probe], condition: {not: 'foreign'}}] wrapped in withAstryx(), the bare loader ran on 528 Astryx source files and the rule object on none. Wrapping each bare item (or each run of consecutive bare items) in exclude({loaders: [item]}) would keep the README's promise that the app's own rules stay off Astryx source, and the mixed shape could join the "in every rule shape" test in next.test.mjs.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in bc71a0e. Next.js turns each bare loader in a list into a rule of its own, with no condition, and applies matching rules in list order. keepOffAstryx() now does the same split, wrapping each bare loader in place as {loaders: [item]} with the keep-off condition. The order on app files is therefore Next's own.

This also fixed a second bug: for a list of only bare loaders, the previous head merged them into one rule, which ran them in reverse (b, a where Next runs a, b).

Tests:

  • The "every rule shape" test now covers a mixed list and a two-loader bare list, and checks the whole returned config against Next's own config schema.
  • The fixture's *.tsx rule is now a mixed list: two bare loaders around the app's StyleX rule object. Each loader logs the files it runs on and refuses Astryx source. The test asserts they run a, stylex, b on page.tsx and only on the app's files.
  • On 6f07dd5 that build fails (the bare loader reaches Lab's Stat.tsx), and the unit test fails too.

Against the same app without withAstryx(), both lists run in the same order: a, stylex, b and a, b.

Comment thread .github/workflows/ci.yml Outdated

# The Build package's Next.js suite checks a theme override in Chromium.
- name: Install Playwright for the Node suite's browser checks
if: needs.check-scope.outputs.docsite_only != 'true' && needs.check-scope.outputs.spec_only != 'true'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This step lacks the needs.check-scope.outputs.tooling_only != 'true' guard that the theme-family Chromium step below carries, so a pull request that only touches admitted Node tooling now downloads Chromium and runs the theme-override browser check, which spec:AST-030 FR8 says that lane skips. Adding the guard lets it.skipIf(!hasChromium) skip the check there.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in bc71a0e: the step now carries the same tooling_only != 'true' guard as the theme-family steps below it. In the tooling-only lane it.skipIf(!hasChromium) skips the browser check, and the CI workflow tests pass.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebased in 0ef2281 past #7705, which splits test-node into four Vitest --shard legs. The step keeps both guards and now runs in every leg. --shard decides which leg runs the Build suite, and its Chromium check skips wherever Chromium is missing, so installing Chromium in one leg alone could skip the check without notice.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a92978d the install step also sets ASTRYX_REQUIRE_CHROMIUM for the rest of the leg, and the Turbopack test skips its Chromium check only when that variable is unset. In CI, a missing browser now fails the check instead of skipping it. Local runs, and deploy.yml's push gate, which installs no Chromium, skip as before.

The install costs 12–13 s per leg, and the legs run in parallel. Running the check once in leg 1 instead would mean changing ci-test-routing's contract, which allows one unsharded step in a sharded lane: the FR23 benchmark.

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The earlier mixed-rule-list and CI-guard problems are fixed, and the Turbopack build, next dev and the Core and Lab parity tests pass, but approval waits on a maintainer decision. spec:AST-080 leaves how @astryxdesign/build plugs into each bundler and how a source build picks its modules out of scope, so a maintainer needs to provide or identify the governing spec for Turbopack support in withAstryx() (including the condition it adds to the app's own turbopack.rules), the @astryxdesign/build/next/postcss export with @astryx;, include and cwd, and import-based module selection. Beyond that decision, one optional README suggestion is inline.

[Automated review]

Comment thread packages/build/README.md Outdated
`include` takes globs of the files whose Astryx imports count; the default is
every JS, TS and MDX file outside `node_modules` and `.next`.

3. Your global stylesheet, with `@astryx;` in place of `astryx.css`:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: when the app imports Lab, @astryx; also prints Lab's rules, while Rich Text and Charts are not source-built and keep their prebuilt stylesheets. Saying so here (in place of astryx.css and lab.css; keep richtext.css and charts.css) would keep a Lab user from loading Lab's rules twice, matching how spec:AST-080 FR5 describes a source build replacing each source-built package's stylesheet.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 9d6fcad. I checked the list first. Only packages in withAstryx()'s list whose root export carries a source entry are built from source. With Core, Lab, Rich Text, Charts and the neutral theme all installed, that is Core and Lab: those two get the source aliases and loader rules. The neutral theme is in the list but ships no source entry. Rich Text and Charts resolve to their published files.

Step 3 now says @astryx; replaces astryx.css and lab.css, and that any richtext.css or charts.css import stays.

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Turbopack build, next dev and the Core and Lab parity tests pass, and a Turbopack build of the fixture renders the same pixels with @astryx; as with the prebuilt stylesheets, but approval waits on a maintainer decision. spec:AST-080 leaves how @astryxdesign/build plugs into each bundler and how a source build picks its modules out of scope, so a maintainer needs to provide or identify the governing spec for Turbopack support in withAstryx() (including the condition it adds to the app's own turbopack.rules), the @astryxdesign/build/next/postcss export with @astryx;, include and cwd, and import-based module selection. One optional test suggestion is inline.

[Automated review]

),
);
}
expect(colors[0]).not.toBe('rgb(0, 120, 255)');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional: this assertion passes even though the Button's own colors never resolve here. The fixture's globals.css loads no reset.css, so nothing declares color-scheme, and Turbopack lowers each light-dark() value to --lightningcss-light/--lightningcss-dark fallbacks that nothing sets: in the built page --color-error computes to #e3193b#f5394f, and the destructive Button has a transparent background with black text. Importing @astryxdesign/core/reset.css in the fixture, as README step 3 does, and expecting rgb(227, 25, 59) here would let the check prove the source-built color as well as the layer order.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in b4d580f. The fixture's globals.css now imports @astryxdesign/core/reset.css, as README step 3 does. The check now expects the destructive Button's source-built background, rgb(227, 25, 59), without the override, and rgb(0, 120, 255) with it, in both orders.

It fails in both directions:

  • With the override removed, all three cases compute rgb(227, 25, 59).
  • With reset.css removed, the Button computes rgba(0, 0, 0, 0).

Step 3's theme import is still played by the stylesheet the test injects. The Node suite builds Core but no theme package, so there's no built theme.css to load.

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This now builds and renders correctly under Turbopack: the parity, next build, next dev and Chromium cascade tests pass (the cascade test now loads reset.css and checks the source-built color), and the fixture renders identically with @astryx; and with the prebuilt stylesheets. Approval still needs a maintainer decision, because spec:AST-080 leaves bundler integration and source-build module selection out of scope: a maintainer must provide or identify the spec covering Turbopack support in withAstryx() (including the condition it adds to the app's own turbopack.rules), the @astryxdesign/build/next/postcss export with @astryx;, include and cwd, and import-based module selection. There is nothing further for you to change before that decision.

[Automated review]

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approval waits on an engineering owner's decision: spec:AST-080 governs the CSS a source build emits, and this head meets it, but its Non-goals leave how @astryxdesign/build plugs into each bundler out of scope. The governing spec needs to be provided or identified for withAstryx()'s Turbopack configuration (its aliases, loader rules and the condition it adds to the app's own turbopack.rules), the new @astryxdesign/build/next/postcss export with @astryx; and cwd, and the refusal added to @astryxdesign/build/postcss, including whether this direction stands beside #6841. Any engineering owner, the author included, can record that decision by commenting /approve-spec followed by the full head SHA. Independently, the real Turbopack build test now runs only with ASTRYX_TURBOPACK_E2E=1, which no CI step sets, while spec:AST-030 FR11 puts the Build package's CSS-layer cascade checks in its test owner: adding it to pnpm test:build, beside the ASTRYX_STYLEX_BROWSER=1 check, keeps it running on that job's own runner without slowing test-node.

[Automated review]

@vjeux
vjeux marked this pull request as draft October 29, 2026 22:45
@vjeux
vjeux marked this pull request as ready for review October 30, 2026 00:00

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approval waits on an engineering owner's decision: spec:AST-080 governs the CSS a source build emits, and this head meets it, but its Non-goals leave how @astryxdesign/build plugs into each bundler out of scope. The governing spec needs to be provided or identified for withAstryx()'s Turbopack configuration (its aliases, loader rules and the condition it adds to the app's own turbopack.rules), the new @astryxdesign/build/next/postcss export with @astryx; and cwd, and the refusal added to @astryxdesign/build/postcss, including whether this direction stands beside #6841. Any engineering owner, the author included, can record that decision by commenting /approve-spec followed by the full head SHA. Nothing else needs fixing first: the real Turbopack build check now runs in pnpm test:build on the Build package's own CI job, and it passes at this head.

[Automated review]

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approval waits on an engineering owner's decision: spec:AST-080 governs the CSS a source build emits, and this head meets it, but its Non-goals leave how @astryxdesign/build plugs into each bundler out of scope. The governing spec needs to be provided or identified for withAstryx()'s Turbopack configuration (its aliases, loader rules, the condition it adds to the app's own turbopack.rules, and failing on an unreadable installed package.json), the new @astryxdesign/build/next/postcss export with @astryx; and cwd, and the refusal added to @astryxdesign/build/postcss, including whether this direction stands beside #6841. Any engineering owner, the author included, can record that decision by commenting /approve-spec followed by the full head SHA. Nothing else needs fixing first: the Core and Lab parity tests and the real Turbopack build check pass at this head.

[Automated review]

@cixzhang cixzhang added the ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) label Oct 31, 2026
@cixzhang
cixzhang marked this pull request as ready for review October 31, 2026 02:45
@vjeux
vjeux force-pushed the build-next-turbopack branch from 7f090fc to 811d158 Compare November 2, 2026 20:15
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 2, 2026
@cixzhang

cixzhang commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

/approve-spec 811d158

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 2, 2026

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Turbopack source build matches spec:AST-080 FR9 and the AST-080 edit approved at this head: Core, Lab, Charts and Rich Text compile to their prebuilt stylesheets byte for byte, and the Turbopack fixture passes in CI. Two changes are needed before this can be approved:

  • packages/build/src/source-stylesheet.js copies the module walk, compile options and layer wrapper of scripts/build-css.mjs instead of sharing them, so route the prebuilt build through the new module or explain in the description why the two must stay separate.
  • The AST-080 current-state edit drops the still-true webpack gap that a source build emits no order registration (packages/build/src/index.js:309-312) and adds a release plan, so keep the gap and state it in the present tense.

[Automated review]

};
}

function staticStyleXImports(source) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From here through renderPackage (line 388), this file repeats scripts/build-css.mjs lines 117-369: the .stylex import scan, file and alias resolution, the module walk with provider modules, constant collection, the compile options and the layer wrapper. A fix to one walk then misses the other until the parity test catches it. Please have scripts/build-css.mjs compile each target through these functions, or say in the description why the two builds must stay separate.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kept separate here: routing every package's published stylesheet through this module changes how each dist file is built, so it needs its own byte-identity check on every file. Until then the parity test fails on any drift, byte for byte, for Core, Lab, Charts and Rich Text. I'll open that refactor as a follow-up after this merges.

`@astryxdesign/build` measures the speed figures. Under webpack it
source-builds Core and Lab with the `@astryxdesign/build` setup above, while
Rich Text and Charts stay on their prebuilt stylesheets. Implementation gap:
webpack source builds conform at the next minor, because conforming changes

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Under webpack the source build still emits no FR3 order registration (packages/build/src/index.js:309-312 writes @layer astryx-base {…} with no order line), and this edit drops that recorded gap. Please keep it in this sentence and state the gap in the present tense instead of "conform at the next minor".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 1c496ae: the webpack gap is back in the present tense (a webpack source build emits no order registration), with no release wording.

withAstryx() configured only nextConfig.webpack, which Turbopack never
calls, so a Next.js 16 app on its default bundler could not source-build
Astryx. Under Turbopack it now points the documented entry points of Core,
Lab, Charts and Rich Text at their source, compiles that source with the
settings the prebuilt stylesheets use, and keeps the app's own Turbopack
rules off it (spec:AST-080 FR9). The new PostCSS plugin
@astryxdesign/build/next/postcss replaces an `@astryx;` rule with each
source-built package's prebuilt stylesheet compiled from that source: the
same rules and selectors in the same order, each package's block beginning
with the layer order before its `@layer astryx-base` (FR7). Importing the
prebuilt stylesheet of a package built from source fails the build. The
webpack setup is unchanged, and under Turbopack its PostCSS plugin refuses
to run beside withAstryx() instead of building unstyled; AST-080 records
that webpack source builds conform at the next minor. In this source build
an installed Astryx package with a malformed package.json fails the build
instead of being left out.

Unit and parity tests run in the Node suite. pnpm test:build builds a
Next.js app importing Core, Lab, Charts and Rich Text with Turbopack, every
installed prebuilt stylesheet deleted, and checks in Chromium, served and
under next dev, that per package the product's class and StyleX rule beat
the base and a theme beats the base in either load order, also with the
page's stylesheet chunks reversed. scripts/turbopack-speed.mjs measures the
speed against the same app on the prebuilt stylesheets.
@vjeux
vjeux force-pushed the build-next-turbopack branch from 811d158 to 1c496ae Compare November 2, 2026 21:46
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 2, 2026
@cixzhang

cixzhang commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

/approve-spec 1c496ae

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 2, 2026

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is ready to approve: withAstryx() and @astryxdesign/build/next/postcss meet spec:AST-080 FR9 and the FR9 Stylesheet entry clause approved at this head, Core, Lab, Charts and Rich Text compile to their prebuilt stylesheets byte for byte, and the Turbopack fixture passes in CI. Two optional follow-ups: route scripts/build-css.mjs through source-stylesheet.js as planned, so the prebuilt and source builds share one walk, and tighten the two source comments noted inline.

[Automated review]

})
.map(file => path.normalize(file))
.filter(file => !STYLEX_MODULE.test(file)),
// A version older than an entry has none of it to print.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking (comment style): this reads ambiguously. Suggested: // An older package version may not have this file. Skip it.

Comment on lines +27 to +31

/**
* Fail when `from` is the prebuilt stylesheet of a package the app builds from
* source. Its rules would load twice. The second copy would sit outside the
* source build.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking (comment style): this repeats the file header's last sentence (lines 9-10). Delete the JSDoc, or keep one reason sentence.

@cixzhang
cixzhang merged commit 653624f into meta:main Nov 2, 2026
68 checks passed
@vjeux
vjeux deleted the build-next-turbopack branch November 2, 2026 22:34

This branch was successfully deployed

1 active deployment
Preview — 1c496aeb Deployed Nov 2, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) CLA Signed This label is managed by the Meta Open Source bot. needs:design-review Affects visuals — Design should review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants