Skip to content

ci: add validate:exports script to catch missing build output type declarations#8544

Open
hectormmg wants to merge 17 commits into
devfrom
build-validation-update
Open

ci: add validate:exports script to catch missing build output type declarations#8544
hectormmg wants to merge 17 commits into
devfrom
build-validation-update

Conversation

@hectormmg
Copy link
Copy Markdown
Member

@hectormmg hectormmg commented Apr 20, 2026

Summary

This PR adds two CI checks to catch build quality issues before they reach npm.

1. validate:exports - export path validation

Adds scripts/check-exports.js (zero-dependency Node.js script) that reads each package's package.json and verifies every path referenced in exports, types, typings, main, and module actually exists on disk after the build.

This catches the class of bug where a Rollup config omits .d.ts output (e.g. declaration: false) while package.json still declares a types path - producing packages that break downstream consumers at type-check time even though the build succeeded.

2. typecheck - source-level type checking

Adds "typecheck": "tsc --noEmit -p tsconfig.build.json" to all Rollup-based packages (msal-common, msal-browser, msal-node, msal-react, msal-node-extensions). msal-angular is excluded because the Angular CLI already type-checks during its build.

Rollup's @rollup/plugin-typescript uses noEmitOnError: false by default and never fails the build on type errors. Running tsc --noEmit as a separate CI step surfaces these errors explicitly.

CI wiring

Both steps are added to ci-template.yml with condition: succeededOrFailed() so every post-build check runs even if a prior check fails, maximising signal per CI run while still blocking the PR on any failure.

hectormmg and others added 2 commits April 20, 2026 13:00
Rollup does not enforce TypeScript type correctness, allowing TS errors
to slip through into built packages. Add a 'typecheck' script using
tsc --noEmit to each Rollup-based library so CI can detect type errors
that would otherwise only surface as non-fatal warnings during test
coverage collection.

Skipped for msal-angular which uses Angular CLI, which includes type
checking as part of its build.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add publint + attw (Are The Types Wrong) as dev dependencies and
validate:exports scripts to all publishable packages. These tools check
that all paths referenced in package.json exports conditions actually
exist after a build, and that TypeScript resolves types correctly for
every export condition. This would have caught the missing
lib/redirect-bridge/types/redirect_bridge/index.d.ts declaration file
before it was published.

- publint: validates all exports/main/types paths exist on disk
- attw --pack .: packs and checks each export condition resolves types
- msal-angular uses publint only (no exports map, Angular CLI output)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@hectormmg hectormmg requested review from a team as code owners April 20, 2026 23:25
Copilot AI review requested due to automatic review settings April 20, 2026 23:25
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

Adds a repo-wide validation script intended to fail CI/builds when a package’s package.json promises export/type entrypoints that are missing from the built output (catching cases where declarations or build artifacts are silently omitted).

Changes:

  • Add scripts/check-exports.js to walk package.json exports and entry fields and verify referenced files exist on disk.
  • Add validate:exports script to each package to run the validator from the package directory.
  • Add typecheck script to several packages (in addition to the export validation).

Reviewed changes

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

Show a summary per file
File Description
scripts/check-exports.js New Node script that validates export/entrypoint file paths exist after build.
lib/msal-react/package.json Adds typecheck and validate:exports scripts.
lib/msal-node/package.json Adds typecheck and validate:exports scripts.
lib/msal-common/package.json Adds typecheck and validate:exports scripts.
lib/msal-browser/package.json Adds typecheck and validate:exports scripts.
lib/msal-angular/package.json Adds validate:exports script.
extensions/msal-node-extensions/package.json Adds typecheck and validate:exports scripts.

Comment thread scripts/check-exports.js Outdated
Comment thread lib/msal-browser/package.json Outdated
hectormmg and others added 15 commits April 20, 2026 16:34
Some packages set main/types/module without the './' prefix
(e.g. 'dist/index.d.ts'). The previous startsWith('./') guard silently
skipped those. Now any non-URL, non-absolute string is treated as a
package-relative path.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…anch

MUST REVERT before merging - changes ref: dev to ref: build-validation-update
so CI picks up the updated ci-template.yml steps (validate:exports, typecheck).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The typings field pointed to ./dist/azure-msal-angular.d.ts which ng-packagr
never generates. The actual output is ./dist/index.d.ts (matching the
published dist/package.json). Surfaced by the new validate:exports check.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@types/node v22 uses Symbol.dispose/Disposable which require
lib: esnext.disposable, incompatible with target: es2020. skipLibCheck
prevents third-party .d.ts errors from failing the typecheck CI step.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
--skipLibCheck is now passed directly in the typecheck npm script

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@microsoft-github-policy-service
Copy link
Copy Markdown
Contributor

Reminder: This PR appears to be stale. If this PR is still a work in progress please mark as draft.

@microsoft-github-policy-service microsoft-github-policy-service Bot added the Needs: Attention 👋 Awaiting response from the MSAL.js team label May 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs: Attention 👋 Awaiting response from the MSAL.js team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants