Skip to content

Validate dist package exports and typings - #180

Merged
rkaraivanov merged 2 commits into
masterfrom
dpetev/validate-dist
Aug 3, 2026
Merged

Validate dist package exports and typings#180
rkaraivanov merged 2 commits into
masterfrom
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

Base automatically changed from dpetev/fix-dist-structure to master July 13, 2026 13:33
@rkaraivanov

Copy link
Copy Markdown
Member

@damyanpetev

Running the validate script produces this:

  const [{ files }] = JSON.parse(
                      ^

TypeError: object is not iterable (cannot read property Symbol(Symbol.iterator))
    at packedFiles (/home/racho/work/igniteui-react/scripts/validate-dist.ts:54:23)
    at validate (/home/racho/work/igniteui-react/scripts/validate-dist.ts:82:18)
    at main (/home/racho/work/igniteui-react/scripts/validate-dist.ts:105:7)
    at <anonymous> (/home/racho/work/igniteui-react/scripts/validate-dist.ts:122:1)
    at ModuleJob.run (node:internal/modules/esm/module_job:439:25)
    at async node:internal/modules/esm/loader:643:26
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:101:5)

@damyanpetev

damyanpetev commented Aug 3, 2026

Copy link
Copy Markdown
Member Author

Odd, it ran locally, will check it. Seems like I have conflicts to resolve anyway;
Edit: and it still does
image
likely the npm pack --json output isn't stable across versions (-.-), will update the package resolution.

@damyanpetev
damyanpetev force-pushed the dpetev/validate-dist branch from e6bcbf3 to fe4c463 Compare August 3, 2026 11:25
Comment thread scripts/validate-dist.ts Dismissed
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)
@damyanpetev
damyanpetev force-pushed the dpetev/validate-dist branch from fe4c463 to f3f837b Compare August 3, 2026 11:42
@damyanpetev

Copy link
Copy Markdown
Member Author

Done, fragile exec->parse of npm pack --json, replaced with npm-packlist

@rkaraivanov
rkaraivanov merged commit d160000 into master Aug 3, 2026
3 checks passed
@rkaraivanov
rkaraivanov deleted the dpetev/validate-dist branch August 3, 2026 11:53
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.

3 participants