Skip to content
Source
Sign inSign up
TanStack/devtools

fix(devtools-bundler-core): remove plugin imports used directly in the plugins array #578

Openpcbeingused33(GitHub profile, opens in a new tab)wants to merge 5 commits intomain fromrefs/pull/578/headopened View on GitHub

Showing 4 changed files with 96 additions and 3 deletions (loading 1).

x
0 of 4 viewed, 4 left
7 additions and 0 deletions.changeset/remove-devtools-plugin-factory-imports.mdAdded
View file
@@ -0,0 +1,7 @@
+---
+'@tanstack/devtools-bundler-core': patch
+---
+​
+Remove imports of plugins used exclusively in the devtools `plugins` array (for example `plugins={[hotkeysDevtoolsPlugin()]}`) when stripping devtools from production builds. Preserve plugin imports still used by application code and retain the original import kinds in mixed declarations.
+​
+A `walk()` visitor can return `false` to skip the current node’s children. Other return values allow traversal to continue.
3 additions and 3 deletionspackages/devtools-bundler-core/src/ast-utils.tsModified
View file
@@ -49,13 +49,13 @@
​
/**
- * Recursively walk AST nodes, calling `visitor` for each node with a `type`.
+ * Recursively walk AST nodes. Return false from the visitor to skip children.
*/
export function walk(
node: Node,
- visitor: (node: Node, parentNode?: Node) => void,
+ visitor: (node: Node, parentNode?: Node) => unknown,
parentNode?: Node,
) {
- visitor(node, parentNode)
+ if (visitor(node, parentNode) === false) return
forEachChild(node, (child) => walk(child, visitor, node))
86 additions and 0 deletionspackages/devtools-bundler-core/src/remove-devtools.test.tsModified
View file