Skip to content

[Bug]: workspace-plugin generate-api silently skips every export-subpath rollup on Windows #36654

Description

Area

workspace-plugin (package)

Environment

OS: Windows 11
node v22.12.0
@fluentui/workspace-plugin (in-repo tools/workspace-plugin)

Current Behavior

tools/workspace-plugin/src/executors/generate-api/lib/utils.ts, in getExportSubpathConfigs:

const resolvedPrimaryEntry = resolve(
  configDir,
  primaryMainEntryTemplate.replace(/<unscopedPackageName>/g, unscopedPackageName),
);

const indexDtsSuffix = '/index.d.ts';
if (!resolvedPrimaryEntry.endsWith(indexDtsSuffix)) {
  // …skip
}

path.resolve emits backslash-separated paths on Windows, so resolvedPrimaryEntry never ends
with the hard-coded posix suffix '/index.d.ts'. The guard therefore fires for every project and
every export-subpath API rollup is skipped, silently, on Windows machines. Linux CI is
unaffected, which is why the behaviour has not surfaced there.

Concretely: on a Windows checkout, generate-api for
@fluentui/react-headless-components-preview emits 0 subpath rollups where it should emit 56.
A contributor on Windows therefore cannot regenerate the etc/*.api.md files their change requires,
and — worse — a run that produces nothing looks the same as a run that had nothing to produce.

Expected Behavior

Subpath rollups are generated on every supported development platform, and a path that cannot be
matched raises rather than silently skipping.

Reproduction

On Windows, run generate-api for any package that declares export subpaths (e.g.
@fluentui/react-headless-components-preview) and compare the emitted rollups against a Linux run.

Steps to reproduce

  1. On a Windows checkout, run the generate-api executor for a package with exports subpaths.
  2. Observe that no per-subpath .d.ts rollup or etc/*.api.md is produced.
  3. Instrument resolvedPrimaryEntry — it is backslash-separated and fails the '/index.d.ts' check.

Discovery context

Found while scaffolding a new package with a large export-subpath surface on a Windows checkout,
during work on a styling layer over @fluentui/react-headless-components-preview. The package's
API reports came back empty, and tracing that led here. Nothing about the finding is specific to
that work: any Windows contributor touching a package with subpath exports hits it.

Proposed fix

Normalize to posix separators before the suffix check:

const resolvedPrimaryEntry = resolve(
  configDir,
  primaryMainEntryTemplate.replace(/<unscopedPackageName>/g, unscopedPackageName),
).replace(/\\/g, '/');

One expression, with a comment recording why (so it survives a future tidy). 56 headless rollups
emit locally after the change; CI output is unchanged, since it was already correct there.

A working implementation is included in PR #[WINDMOD-PR-NUMBER] (part of commit d826380ae5);
happy to split it into a standalone PR against this issue — it is independent of everything else in
that PR.

Suggested severity

Medium - Has workaround (regenerate API reports on Linux/WSL or let CI do it).

Products/sites affected

Local development on Windows for any package with export subpaths.

Are you willing to submit a PR to fix?

yes

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