ci: add validate:exports script to catch missing build output type declarations#8544
Open
hectormmg wants to merge 17 commits into
Open
ci: add validate:exports script to catch missing build output type declarations#8544hectormmg wants to merge 17 commits into
hectormmg wants to merge 17 commits into
Conversation
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>
Contributor
There was a problem hiding this comment.
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.jsto walkpackage.jsonexportsand entry fields and verify referenced files exist on disk. - Add
validate:exportsscript to each package to run the validator from the package directory. - Add
typecheckscript 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. |
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>
Contributor
|
Reminder: This PR appears to be stale. If this PR is still a work in progress please mark as draft. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.