Skip to content
Source
Sign inSign up
TanStack/devtools

fix(devtools-bundler-core): skip primitive values when walking AST children #539

MergedAlemTuzlakmerged 2 commits intomain fromrefs/pull/539/headmerged by AlemTuzlak View on GitHub

Showing 3 changed files with 35 additions and 1 deletion.

x
0 of 3 viewed, 3 left
6 additions and 0 deletions.changeset/ast-child-keys-primitive.mdAdded
View file
@@ -0,0 +1,6 @@
+---
+'@tanstack/devtools-bundler-core': patch
+'@tanstack/devtools-vite': patch
+---
+​
+Source injection no longer stops after the dev server parses a regex literal. Before this fix, a regex literal cached `value` as a child key of `Literal` nodes. Every later file with a string literal then threw during the walk and got zero `data-tsd-source` attributes.
25 additions and 0 deletionspackages/devtools-bundler-core/src/ast-utils.test.tsModified
View file
@@ -44,6 +44,31 @@
​
expect(visited).toEqual([real])
})
+​
+ it('does not throw when a cached child key holds a primitive in a later node', () => {
+ // A regex literal has an object `value`, a string literal has a string
+ // `value`, and both share one type, so the cached keys include `value`.
+ const regexLiteral = {
+ type: 'ForEachSharedLiteral',
+ start: 0,
+ end: 6,
+ value: {},
+ } as unknown as Node
+ const stringLiteral = {
+ type: 'ForEachSharedLiteral',
+ start: 0,
+ end: 12,
+ value: 'use client',
+ } as unknown as Node
+​