Skip to content

Commit b0024d6

Browse files
committed
Revert "fix(solid-router): enable route component HMR for Solid"
This reverts commit b86b061.
1 parent 8eb951b commit b0024d6

23 files changed

Lines changed: 22 additions & 956 deletions

‎.changeset/solid-router-plugin-hmr.md‎

Lines changed: 0 additions & 5 deletions
This file was deleted.

‎packages/router-plugin/src/core/code-splitter/plugins/framework-plugins.ts‎

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createReactRefreshIgnoredRouteExportsPlugin } from './react-refresh-ignored-route-exports'
2-
import { createRefreshRouteComponentsPlugin } from './refresh-route-components'
3-
import { createStableHmrSplitRouteComponentsPlugin } from './stable-hmr-split-route-components'
2+
import { createReactRefreshRouteComponentsPlugin } from './react-refresh-route-components'
3+
import { createReactStableHmrSplitRouteComponentsPlugin } from './react-stable-hmr-split-route-components'
44
import type { ReferenceRouteCompilerPlugin } from '../plugins'
55
import type { Config, HmrStyle } from '../../config'
66

@@ -9,27 +9,19 @@ export function getReferenceRouteCompilerPlugins(opts: {
99
addHmr?: boolean
1010
hmrStyle?: HmrStyle
1111
}): Array<ReferenceRouteCompilerPlugin> | undefined {
12-
if (!opts.addHmr) {
13-
return undefined
14-
}
15-
16-
const hmrStyle = opts.hmrStyle ?? 'vite'
17-
1812
switch (opts.targetFramework) {
1913
case 'react': {
20-
return [
21-
...(hmrStyle === 'vite'
22-
? [createReactRefreshIgnoredRouteExportsPlugin()]
23-
: []),
24-
createRefreshRouteComponentsPlugin(),
25-
createStableHmrSplitRouteComponentsPlugin({ hmrStyle }),
26-
]
27-
}
28-
case 'solid': {
29-
return [
30-
createRefreshRouteComponentsPlugin(),
31-
createStableHmrSplitRouteComponentsPlugin({ hmrStyle }),
32-
]
14+
if (opts.addHmr) {
15+
const hmrStyle = opts.hmrStyle ?? 'vite'
16+
return [
17+
...(hmrStyle === 'vite'
18+
? [createReactRefreshIgnoredRouteExportsPlugin()]
19+
: []),
20+
createReactRefreshRouteComponentsPlugin(),
21+
createReactStableHmrSplitRouteComponentsPlugin({ hmrStyle }),
22+
]
23+
}
24+
return undefined
3325
}
3426
default:
3527
return undefined

packages/router-plugin/src/core/code-splitter/plugins/refresh-route-components.ts renamed to packages/router-plugin/src/core/code-splitter/plugins/react-refresh-route-components.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
} from '../../utils'
66
import type { ReferenceRouteCompilerPlugin } from '../plugins'
77

8-
const ROUTE_COMPONENT_OPTION_KEYS = new Set([
8+
const REACT_REFRESH_ROUTE_COMPONENT_IDENTS = new Set([
99
'component',
1010
'shellComponent',
1111
'pendingComponent',
@@ -27,7 +27,7 @@ function hoistInlineRouteComponents(ctx: {
2727

2828
const key = getObjectPropertyKeyName(prop)
2929

30-
if (!key || !ROUTE_COMPONENT_OPTION_KEYS.has(key)) {
30+
if (!key || !REACT_REFRESH_ROUTE_COMPONENT_IDENTS.has(key)) {
3131
return
3232
}
3333

@@ -60,11 +60,11 @@ function hoistInlineRouteComponents(ctx: {
6060
return true
6161
}
6262

63-
export function createRefreshRouteComponentsPlugin(): ReferenceRouteCompilerPlugin {
63+
export function createReactRefreshRouteComponentsPlugin(): ReferenceRouteCompilerPlugin {
6464
return {
65-
name: 'refresh-route-components',
65+
name: 'react-refresh-route-components',
6666
getStableRouteOptionKeys() {
67-
return [...ROUTE_COMPONENT_OPTION_KEYS]
67+
return [...REACT_REFRESH_ROUTE_COMPONENT_IDENTS]
6868
},
6969
onUnsplittableRoute(ctx) {
7070
if (!ctx.opts.addHmr) {

packages/router-plugin/src/core/code-splitter/plugins/stable-hmr-split-route-components.ts renamed to packages/router-plugin/src/core/code-splitter/plugins/react-stable-hmr-split-route-components.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ function hotExpressionAstFor(hmrStyle: HmrStyle): t.Expression {
3434
)
3535
}
3636

37-
export function createStableHmrSplitRouteComponentsPlugin(opts: {
37+
export function createReactStableHmrSplitRouteComponentsPlugin(opts: {
3838
hmrStyle: HmrStyle
3939
}): ReferenceRouteCompilerPlugin {
4040
return {
41-
name: 'stable-hmr-split-route-components',
41+
name: 'react-stable-hmr-split-route-components',
4242
onSplitRouteProperty(ctx) {
4343
if (ctx.splitNodeMeta.splitStrategy !== 'lazyRouteComponent') {
4444
return

‎packages/router-plugin/tests/add-hmr/snapshots/solid/[email protected]‎

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,9 @@ const $$splitComponentImporter = () => import('arrow-function.tsx?tsr-split=comp
22
import { lazyRouteComponent } from '@tanstack/solid-router';
33
import { createFileRoute } from '@tanstack/solid-router';
44
import { fetchPosts } from '../posts';
5-
const TSRSplitComponent = (() => {
6-
const hot = import.meta.hot;
7-
const hotData = hot ? hot.data ??= {} : undefined;
8-
return hotData?.["tsr-split-component:component"] ?? lazyRouteComponent($$splitComponentImporter, "component");
9-
})();
10-
if (import.meta.hot) {
11-
(import.meta.hot.data ??= {})["tsr-split-component:component"] = TSRSplitComponent;
12-
}
135
export const Route = createFileRoute('/posts')({
146
loader: fetchPosts,
15-
component: TSRSplitComponent
7+
component: lazyRouteComponent($$splitComponentImporter, 'component')
168
});
179
if (import.meta.hot) {
1810
const hot = import.meta.hot;
@@ -40,7 +32,7 @@ if (import.meta.hot) {
4032
const oldHasShellComponent = "shellComponent" in oldRoute.options;
4133
const newHasShellComponent = "shellComponent" in newRoute.options;
4234
const preserveComponentIdentity = oldHasShellComponent === newHasShellComponent;
43-
const componentKeys = ["component", "shellComponent", "pendingComponent", "errorComponent", "notFoundComponent"];
35+
const componentKeys = [];
4436
if (preserveComponentIdentity) {
4537
componentKeys.forEach(key => {
4638
if (key in oldRoute.options && key in newRoute.options) {

‎packages/router-plugin/tests/add-hmr/snapshots/solid/[email protected]‎

Lines changed: 0 additions & 5 deletions
This file was deleted.

‎packages/router-plugin/tests/add-hmr/snapshots/solid/[email protected]‎

Lines changed: 0 additions & 141 deletions
This file was deleted.

‎packages/router-plugin/tests/add-hmr/snapshots/solid/[email protected]‎

Lines changed: 0 additions & 11 deletions
This file was deleted.

‎packages/router-plugin/tests/add-hmr/snapshots/solid/[email protected]‎

Lines changed: 0 additions & 11 deletions
This file was deleted.

‎packages/router-plugin/tests/add-hmr/snapshots/solid/[email protected]‎

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)