Support Vite-style ?raw raw-text imports in CLI builds - #69
Merged
Conversation
build-cli now drives the tsdown JS API with the standard CLI-build options plus a raw-imports plugin that resolves and inlines *?raw imports (rolldown doesn't implement the suffix natively), and the client types declare *?raw modules as strings. Consumers can import example fixtures (e.g. YAML files) as raw text without a local tsdown config or ambient module declaration. The JS API replaces spawning the tsdown CLI because plugins can only reach the CLI via a config file, and tsdown resolves relative paths (entry, tsconfig) against the config file's directory — a config shipped inside the package would break consumer builds. build-cli now takes entries only and never loads a consumer tsdown.config.ts.
pasibun
approved these changes
Jul 15, 2026
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.
Generic follow-up to developer-overheid-nl/don-checker#66 (which fixes developer-overheid-nl/don-checker#55): consumer apps import example fixtures as raw text via Vite's
?rawsuffix — YAML fixtures in particular, so the editor opens them in YAML mode. Vite and Vitest support the suffix natively, but thebuild-cliCLI bundle (rolldown) andtscdon't. This makes both work out of the box, so consumers need no local tsdown config or ambient module declaration.Changes
bin/build-cli.mjs— now drives the tsdown JS API with the standard CLI-build options plus araw-importsplugin that resolves*?rawspecifiers and inlines the file content as a default-exported string.Why the JS API instead of spawning the tsdown CLI: plugins can only reach the CLI via a config file, and tsdown resolves relative paths (entry, tsconfig discovery) against the config file's directory — a config shipped inside this package made consumer builds resolve
tsconfig: ../tsconfig.json(this package's own!) and fail onCannot resolve entry module src/cli.ts. With the API everything stays relative to the consumer's cwd.Contract change:
build-cli <entry> [...entry]takes entries only (flags now error with a usage message instead of being forwarded), and a consumertsdown.config.tsis never loaded — the build is fully standard.client.d.ts— declares*?rawmodules as strings, sotscaccepts the imports. Consumers upgrading should remove any local equivalent declaration (a duplicate would conflict).README + changeset (minor).
Verification
pnpm lintclean,pnpm test runpasses (131 tests),pnpm buildsucceeds.?rawYAML/JSON imports): built with thisbuild-cliafter removing its localtsdown.config.tsshim — correct consumertsconfig.jsonpicked up, bundle validates both the YAML publiccode example and the JSON ADR example with 0 diagnostics.tsc -balso passes against the newclient.d.tswith the local*?rawdeclaration removed.?rawimports): builds unchanged and its CLI validates the JSON-FG feature example clean — no regression for consumers not using the feature.After this lands in a release, don-checker can drop its
tsdown.config.tsandsrc/vite-env.d.tsshims when bumping the dependency.