Add a transform hook filter and release 2.0.0 - #43
Open
toeknee-figma wants to merge 1 commit into
Open
Conversation
toeknee-figma
force-pushed
the
fix/transform-correctness
branch
from
August 1, 2026 23:52
9a77b11 to
abb24d5
Compare
toeknee-figma
force-pushed
the
feat/transform-hook-filter
branch
from
August 1, 2026 23:52
bebefb7 to
5a3ffe9
Compare
Rolldown and Rollup 4.38+ read `transform.filter` and skip the handler entirely for ids that miss it, so the plugin no longer gets called for every non-YAML module in the graph (#37). Older versions ignore the field and invoke the handler exactly as before, which Vite has resolved through the object hook form since well before the 3.2.7 floor in peerDependencies, so the supported range is unchanged. The handler keeps its own checks: the filter narrows which ids reach it, it does not replace the include/exclude options, whose picomatch semantics differ from a hook filter's. Releasing as 2.0.0 for the removal of the `raw` option and for the serializer no longer emitting a placeholder in place of a circular reference. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
toeknee-figma
force-pushed
the
feat/transform-hook-filter
branch
from
August 2, 2026 00:00
5a3ffe9 to
f3e4647
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.
Third of three stacked PRs. Based on #42, which is based on #41 — the diff here is just the hook filter, the changelog and the version bump.
Hook filter
Rolldown and Rollup 4.38+ read
transform.filterand skip the handler entirely for ids that miss it, so the plugin stops being called for every non-YAML module in the graph. Fixes #37 — thanks @TheAlexLichter for the pointer to the rolldown guidance.Older versions ignore
filterand callhandleras before. I checked that the object hook form itself resolves correctly all the way back to the>=3.2.7floor inpeerDependencies— Vite 3.2.7 already does'handler' in hook ? hook.handler : hook— so the supported range is unchanged and no peer bump is needed.The handler keeps its own checks. The filter narrows which ids reach it; it does not replace
include/exclude, whose picomatch semantics differ from a hook filter's, and folding one into the other would quietly change which files users' existing patterns match.2.0.0
Major for two breaking changes, both in #42: the
rawoption is gone, and a circular anchor now raises an error instead of emitting a{$circularReference:1}placeholder where the data should be.Worth being clear about the trade-off: in practice nothing that currently works breaks, since
rawemitted[object Object]for any mapping and the placeholder was already corrupt data. A major means everyone on^1.1.1has to opt in, so the js-yaml advisory fix will not reach them automatically. A 1.1.2 backport would close that gap if wanted.Disposition of the remaining issues
Each was investigated against a real build or dev server, then put through an independent reviewer whose job was to refute it. All five reviewers dissented on something, and two of those dissents changed the outcome.
#3 sourcemaps — close, no code change.
map: { mappings: '' }is the only option that produces no warning and no fabricated positions and no bloat.map: nullalso silences the warning but projects generated-JS columns onto YAML lines, emitting a knowingly wrong map, and drags the YAML into the bundle sourcemap — measured at 183 KB of map for a 172 KB YAML versus 272 bytes today. Omittingmapis the only variant that warns, so PR #9's 2022 fix was right and still is. One correction worth recording: an empty map is a chain terminator, not a neutral no-op — a plugin transforming the same module afterwards has its map discarded. Accepted deliberately, since the output is a singleJSON.parse("…")with no original position to point at.#16 Storybook — close as not reproducible. Built the matrix: Storybook 7.0/7.6/9.1 against Vite 4.1/4.5/5.4/7.3, on both the published 1.1.1 and this branch,
buildanddev, including a real browser HMR edit. Every combination passed, including on 1.1.1 — so this stack cannot be claimed to fix it. The reporter's exactParse error @:1:NNwas reproduced by a different mechanism: the plugin absent from the config Storybook builds with, where the column is just the length of line 1 and the error only takes that cryptic form when line 1 contains a quote. That matches reporter 1's description precisely. Reporter 2's symptom is genuinely unexplained and needs a repro.#19
!import— close with an answer, do not build the tag. The reviewer showed the reporter's use case already works with no plugin change: split the file, then a three-line module that imports the parts and spreads them. Verified on a real Vite 7 dev server that editing an imported YAML file propagates correctly through the module graph. It also gets the precedence the reporter actually asked for — later spread wins — whereas the YAML merge key (<<:) gives the opposite, so recommending<<:would have answered the maintainer's duplicate-key question wrongly.#27
keyof typeofand the runtime half of #18 are still open; see the issues.🤖 Generated with Claude Code