ReviewOS

also looking at this

stacks/dtsx

fix(generator): skip glob and relative entrypoints outside the root

#3126
Open mkantautas wants to merge fix/glob-entrypoint-outside-root into main
3 files +74 -2
8 days ago

Summary

An entrypoint pattern that reaches above the root writes its declaration outside outdir:

generate({ root: 'src', outdir: 'dist', entrypoints: ['../*.ts'] })

writes outside.d.ts next to outside.ts, and entrypoints: ['../outside.ts'] does the same.

Changes

findFiles already skips an absolute entrypoint outside the root with a warning, as the re-export auto-inclusion does, but a glob or relative pattern goes through its glob branch, which did not check. That branch now skips such files the same way, with the same Skipping entrypoint outside root warning. A flat output structure still takes them, into outdir under their file name. A run left with no files fails with "No source files matched" after the warnings. The configuration docs' Entry Points section describes the rule.

Testing

New test/entrypoint-outside-root.test.ts:

  • ['../*.ts'] and ['../outside.ts'] must write nothing outside outdir and fail with "No source files matched";
  • ['*.ts', '../*.ts'] must write only dist/inside.d.ts;
  • the flat structure must write dist/outside.d.ts;
  • an exclude that leaves nothing must still fail.

On main the first three fail, with the file written outside outdir.

bun test (Zig library built with the pinned Zig, so its tests run too), typecheck, lint and zig build test pass.

3 changed files on the files tab, with 0 review threads.

Sign in to comment on this pull request.