Skip to content

@react-spectrum/ai prose() fails with fontSize is not defined #10975

Open

Description

@BDesta

Provide a general summary of the issue here

Using the published prose() macro from @react-spectrum/ai@0.5.2 fails during the consumer build with fontSize is not defined.

🤔 Expected Behavior?

Importing and calling prose() as a macro should build successfully, return a class name, and generate the corresponding prose CSS.

😯 Current Behavior

The build fails while evaluating the macro:

Error evaluating macro: fontSize is not defined

The published dist/private/style/prose.mjs retains a reference to fontSize in its local font() helper, but the corresponding import is missing from the generated module.

StackBlitz Reproduction

https://stackblitz.com/edit/frhxnxlb?file=main.js

🖥️ Steps to Reproduce

  1. Open the StackBlitz reproduction and let dependencies install.
  2. Run npm run build in the terminal.
  3. Observe the macro evaluation error.

The reproduction uses Vite with unplugin-parcel-macros:

// vite.config.js
import {defineConfig} from 'vite';
import macros from 'unplugin-parcel-macros';

export default defineConfig({plugins: [macros.vite()]});
// main.js
import {prose} from '@react-spectrum/ai/style' with {type: 'macro'};

document.querySelector('#app').className = prose();

💁 Possible Solution

Correct the regular versus macro imports in the prose implementation. In particular, fontFamily is not a function but is imported with with {type: 'macro'}. The packaged macro also needs to retain or resolve the dependencies used by its local font() helper.

Published output: https://npmx.dev/package-code/@react-spectrum/ai/v/0.5.2/dist%2Fprivate%2Fstyle%2Fprose.mjs

A proposed fix and regression tests are now available in PR #10976. The PR moves the font helper behind a separate macro compilation boundary so Parcel can inline resolved font declarations without bundling the theme tables, and fixes serialization of nested language-specific font weights. It includes CommonJS and ESM packaging coverage; validation results and limitations are documented in the PR.

🔦 Context

I am trying to use the shared prose styles for rendered Markdown rather than maintaining custom typography styles. This build failure prevents adopting the published macro.

🌍 Your Environment

Version

  • @react-spectrum/ai: 0.5.2
  • Vite: 7.3.2
  • unplugin-parcel-macros: 0.2.0 (reproduction manifest specifies ^0.2.0)
  • Node.js: 24 (recorded local reproduction)

What browsers are you seeing the problem on?

Other — this is a build-time macro evaluation failure, before browser execution.

What operating system are you using?

macOS (local reproduction); a public StackBlitz reproduction is linked above.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions