Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #10975
Summary
Intent
Make the published
prose()macro usable without changing its public API or requiring consumers to maintain their own typography styles. Currently, evaluating it fails withReferenceError: fontSize is not definedbecause values imported withwith {type: 'macro'}are referenced as ordinary data by the localfont()helper.Implementation and why the separate font file matters
Move the existing
font()helper and its color lookup intoprose-font.ts. This module imports the font tables and related values normally;prose.tsimports the helper function as a macro.The separate file is a compilation boundary, not just code organization. Parcel evaluates the literal
font('body'),font('heading-xl'), etc. calls while packagingprose.ts, and inlines their resolved declaration objects. The helper can read the original Spectrum font tables without retaining those tables and their dependencies in the published macro. It also avoids duplicating token values or inventing a separate typography scale.Simply changing the existing theme imports to regular imports avoids the missing binding, but pulls substantially more theme code into the emitted macro. In a local comparison using the same Node ESM library entry, production mode, and
shouldOptimize: false:prose.tsThat is 174,124 fewer bytes (about 82% smaller) than the imports-only alternative. These are unoptimized build-time macro module sizes, not compressed browser-bundle measurements. The broken upstream module is smaller still, but cannot be evaluated.
Recursively serialize nested conditional declarations. Resolving the actual font-weight tables exposes nested CJK language conditions; stringifying these objects directly produces
[object Object]instead of CSS. Preserve the nested selectors and their default weights.Add source-level coverage for the nested font weights and packaging coverage that builds both CommonJS and ESM output, evaluates the packaged macro in Node, and checks its emitted CSS. The packaging test runs Parcel outside Jest's module environment to avoid sharing cached loaders with other suites.
This PR was prepared with AI assistance; the implementation and validation remain the author's responsibility.
📝 Test Instructions
main(360e35170) in a separate Parcel ESM packaging probe: evaluating the output throwsReferenceError: fontSize is not defined. The same probe succeeds on this branch and emits CSS withoutundefinedor[object Object].yarn test --maxWorkers=2: 383 suites / 8,285 tests passed; 2 tests failed; 16 skipped. Failures are in unchanged date/era tests:DatePicker > editing > text input > should support typing into the era segmentandDateField > does not crash when a calendar has an era with no localized name(expectedAM, receivedERA1). These failures have not been independently reproduced on a clean baseline.yarn test:ssr: 60 suites / 74 tests passed.yarn test:parcel --runInBand: 2 suites / 15 tests passed, including both packaged prose formats and the existing docs-transformer suite.yarn lint: failed. Package lint, package metadata checks, and Yarn constraints passed. The formatting check reports two untouched local configuration files (.claude/settings.local.json,.github/hooks/hooks.json); type checking reports duplicateJSXimports on lines 1 and 2 of the installednode_modules/@mdx-js/react/lib/index.d.ts. No unrelated configuration or dependency files were changed to suppress these failures.yarn format:checkandyarn exec oxlinton all four changed files: passed.git diff --cached --check: passed.24.11.1selected by.nvmrc(24), Yarn4.18.0, macOS. Dependencies were refreshed withyarn install --immutableafter fast-forwarding to upstream main.npm run buildto observe the published 0.5.2 failure. The StackBlitz still uses the published package, not this unpublished fix.Release impact
✅ PR Checklist
🧢 Your Project
Downstream Markdown rendering using shared Spectrum prose styles.