Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize deps #193

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
"@radix-ui/react-accordion": "^1.2.2",
"@radix-ui/react-select": "^2.1.5",
"beautify": "^0.0.8",
"bippy": "^0.2.24",
"bippy": "^0.3.0",
"chalk": "^5.4.1",
"clsx": "^2.1.1",
"date-fns": "^4.1.0",
Expand Down
17 changes: 14 additions & 3 deletions src/client/hooks/useReactTreeListeners.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { type Fiber, onCommitFiberRoot, traverseFiber } from "bippy"
import { getFiberSource } from "bippy/source"
import { useCallback, useEffect, useRef } from "react"
import { useNavigation } from "react-router"
import type { HTMLError } from "../context/rdtReducer.js"
import { useHtmlErrors } from "../context/useRDTContext.js"

export const ROUTE_CLASS = "outlet-route"

const isSourceElement = (fiberNode: any) => {
Expand Down Expand Up @@ -153,7 +153,7 @@ export function useReactTreeListeners() {
useEffect(() => {
if (navigation.state !== "idle") return

onCommitFiberRoot((root) =>
onCommitFiberRoot((root) => {
traverseFiber(root.current, (fiberNode) => {
if (isSourceElement(fiberNode) && typeof import.meta.hot !== "undefined") {
const originalSource = fiberNode?._debugSource
Expand All @@ -166,6 +166,17 @@ export function useReactTreeListeners() {
`${fileName}:::${line}` //
)
}
getFiberSource(fiberNode)
.then((source) => {
const line = source?.lineNumber
const fileName = source?.fileName

fiberNode.stateNode?.setAttribute?.(
"data-source",
`${fileName}:::${line}` //
)
})
.catch(console.error)

if (fiberNode?.stateNode && fiberNode?.elementType === "form") {
findIncorrectHtml(fiberNode.child, fiberNode, "form")
Expand All @@ -183,7 +194,7 @@ export function useReactTreeListeners() {
styleNearestElement(fiberNode)
}
})
)
})

setHtmlErrors(invalidHtmlCollection.current)
invalidHtmlCollection.current = []
Expand Down
16 changes: 16 additions & 0 deletions src/vite/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,22 @@ export const reactRouterDevTools: (args?: ReactRouterViteConfig) => Plugin[] = (
return [
{
name: "react-router-devtools",
config(config) {
config.optimizeDeps = {
...config.optimizeDeps,
include: [
...(config.optimizeDeps?.include ?? []),
"react-router-devtools > beautify",
"react-router-devtools > react-diff-viewer-continued",
"react-router-devtools > react-d3-tree",
"react-router-devtools > classnames",
"react-router-devtools > @bkrem/react-transition-group",
"react-router-devtools/client",
"react-router-devtools/context",
"react-router-devtools/server",
],
}
},
apply(config) {
return shouldInject(config.mode, includeClient)
},
Expand Down
Loading