Skip to content

feat(source-resolution): a package declared "resolve": "dist" carries no source condition - #77

Merged
systemfsoftware-bot merged 1 commit into
mainfrom
source-resolution-declared-dist
Nov 27, 2026
Merged

systemfsoftware-bot merged 1 commit into
mainfrom
source-resolution-declared-dist

Conversation

@systemfsoftware-bot

Copy link
Copy Markdown
Contributor

A workspace package can now resolve to its built dist/ for its workspace consumers, instead of to its src/ through the source condition. It does that by declaring "gritlint": { "resolve": "dist" } in its package.json. The declaration alone decides; the rules check that the export map agrees with it.

Rules

Rule Check
dist-resolve-no-source-condition (new) a declared package carries the condition on no exports subpath
tsdown-source-condition-required (new) in a package with a bundler config and no declaration, every export entry pointing into ./dist/ is an object that carries the condition
gritlint-resolve-value (new) a top-level "gritlint" key is exactly { "resolve": "dist" }
tsdown-exports (changed) devExports may be left out; a devExports that is set must still be the condition string

tsdown-exports is a JavaScript rule, so it can't read the sibling package.json. That's why the rule that stops an undeclared package from dropping the condition lives on package.json, in tsdown-source-condition-required. publishConfig.exports stays with publish-config-exports. Only a top-level "gritlint" key counts as a declaration, so a bin entry named gritlint isn't one.

Evidence

  • cargo test -p gritlint_core passes, 137 of 137. That includes every fixture case and the committed bundled-rule listing.
  • New fixtures:
    • For each new rule: bad cases at their exact locations, good cases, and decoys (a nested key, a key in another package, a bundler config in another directory, a stylesheet subpath, publishConfig.exports).
    • tsdown-exports gains good cases for an omitted devExports.
  • No new findings on real trees: gritlint check with the new rules finds nothing on gritlint's own repo or on a 6,807-file monorepo whose 52 libraries all use the source condition. So the rules enable at error severity with no baseline.
  • Adversarial review: a written review in a fresh context found several escapes, each reproduced as a failing fixture before the fix: string-valued and wildcard export entries, root conditions maps, src/ string exports, publishConfig.exports double reports, and contradictory findings on an invalid declaration.
    • Left out on purpose: a bundled package with no exports field at all. The bundler writes exports on build.

… no source condition

A package.json may declare "gritlint": { "resolve": "dist" } so its workspace consumers resolve its built dist/
instead of its src/. Three rules check that its export map agrees:

- dist-resolve-no-source-condition: a declared package carries the condition on no exports subpath.
- tsdown-source-condition-required: in a package with a bundler config and no declaration, every export entry that
  points into ./dist/ is an object that carries the condition, so leaving devExports out is not an undeclared way
  to drop it.
- gritlint-resolve-value: a top-level "gritlint" key is exactly { "resolve": "dist" }.

tsdown-exports accepts a bundler config that leaves devExports out; a devExports it sets must still be the
condition string. publishConfig.exports stays with publish-config-exports, and only the top-level "gritlint" key
counts as a declaration.
@systemfsoftware-bot
systemfsoftware-bot merged commit 8b81f2d into main Nov 27, 2026
5 checks passed
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