also looking at this
feat(dx): dev-mode warning for unbalanced template tags (#1769)
#1770
4 files
+277
-0
| @@ -69,6 +69,7 @@ | ||
| 69 | 69 | import type { StxOptions } from './types' |
| 70 | 70 | import path from 'node:path' |
| 71 | 71 | import { processConditionals } from './conditionals' |
| 72 | import { isProduction, isTest } from './env' | |
| 72 | 73 | import { processExpressions, usesSignalsInScript } from './expressions' |
| 73 | 74 | import { LRUCache } from './performance-utils' |
| 74 | 75 | import { createSafeFunction, isExpressionSafe, safeEvaluate, safeEvaluateObject } from './safe-evaluator' |
| @@ -880,6 +881,20 @@ catch (error: unknown) { | ||
| 880 | 881 | partialContent = processStreamDirectives(partialContent, context) |
| 881 | 882 | } |
| 882 | 883 | |
| 884 | // #1769: dev-mode tag-balance heads-up on the RAW partial, before SFC | |
| 885 | // extraction / directive processing auto-closes anything. A dropped | |
| 886 | // </div> silently re-parents following siblings and blanks the page with | |
| 887 | // no error at any layer; a coarse per-tag open/close count catches it. | |
| 888 | // On by default in development; opt-in via `debug` elsewhere; off in prod | |
| 889 | // + the test runner. Pre-gated so the dynamic import is dev-only. | |
| 890 | if (partialContent && (options.debug || (!isProduction() && !isTest()))) { | |
| 891 | try { | |
| 892 | const { warnUnbalancedTags } = await import('./template-tag-balance') | |
| 893 | warnUnbalancedTags(partialContent, includeFilePath) | |
| 894 | } | |
| 895 | catch {} | |
| 896 | } | |
| 897 | ||
| 883 | 898 | // SFC Support: Extract <template>, <script>, and <style> sections |
| 884 | 899 | let workingContent = partialContent |
| 885 | 900 | |