Skip to content

Commit 8abfb24

Browse files
fix: avoid unnecessary source map rewriting for files without directives (#20)
- Add hasDirective check in transform method to skip processing when no preprocessor directives are found - This prevents unnecessary source map modifications that conflict with vite-plugin-vue-tracer - Fixes Nuxt DevTools element selection functionality by preserving correct source maps - Only processes files that actually contain #if, #define, #message, or other directives
1 parent fe4d2b6 commit 8abfb24

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/core/context/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ export class Context {
7878

7979
transform(code: string, _id: string) {
8080
const tokens = Lexer.lex(code, this.lexers)
81+
const hasDirective = tokens.some(token => token.type !== 'code')
82+
if (!hasDirective)
83+
return
8184
const ast = Parser.parse(tokens, this.parsers)
8285

8386
const transformed = Transformer.transform(ast, this.transforms)

0 commit comments

Comments
 (0)