feat(plugin): add tsdownConfig and tsdownConfigResolved plugin hooks#918
Merged
feat(plugin): add tsdownConfig and tsdownConfigResolved plugin hooks#918
tsdownConfig and tsdownConfigResolved plugin hooks#918Conversation
Introduce two tsdown-specific per-plugin lifecycle hooks modeled on Vite's `config` and `configResolved`: - `tsdownConfig(config, env)` — called before the user config is resolved. May mutate in place or return a partial `UserConfig` to be deep-merged. - `tsdownConfigResolved(resolvedConfig)` — read-only notification fired once per produced `ResolvedConfig` (per output format). Both hooks are detected on user plugins via duck-typing, so existing Rolldown plugins continue to work unchanged. A `TsdownPlugin` interface, `TsdownConfigEnv` interface, and `flattenPlugins` helper are exported from `tsdown/plugins`.
✅ Deploy Preview for tsdown-main ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
tsdown
create-tsdown
@tsdown/css
@tsdown/exe
tsdown-migrate
commit: |
`watch` and `cwd` are already reachable via the first `config` argument passed to `tsdownConfig`, so keeping them in env duplicates data and risks going stale. Drop both — `inlineConfig` remains because it is the only piece of context that cannot be derived from `UserConfig`.
The env object only wrapped a single `inlineConfig` field, so pass the `InlineConfig` directly as the second argument instead. Drops the `TsdownConfigEnv` interface and its re-exports.
f9ebb82 to
75601ed
Compare
Mirrors Rolldown's `RolldownPluginOption` but with `TsdownPlugin` as the atom, so that `UserConfig.plugins` entries get proper type-checking for the new `tsdownConfig` / `tsdownConfigResolved` hooks.
75601ed to
a31dbe2
Compare
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.
Description
Adds two tsdown-specific per-plugin lifecycle hooks modeled on Vite's
configandconfigResolved:tsdownConfig(config, env)— called before the user config is resolved. May mutate in place or return a partialUserConfigto be deep-merged. Async supported.tsdownConfigResolved(resolvedConfig)— read-only notification fired once per producedResolvedConfig(per output format). Async supported.Both hooks are detected on user plugins via duck-typing, so existing Rolldown plugins continue to work unchanged. A new
TsdownPlugininterface,TsdownConfigEnvinterface, andflattenPluginshelper are exported fromtsdown/plugins.Linked Issues
Additional context
fromViteparticipate intsdownConfigResolvedbut nottsdownConfig(they are loaded after the dispatch).tsdownConfigdispatch so plugins added by a hook do not re-trigger themselves (matches Vite semantics, prevents infinite recursion).mergeConfigreplaces arrays — to append plugins fromtsdownConfig, mutateconfig.pluginsin place.src/features/plugin.test.tscover mutation, partial-return merge, env shape, plugin order, async, dual-format firing, ordering guarantee (tsdownConfigfinishes beforetsdownConfigResolved), andflattenPluginsedge cases.