Skip to content

Validate dist package exports and typings#180

Open
damyanpetev wants to merge 2 commits into
dpetev/fix-dist-structurefrom
dpetev/validate-dist
Open

Validate dist package exports and typings#180
damyanpetev wants to merge 2 commits into
dpetev/fix-dist-structurefrom
dpetev/validate-dist

Conversation

@damyanpetev

Copy link
Copy Markdown
Member

Addition to #179
Will migrate the CI pipeline separately.

What

Adds a dist validation script that verifies every published package's export contract actually resolves in the built dist/ output, and wires it into CI.

How it works

scripts/validate-dist.ts iterates over each package manifest (components / dock-manager / grids), copies it to dist/package.json (exactly as the release pipeline does), and validates against the real packed output (npm pack / attw --pack), so the files allowlist is respected just like a real publish:

  1. @arethetypeswrong/cli resolves the types (and their JS) for every exports entrypoint. --profile esm-only ignores the legacy node10/CJS resolution modes these ESM-only packages intentionally don't support, so a non-zero exit means a real problem. attw's own report is printed for visibility in CI and locally.
  2. JS-entry backstop — attw is types-first and will still pass if a runtime .js is missing while its .d.ts resolves, so the script also confirms every JS entry point is actually in the published file set.

Changes

  • scripts/validate-dist.ts — new validator (attw exit code + JS-entry check; reuses PackageJsonTypes from scripts/types.ts).
  • package.json — added @arethetypeswrong/cli devDependency and a validate:dist script.
  • .azure-pipelines/setup-build-test-steps.yml — new Validate dist packages step after build (runs in both CI and release pipelines).
  • scripts/grids.package.json — added an explicit exports map to match the other packages, with a "./grids/*" wildcard to preserve theme CSS and the deprecated grids/combined subpath imports; legacy main/module/typings retained for back-compat.

Verification

  • Passes cleanly on a correct build (exit 0, no leftover dist/package.json).
  • Regression checks fail as expected: a missing .d.ts is caught by attw, and a missing .js is caught by the backstop (both exit 1).
  • New script passes biome lint.

Usage

npm run build
npm run validate:dist

Additional information (check all that apply):

  • Bug fix
  • New functionality
  • Documentation
  • Demos
  • CI/CD

Checklist:

  • All relevant tags have been applied to this PR
  • This PR includes general feature table updates in the root README.MD
  • This PR includes CHANGELOG.MD updates for newly added functionality
  • This PR contains breaking changes
  • This PR includes behavioral changes and the feature specification has been updated with them

Add a check that guards each published package against a broken dist layout —
e.g. build output like .d.ts files moved from where the package exports point.

scripts/validate-dist.ts, per manifest, copies it to dist/package.json (as the
release pipeline does) and, against the real npm pack output (so the `files`
allowlist is honored):
- runs `attw --pack --profile esm-only` and relies on its exit code;
- confirms every JS entrypoint actually ships (attw is types-first and won't
  flag a missing runtime file when the .d.ts still resolves)
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.

1 participant