feat: add vue.customElements config to skip component resolution - #1823
Conversation
Hand-written non-HTML tags (VML `v:*`, Office `o:*` inside MSO conditional comments) are compiled as Vue components, triggering a "Failed to resolve component" warning. There was no way to opt them out — `isCustomElement` was hardcoded to `amp-*` and not exposed. Add `vue.customElements` (string | RegExp | array | predicate), composed with the built-in `amp-*` matcher, so matching tags render verbatim while their Tailwind classes are still scanned. Threaded through all renderer entry points (build, serve, worker, render, prepare). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe renderer now accepts Vue ChangesVue custom-elements support
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant VueConfig
participant createRenderer
participant VueResolver
participant NativeElement
VueConfig->>createRenderer: Pass customElements
createRenderer->>VueResolver: Apply custom-element predicate
VueResolver->>NativeElement: Render matching tags natively
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/render/createRenderer.ts`:
- Around line 87-92: Update the tag-matching callback returned by the pattern
setup to prevent shared global or sticky RegExp state from persisting between
calls: in the flow around regexes and the returned matcher, clone configured
RegExp instances or reset each regex’s lastIndex before every re.test(tag).
Preserve exact-match behavior and add regression coverage for global and sticky
vue.customElements patterns matching successive tags.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 04134625-df7a-40f5-9420-766afec630f0
📒 Files selected for processing (9)
src/build.tssrc/prepare.tssrc/render/createRenderer.tssrc/render/index.tssrc/render/parallel/buildWorker.tssrc/serve.tssrc/tests/render/vue.test.tssrc/types/config.tssrc/types/index.ts
test() on a global/sticky regex advances lastIndex, so reusing the user's instance across the compiler's per-tag isCustomElement calls matched intermittently. Clone without g/y (meaningless for a tag test) instead of mutating the user's regex. Add regression coverage. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Problem
Hand-written non-HTML tags — VML (
v:*) and Office (o:*) markup inside MSO conditional comments — get compiled as Vue components, so the SSR renderer emits aFailed to resolve component: v:groupwarning for each one. There was no way to opt them out: the compiler'sisCustomElementwas hardcoded toamp-*and not exposed through config.Change
Add a
vue.customElementsoption so users can mark extra tags as native custom elements. Matching tags skip component resolution — they render verbatim (no warning) while their Tailwind classes are still scanned.Accepts an exact tag name, a
RegExp, an array of either, or a predicate(tag) => boolean. It composes with the built-inamp-*matcher, which stays always-native regardless.Details
VueConfig.customElementstype + JSDoc; re-exportedVueConfig.toCustomElementPredicate()normalizer increateRenderer, folded intoisCustomElementastag.startsWith('amp-') || isUserCustomElement(tag).config.vue?.customElementsthrough every renderer entry point:build,serve(initial + restart),buildWorker,render,prepare.Tests
6 new cases in
src/tests/render/vue.test.ts: RegExp / exact-string / predicate matching, verbatim render with attributes preserved, a component-collision proof that a marked tag bypasses resolution (vs. resolving by default), andamp-*staying native alongside a custom-element matcher. Full suite green (1766 passed), lint clean.Docs PR to follow in
maizzle/maizzle.com.Summary by CodeRabbit
New Features
amp-*elements remains supported.Documentation