Skip to content

Dedupe build output#8557

Merged
tnorling merged 14 commits into
devfrom
dedupe-build-output
Apr 29, 2026
Merged

Dedupe build output#8557
tnorling merged 14 commits into
devfrom
dedupe-build-output

Conversation

@tnorling
Copy link
Copy Markdown
Collaborator

This pull request updates the packaging and build configuration for all MSAL packages to improve TypeScript type resolution for consumers using both ESM and CommonJS. The main improvements are the introduction of CommonJS type declaration shims, consolidation of subpath export builds, and updates to the package.json exports to reference the correct type declaration files. These changes should resolve longstanding issues with type resolution in CommonJS environments and simplify the build process.

Build process and type declaration improvements:

  • Introduced a new createCjsTypeShims utility in shared-configs/rollup-msal/index.js to generate CommonJS .d.cts type declaration files that re-export types from ESM entrypoints, ensuring correct type resolution for CommonJS consumers.
  • Updated all package rollup.config.js files (msal-browser, msal-common, msal-node, msal-react) to use createCjsTypeShims and generate .d.cts files for CommonJS exports. [1] [2] [3] [4]
  • Changed TypeScript compiler options in all build configs to disable generation of .d.ts and .d.ts.map files for CommonJS builds, preventing duplicate or unnecessary declaration files. [1] [2] [3] [4] [5] [6]

Package exports and type resolution:

  • Updated package.json exports fields in all packages to reference the new .d.cts files in the dist (or dist-browser) directories for CommonJS types entries, instead of the previous .d.ts files in lib/types. [1] [2] [3] [4] [5] [6] [7]

Build process simplification and consolidation:

  • Consolidated the ES module build for msal-browser subpath exports (custom_auth and redirect_bridge) into the main build step, removing redundant build configurations and simplifying the output directory structure. [1] [2] [3]

Summary of the most important changes:

Type Declaration and Exports Modernization

  • Added createCjsTypeShims to generate .d.cts files for CommonJS type resolution and integrated it into all package builds. [1] [2] [3] [4] [5]
  • Updated all package.json exports to point CommonJS types to the new .d.cts files in dist folders. [1] [2] [3] [4] [5] [6] [7]

Build Process Improvements

  • Disabled TypeScript declaration and declaration map generation for CommonJS builds to avoid duplicate or conflicting type files. [1] [2] [3] [4] [5] [6]
  • Consolidated ES build steps for msal-browser subpaths, reducing build complexity and output directories. [1] [2] [3]

Copilot AI review requested due to automatic review settings April 23, 2026 22:21
@tnorling tnorling requested review from a team as code owners April 23, 2026 22:21
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates MSAL packages’ Rollup build + packaging metadata to dedupe build artifacts and improve TypeScript type resolution for consumers using both ESM and CommonJS, primarily by generating .d.cts CommonJS type shims and updating package.json export types entries.

Changes:

  • Added a shared Rollup plugin (createCjsTypeShims) to emit CommonJS declaration shims (.d.cts) that re-export from ESM type entrypoints.
  • Updated package Rollup configs to stop emitting duplicate declaration files for CommonJS builds and to generate the .d.cts shims.
  • Updated package.json exports to reference .d.cts files for the require (types) condition and consolidated msal-browser subpath ESM builds.

Reviewed changes

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

Show a summary per file
File Description
shared-configs/rollup-msal/index.js Adds createCjsTypeShims plugin and exports it for reuse in package builds.
lib/msal-react/rollup.config.js Generates dist/index.d.cts and disables CJS declaration emit to reduce duplicate types.
lib/msal-react/package.json Points exports.require.types to dist/index.d.cts.
lib/msal-node/rollup.config.js Generates dist/index.d.cts and disables CJS declaration emit.
lib/msal-node/package.json Points exports.require.types to dist/index.d.cts.
lib/msal-common/rollup.config.js Generates multiple .d.cts shims for main/node/browser entrypoints; disables CJS declaration emit.
lib/msal-common/package.json Points exports.require.types entries to .d.cts shims across entrypoints.
lib/msal-browser/rollup.config.js Consolidates ESM build inputs (main + subpaths) and generates .d.cts shims; disables CJS declaration emit for subpath CJS builds.
lib/msal-browser/package.json Updates subpath and main exports to use new dist paths and .d.cts for require.types.

Comment thread shared-configs/rollup-msal/index.js
Comment thread lib/msal-node/rollup.config.js Outdated
Comment thread lib/msal-common/rollup.config.js Outdated
Comment thread lib/msal-browser/rollup.config.js Outdated
Comment thread shared-configs/rollup-msal/index.js
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 22 out of 23 changed files in this pull request and generated 5 comments.

Comment thread extensions/msal-node-extensions/rollup.config.js Outdated
Comment thread lib/msal-common/rollup.config.js
Comment thread lib/msal-react/rollup.config.js Outdated
Comment thread lib/msal-node/rollup.config.js Outdated
Comment thread lib/msal-browser/rollup.config.js Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 36 out of 37 changed files in this pull request and generated 4 comments.

Comment thread lib/msal-common/rollup.config.js
Comment thread lib/msal-browser/rollup.config.js
Comment thread lib/msal-react/rollup.config.js
Comment thread extensions/msal-node-extensions/rollup.config.js
Copy link
Copy Markdown
Contributor

@shenj shenj left a comment

Choose a reason for hiding this comment

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

A small note. Since the new output folder for ES is now custom_auth (previously custom_auth_path), it might be better to update the output folder for CJS to custom_auth as well to maintain consistency. I understand that this PR was meant to change only the ESM side, so it's up to you if you'd like to make this update. Thanks.

@tnorling tnorling merged commit b79cadc into dev Apr 29, 2026
70 of 71 checks passed
@tnorling tnorling deleted the dedupe-build-output branch April 29, 2026 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants