Skip to content

fix(workspace-plugin): normalize path separators for Windows in generate-api - #36657

Open
MOHAMMED WASIM KHAN (wasim-builds) wants to merge 1 commit into
microsoft:masterfrom
wasim-builds:fix/generate-api-windows-path-separator
Open

fix(workspace-plugin): normalize path separators for Windows in generate-api#36657
MOHAMMED WASIM KHAN (wasim-builds) wants to merge 1 commit into
microsoft:masterfrom
wasim-builds:fix/generate-api-windows-path-separator

Conversation

@wasim-builds

Copy link
Copy Markdown

Previous Behavior

In tools/workspace-plugin/src/executors/generate-api/lib/utils.ts, resolveDeclarationBase resolves the primary main entry template using path.resolve(...). On Windows systems, path.resolve returns backslash-separated paths (\), which causes resolvedPrimaryEntry.endsWith('/index.d.ts') to evaluate to false. As a result, export subpath API rollup generation is silently skipped on Windows environments.

New Behavior

Normalize resolvedPrimaryEntry with .replace(/\\/g, '/') so that the POSIX /index.d.ts suffix check and slice work consistently across all platforms (including Windows). Added a unit test in executor.spec.ts covering path resolution with Windows-style backslashes.

Related Issue(s)

Copilot AI lite review requested due to automatic review settings August 30, 2026 11:29

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI 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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comment on lines +358 to +361
const resolveSpy = jest.spyOn(path, 'resolve').mockImplementation((...args) => {
const posixPath = path.posix.resolve(...args);
return posixPath.replace(/\//g, '\\');
});
configDir,
primaryMainEntryTemplate.replace(/<unscopedPackageName>/g, unscopedPackageName),
);
).replace(/\\/g, '/');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2 participants