@tanstack/router-plugin 1.167.11 → 1.167.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/core/code-splitter/compilers.cjs +5 -4
- package/dist/cjs/core/code-splitter/compilers.cjs.map +1 -1
- package/dist/cjs/core/code-splitter/compilers.d.cts +2 -10
- package/dist/cjs/core/code-splitter/plugins/framework-plugins.cjs +2 -2
- package/dist/cjs/core/code-splitter/plugins/framework-plugins.cjs.map +1 -1
- package/dist/cjs/core/code-splitter/plugins/framework-plugins.d.cts +1 -0
- package/dist/cjs/core/code-splitter/plugins/react-refresh-ignored-route-exports.cjs +12 -6
- package/dist/cjs/core/code-splitter/plugins/react-refresh-ignored-route-exports.cjs.map +1 -1
- package/dist/cjs/core/code-splitter/plugins/react-refresh-ignored-route-exports.d.cts +3 -1
- package/dist/cjs/core/code-splitter/plugins/react-stable-hmr-split-route-components.cjs +12 -7
- package/dist/cjs/core/code-splitter/plugins/react-stable-hmr-split-route-components.cjs.map +1 -1
- package/dist/cjs/core/code-splitter/plugins/react-stable-hmr-split-route-components.d.cts +3 -1
- package/dist/cjs/core/code-splitter/plugins.d.cts +2 -0
- package/dist/cjs/core/config.cjs +4 -1
- package/dist/cjs/core/config.cjs.map +1 -1
- package/dist/cjs/core/config.d.cts +25 -0
- package/dist/cjs/core/hmr-hot-expression.cjs +27 -0
- package/dist/cjs/core/hmr-hot-expression.cjs.map +1 -0
- package/dist/cjs/core/hmr-hot-expression.d.cts +6 -0
- package/dist/cjs/core/route-autoimport-plugin.cjs +2 -2
- package/dist/cjs/core/route-hmr-statement.cjs +13 -10
- package/dist/cjs/core/route-hmr-statement.cjs.map +1 -1
- package/dist/cjs/core/route-hmr-statement.d.cts +3 -1
- package/dist/cjs/core/router-code-splitter-plugin.cjs +7 -10
- package/dist/cjs/core/router-code-splitter-plugin.cjs.map +1 -1
- package/dist/cjs/core/router-hmr-plugin.cjs +6 -2
- package/dist/cjs/core/router-hmr-plugin.cjs.map +1 -1
- package/dist/cjs/esbuild.d.cts +12 -0
- package/dist/cjs/index.d.cts +1 -1
- package/dist/cjs/rspack.cjs +3 -2
- package/dist/cjs/rspack.cjs.map +1 -1
- package/dist/cjs/rspack.d.cts +6 -135
- package/dist/cjs/vite.d.cts +15 -0
- package/dist/cjs/webpack.cjs +3 -2
- package/dist/cjs/webpack.cjs.map +1 -1
- package/dist/cjs/webpack.d.cts +6 -135
- package/dist/esm/core/code-splitter/compilers.d.ts +2 -10
- package/dist/esm/core/code-splitter/compilers.js +4 -3
- package/dist/esm/core/code-splitter/compilers.js.map +1 -1
- package/dist/esm/core/code-splitter/plugins/framework-plugins.d.ts +1 -0
- package/dist/esm/core/code-splitter/plugins/framework-plugins.js +2 -2
- package/dist/esm/core/code-splitter/plugins/framework-plugins.js.map +1 -1
- package/dist/esm/core/code-splitter/plugins/react-refresh-ignored-route-exports.d.ts +3 -1
- package/dist/esm/core/code-splitter/plugins/react-refresh-ignored-route-exports.js +11 -5
- package/dist/esm/core/code-splitter/plugins/react-refresh-ignored-route-exports.js.map +1 -1
- package/dist/esm/core/code-splitter/plugins/react-stable-hmr-split-route-components.d.ts +3 -1
- package/dist/esm/core/code-splitter/plugins/react-stable-hmr-split-route-components.js +11 -6
- package/dist/esm/core/code-splitter/plugins/react-stable-hmr-split-route-components.js.map +1 -1
- package/dist/esm/core/code-splitter/plugins.d.ts +2 -0
- package/dist/esm/core/config.d.ts +25 -0
- package/dist/esm/core/config.js +4 -1
- package/dist/esm/core/config.js.map +1 -1
- package/dist/esm/core/hmr-hot-expression.d.ts +6 -0
- package/dist/esm/core/hmr-hot-expression.js +23 -0
- package/dist/esm/core/hmr-hot-expression.js.map +1 -0
- package/dist/esm/core/route-autoimport-plugin.js +1 -1
- package/dist/esm/core/route-hmr-statement.d.ts +3 -1
- package/dist/esm/core/route-hmr-statement.js +13 -10
- package/dist/esm/core/route-hmr-statement.js.map +1 -1
- package/dist/esm/core/router-code-splitter-plugin.js +7 -10
- package/dist/esm/core/router-code-splitter-plugin.js.map +1 -1
- package/dist/esm/core/router-hmr-plugin.js +6 -2
- package/dist/esm/core/router-hmr-plugin.js.map +1 -1
- package/dist/esm/esbuild.d.ts +12 -0
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/rspack.d.ts +6 -135
- package/dist/esm/rspack.js +3 -2
- package/dist/esm/rspack.js.map +1 -1
- package/dist/esm/vite.d.ts +15 -0
- package/dist/esm/webpack.d.ts +6 -135
- package/dist/esm/webpack.js +3 -2
- package/dist/esm/webpack.js.map +1 -1
- package/package.json +4 -4
- package/src/core/code-splitter/compilers.ts +8 -12
- package/src/core/code-splitter/plugins/framework-plugins.ts +7 -2
- package/src/core/code-splitter/plugins/react-refresh-ignored-route-exports.ts +12 -4
- package/src/core/code-splitter/plugins/react-stable-hmr-split-route-components.ts +14 -5
- package/src/core/code-splitter/plugins.ts +2 -0
- package/src/core/config.ts +9 -0
- package/src/core/hmr-hot-expression.ts +31 -0
- package/src/core/route-hmr-statement.ts +31 -22
- package/src/core/router-code-splitter-plugin.ts +8 -14
- package/src/core/router-hmr-plugin.ts +10 -1
- package/src/index.ts +1 -0
- package/src/rspack.ts +17 -2
- package/src/webpack.ts +17 -2
package/dist/esm/rspack.d.ts
CHANGED
|
@@ -37,6 +37,9 @@ declare const TanStackRouterGeneratorRspack: (options?: Partial<{
|
|
|
37
37
|
enableRouteGeneration?: boolean | undefined;
|
|
38
38
|
codeSplittingOptions?: CodeSplittingOptions | undefined;
|
|
39
39
|
plugin?: {
|
|
40
|
+
hmr?: {
|
|
41
|
+
hotExpression?: string | undefined;
|
|
42
|
+
} | undefined;
|
|
40
43
|
vite?: {
|
|
41
44
|
environmentName?: string | undefined;
|
|
42
45
|
} | undefined;
|
|
@@ -70,51 +73,7 @@ declare const TanStackRouterGeneratorRspack: (options?: Partial<{
|
|
|
70
73
|
* })
|
|
71
74
|
* ```
|
|
72
75
|
*/
|
|
73
|
-
declare const TanStackRouterCodeSplitterRspack: (options?:
|
|
74
|
-
target: "react" | "solid" | "vue";
|
|
75
|
-
routeFileIgnorePrefix: string;
|
|
76
|
-
routesDirectory: string;
|
|
77
|
-
quoteStyle: "single" | "double";
|
|
78
|
-
semicolons: boolean;
|
|
79
|
-
disableLogging: boolean;
|
|
80
|
-
routeTreeFileHeader: string[];
|
|
81
|
-
indexToken: string | RegExp | {
|
|
82
|
-
regex: string;
|
|
83
|
-
flags?: string | undefined;
|
|
84
|
-
};
|
|
85
|
-
routeToken: string | RegExp | {
|
|
86
|
-
regex: string;
|
|
87
|
-
flags?: string | undefined;
|
|
88
|
-
};
|
|
89
|
-
generatedRouteTree: string;
|
|
90
|
-
disableTypes: boolean;
|
|
91
|
-
addExtensions: string | boolean;
|
|
92
|
-
enableRouteTreeFormatting: boolean;
|
|
93
|
-
tmpDir: string;
|
|
94
|
-
importRoutesUsingAbsolutePaths: boolean;
|
|
95
|
-
enableRouteGeneration?: boolean | undefined;
|
|
96
|
-
codeSplittingOptions?: CodeSplittingOptions | undefined;
|
|
97
|
-
plugin?: {
|
|
98
|
-
vite?: {
|
|
99
|
-
environmentName?: string | undefined;
|
|
100
|
-
} | undefined;
|
|
101
|
-
} | undefined;
|
|
102
|
-
virtualRouteConfig?: string | import('@tanstack/virtual-file-routes').VirtualRootRoute | undefined;
|
|
103
|
-
routeFilePrefix?: string | undefined;
|
|
104
|
-
routeFileIgnorePattern?: string | undefined;
|
|
105
|
-
pathParamsAllowedCharacters?: (";" | ":" | "@" | "&" | "=" | "+" | "$" | ",")[] | undefined;
|
|
106
|
-
verboseFileRoutes?: boolean | undefined;
|
|
107
|
-
routeTreeFileFooter?: string[] | ((...args: unknown[]) => string[]) | undefined;
|
|
108
|
-
autoCodeSplitting?: boolean | undefined;
|
|
109
|
-
customScaffolding?: {
|
|
110
|
-
routeTemplate?: string | undefined;
|
|
111
|
-
lazyRouteTemplate?: string | undefined;
|
|
112
|
-
} | undefined;
|
|
113
|
-
experimental?: {
|
|
114
|
-
enableCodeSplitting?: boolean | undefined;
|
|
115
|
-
} | undefined;
|
|
116
|
-
plugins?: import('@tanstack/router-generator').GeneratorPlugin[] | undefined;
|
|
117
|
-
} | (() => Config)> | undefined) => import('unplugin').RspackPluginInstance;
|
|
76
|
+
declare const TanStackRouterCodeSplitterRspack: (options?: unknown) => import('unplugin').RspackPluginInstance;
|
|
118
77
|
/**
|
|
119
78
|
* @example
|
|
120
79
|
* ```ts
|
|
@@ -128,96 +87,8 @@ declare const TanStackRouterCodeSplitterRspack: (options?: Partial<{
|
|
|
128
87
|
* })
|
|
129
88
|
* ```
|
|
130
89
|
*/
|
|
131
|
-
declare const TanStackRouterRspack: (options?:
|
|
132
|
-
|
|
133
|
-
routeFileIgnorePrefix: string;
|
|
134
|
-
routesDirectory: string;
|
|
135
|
-
quoteStyle: "single" | "double";
|
|
136
|
-
semicolons: boolean;
|
|
137
|
-
disableLogging: boolean;
|
|
138
|
-
routeTreeFileHeader: string[];
|
|
139
|
-
indexToken: string | RegExp | {
|
|
140
|
-
regex: string;
|
|
141
|
-
flags?: string | undefined;
|
|
142
|
-
};
|
|
143
|
-
routeToken: string | RegExp | {
|
|
144
|
-
regex: string;
|
|
145
|
-
flags?: string | undefined;
|
|
146
|
-
};
|
|
147
|
-
generatedRouteTree: string;
|
|
148
|
-
disableTypes: boolean;
|
|
149
|
-
addExtensions: string | boolean;
|
|
150
|
-
enableRouteTreeFormatting: boolean;
|
|
151
|
-
tmpDir: string;
|
|
152
|
-
importRoutesUsingAbsolutePaths: boolean;
|
|
153
|
-
enableRouteGeneration?: boolean | undefined;
|
|
154
|
-
codeSplittingOptions?: CodeSplittingOptions | undefined;
|
|
155
|
-
plugin?: {
|
|
156
|
-
vite?: {
|
|
157
|
-
environmentName?: string | undefined;
|
|
158
|
-
} | undefined;
|
|
159
|
-
} | undefined;
|
|
160
|
-
virtualRouteConfig?: string | import('@tanstack/virtual-file-routes').VirtualRootRoute | undefined;
|
|
161
|
-
routeFilePrefix?: string | undefined;
|
|
162
|
-
routeFileIgnorePattern?: string | undefined;
|
|
163
|
-
pathParamsAllowedCharacters?: (";" | ":" | "@" | "&" | "=" | "+" | "$" | ",")[] | undefined;
|
|
164
|
-
verboseFileRoutes?: boolean | undefined;
|
|
165
|
-
routeTreeFileFooter?: string[] | ((...args: unknown[]) => string[]) | undefined;
|
|
166
|
-
autoCodeSplitting?: boolean | undefined;
|
|
167
|
-
customScaffolding?: {
|
|
168
|
-
routeTemplate?: string | undefined;
|
|
169
|
-
lazyRouteTemplate?: string | undefined;
|
|
170
|
-
} | undefined;
|
|
171
|
-
experimental?: {
|
|
172
|
-
enableCodeSplitting?: boolean | undefined;
|
|
173
|
-
} | undefined;
|
|
174
|
-
plugins?: import('@tanstack/router-generator').GeneratorPlugin[] | undefined;
|
|
175
|
-
}> | undefined) => import('unplugin').RspackPluginInstance;
|
|
176
|
-
declare const tanstackRouter: (options?: Partial<{
|
|
177
|
-
target: "react" | "solid" | "vue";
|
|
178
|
-
routeFileIgnorePrefix: string;
|
|
179
|
-
routesDirectory: string;
|
|
180
|
-
quoteStyle: "single" | "double";
|
|
181
|
-
semicolons: boolean;
|
|
182
|
-
disableLogging: boolean;
|
|
183
|
-
routeTreeFileHeader: string[];
|
|
184
|
-
indexToken: string | RegExp | {
|
|
185
|
-
regex: string;
|
|
186
|
-
flags?: string | undefined;
|
|
187
|
-
};
|
|
188
|
-
routeToken: string | RegExp | {
|
|
189
|
-
regex: string;
|
|
190
|
-
flags?: string | undefined;
|
|
191
|
-
};
|
|
192
|
-
generatedRouteTree: string;
|
|
193
|
-
disableTypes: boolean;
|
|
194
|
-
addExtensions: string | boolean;
|
|
195
|
-
enableRouteTreeFormatting: boolean;
|
|
196
|
-
tmpDir: string;
|
|
197
|
-
importRoutesUsingAbsolutePaths: boolean;
|
|
198
|
-
enableRouteGeneration?: boolean | undefined;
|
|
199
|
-
codeSplittingOptions?: CodeSplittingOptions | undefined;
|
|
200
|
-
plugin?: {
|
|
201
|
-
vite?: {
|
|
202
|
-
environmentName?: string | undefined;
|
|
203
|
-
} | undefined;
|
|
204
|
-
} | undefined;
|
|
205
|
-
virtualRouteConfig?: string | import('@tanstack/virtual-file-routes').VirtualRootRoute | undefined;
|
|
206
|
-
routeFilePrefix?: string | undefined;
|
|
207
|
-
routeFileIgnorePattern?: string | undefined;
|
|
208
|
-
pathParamsAllowedCharacters?: (";" | ":" | "@" | "&" | "=" | "+" | "$" | ",")[] | undefined;
|
|
209
|
-
verboseFileRoutes?: boolean | undefined;
|
|
210
|
-
routeTreeFileFooter?: string[] | ((...args: unknown[]) => string[]) | undefined;
|
|
211
|
-
autoCodeSplitting?: boolean | undefined;
|
|
212
|
-
customScaffolding?: {
|
|
213
|
-
routeTemplate?: string | undefined;
|
|
214
|
-
lazyRouteTemplate?: string | undefined;
|
|
215
|
-
} | undefined;
|
|
216
|
-
experimental?: {
|
|
217
|
-
enableCodeSplitting?: boolean | undefined;
|
|
218
|
-
} | undefined;
|
|
219
|
-
plugins?: import('@tanstack/router-generator').GeneratorPlugin[] | undefined;
|
|
220
|
-
}> | undefined) => import('unplugin').RspackPluginInstance;
|
|
90
|
+
declare const TanStackRouterRspack: (options?: unknown) => import('unplugin').RspackPluginInstance;
|
|
91
|
+
declare const tanstackRouter: (options?: unknown) => import('unplugin').RspackPluginInstance;
|
|
221
92
|
export default TanStackRouterRspack;
|
|
222
93
|
export { configSchema, TanStackRouterRspack, TanStackRouterGeneratorRspack, TanStackRouterCodeSplitterRspack, tanstackRouter, };
|
|
223
94
|
export type { Config, CodeSplittingOptions };
|
package/dist/esm/rspack.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { configSchema } from "./core/config.js";
|
|
2
|
+
import { withHmrHotExpression } from "./core/hmr-hot-expression.js";
|
|
2
3
|
import { unpluginRouterCodeSplitterFactory } from "./core/router-code-splitter-plugin.js";
|
|
3
4
|
import { unpluginRouterGeneratorFactory } from "./core/router-generator-plugin.js";
|
|
4
5
|
import { unpluginRouterComposedFactory } from "./core/router-composed-plugin.js";
|
|
@@ -31,7 +32,7 @@ var TanStackRouterGeneratorRspack = /* @__PURE__ */ createRspackPlugin(unpluginR
|
|
|
31
32
|
* })
|
|
32
33
|
* ```
|
|
33
34
|
*/
|
|
34
|
-
var TanStackRouterCodeSplitterRspack = /* @__PURE__ */ createRspackPlugin(unpluginRouterCodeSplitterFactory);
|
|
35
|
+
var TanStackRouterCodeSplitterRspack = /* @__PURE__ */ createRspackPlugin((options, meta) => unpluginRouterCodeSplitterFactory(withHmrHotExpression(options, "import.meta.webpackHot"), meta));
|
|
35
36
|
/**
|
|
36
37
|
* @example
|
|
37
38
|
* ```ts
|
|
@@ -45,7 +46,7 @@ var TanStackRouterCodeSplitterRspack = /* @__PURE__ */ createRspackPlugin(unplug
|
|
|
45
46
|
* })
|
|
46
47
|
* ```
|
|
47
48
|
*/
|
|
48
|
-
var TanStackRouterRspack = /* @__PURE__ */ createRspackPlugin(unpluginRouterComposedFactory);
|
|
49
|
+
var TanStackRouterRspack = /* @__PURE__ */ createRspackPlugin((options, meta) => unpluginRouterComposedFactory(withHmrHotExpression(options, "import.meta.webpackHot"), meta));
|
|
49
50
|
var tanstackRouter = TanStackRouterRspack;
|
|
50
51
|
//#endregion
|
|
51
52
|
export { TanStackRouterCodeSplitterRspack, TanStackRouterGeneratorRspack, TanStackRouterRspack, TanStackRouterRspack as default, configSchema, tanstackRouter };
|
package/dist/esm/rspack.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rspack.js","names":[],"sources":["../../src/rspack.ts"],"sourcesContent":["import { createRspackPlugin } from 'unplugin'\n\nimport { configSchema } from './core/config'\nimport { unpluginRouterCodeSplitterFactory } from './core/router-code-splitter-plugin'\nimport { unpluginRouterGeneratorFactory } from './core/router-generator-plugin'\nimport { unpluginRouterComposedFactory } from './core/router-composed-plugin'\nimport type { CodeSplittingOptions, Config } from './core/config'\n\n/**\n * @example\n * ```ts\n * export default defineConfig({\n * // ...\n * tools: {\n * rspack: {\n * plugins: [TanStackRouterGeneratorRspack()],\n * },\n * },\n * })\n * ```\n */\nconst TanStackRouterGeneratorRspack = /* #__PURE__ */ createRspackPlugin(\n unpluginRouterGeneratorFactory,\n)\n\n/**\n * @example\n * ```ts\n * export default defineConfig({\n * // ...\n * tools: {\n * rspack: {\n * plugins: [TanStackRouterCodeSplitterRspack()],\n * },\n * },\n * })\n * ```\n */\nconst TanStackRouterCodeSplitterRspack = /* #__PURE__ */ createRspackPlugin(\n unpluginRouterCodeSplitterFactory,\n)\n\n/**\n * @example\n * ```ts\n * export default defineConfig({\n * // ...\n * tools: {\n * rspack: {\n * plugins: [tanstackRouter()],\n * },\n * },\n * })\n * ```\n */\nconst TanStackRouterRspack = /* #__PURE__ */ createRspackPlugin(\n unpluginRouterComposedFactory,\n)\nconst tanstackRouter = TanStackRouterRspack\nexport default TanStackRouterRspack\nexport {\n configSchema,\n TanStackRouterRspack,\n TanStackRouterGeneratorRspack,\n TanStackRouterCodeSplitterRspack,\n tanstackRouter,\n}\nexport type { Config, CodeSplittingOptions }\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"rspack.js","names":[],"sources":["../../src/rspack.ts"],"sourcesContent":["import { createRspackPlugin } from 'unplugin'\n\nimport { configSchema } from './core/config'\nimport { withHmrHotExpression } from './core/hmr-hot-expression'\nimport { unpluginRouterCodeSplitterFactory } from './core/router-code-splitter-plugin'\nimport { unpluginRouterGeneratorFactory } from './core/router-generator-plugin'\nimport { unpluginRouterComposedFactory } from './core/router-composed-plugin'\nimport type { CodeSplittingOptions, Config } from './core/config'\n\n/**\n * @example\n * ```ts\n * export default defineConfig({\n * // ...\n * tools: {\n * rspack: {\n * plugins: [TanStackRouterGeneratorRspack()],\n * },\n * },\n * })\n * ```\n */\nconst TanStackRouterGeneratorRspack = /* #__PURE__ */ createRspackPlugin(\n unpluginRouterGeneratorFactory,\n)\n\n/**\n * @example\n * ```ts\n * export default defineConfig({\n * // ...\n * tools: {\n * rspack: {\n * plugins: [TanStackRouterCodeSplitterRspack()],\n * },\n * },\n * })\n * ```\n */\nconst TanStackRouterCodeSplitterRspack = /* #__PURE__ */ createRspackPlugin(\n (options, meta) =>\n unpluginRouterCodeSplitterFactory(\n withHmrHotExpression(\n options as Partial<Config> | undefined,\n 'import.meta.webpackHot',\n ),\n meta,\n ),\n)\n\n/**\n * @example\n * ```ts\n * export default defineConfig({\n * // ...\n * tools: {\n * rspack: {\n * plugins: [tanstackRouter()],\n * },\n * },\n * })\n * ```\n */\nconst TanStackRouterRspack = /* #__PURE__ */ createRspackPlugin(\n (options, meta) =>\n unpluginRouterComposedFactory(\n withHmrHotExpression(\n options as Partial<Config> | undefined,\n 'import.meta.webpackHot',\n ),\n meta,\n ),\n)\nconst tanstackRouter = TanStackRouterRspack\nexport default TanStackRouterRspack\nexport {\n configSchema,\n TanStackRouterRspack,\n TanStackRouterGeneratorRspack,\n TanStackRouterCodeSplitterRspack,\n tanstackRouter,\n}\nexport type { Config, CodeSplittingOptions }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAsBA,IAAM,gCAAgD,mCACpD,+BACD;;;;;;;;;;;;;;AAeD,IAAM,mCAAmD,oCACtD,SAAS,SACR,kCACE,qBACE,SACA,yBACD,EACD,KACD,CACJ;;;;;;;;;;;;;;AAeD,IAAM,uBAAuC,oCAC1C,SAAS,SACR,8BACE,qBACE,SACA,yBACD,EACD,KACD,CACJ;AACD,IAAM,iBAAiB"}
|
package/dist/esm/vite.d.ts
CHANGED
|
@@ -24,6 +24,9 @@ declare const tanstackRouterAutoImport: (options?: Partial<{
|
|
|
24
24
|
enableRouteGeneration?: boolean | undefined;
|
|
25
25
|
codeSplittingOptions?: CodeSplittingOptions | undefined;
|
|
26
26
|
plugin?: {
|
|
27
|
+
hmr?: {
|
|
28
|
+
hotExpression?: string | undefined;
|
|
29
|
+
} | undefined;
|
|
27
30
|
vite?: {
|
|
28
31
|
environmentName?: string | undefined;
|
|
29
32
|
} | undefined;
|
|
@@ -78,6 +81,9 @@ declare const tanstackRouterGenerator: (options?: Partial<{
|
|
|
78
81
|
enableRouteGeneration?: boolean | undefined;
|
|
79
82
|
codeSplittingOptions?: CodeSplittingOptions | undefined;
|
|
80
83
|
plugin?: {
|
|
84
|
+
hmr?: {
|
|
85
|
+
hotExpression?: string | undefined;
|
|
86
|
+
} | undefined;
|
|
81
87
|
vite?: {
|
|
82
88
|
environmentName?: string | undefined;
|
|
83
89
|
} | undefined;
|
|
@@ -132,6 +138,9 @@ declare const tanStackRouterCodeSplitter: (options?: Partial<{
|
|
|
132
138
|
enableRouteGeneration?: boolean | undefined;
|
|
133
139
|
codeSplittingOptions?: CodeSplittingOptions | undefined;
|
|
134
140
|
plugin?: {
|
|
141
|
+
hmr?: {
|
|
142
|
+
hotExpression?: string | undefined;
|
|
143
|
+
} | undefined;
|
|
135
144
|
vite?: {
|
|
136
145
|
environmentName?: string | undefined;
|
|
137
146
|
} | undefined;
|
|
@@ -186,6 +195,9 @@ declare const tanstackRouter: (options?: Partial<{
|
|
|
186
195
|
enableRouteGeneration?: boolean | undefined;
|
|
187
196
|
codeSplittingOptions?: CodeSplittingOptions | undefined;
|
|
188
197
|
plugin?: {
|
|
198
|
+
hmr?: {
|
|
199
|
+
hotExpression?: string | undefined;
|
|
200
|
+
} | undefined;
|
|
189
201
|
vite?: {
|
|
190
202
|
environmentName?: string | undefined;
|
|
191
203
|
} | undefined;
|
|
@@ -234,6 +246,9 @@ declare const TanStackRouterVite: (options?: Partial<{
|
|
|
234
246
|
enableRouteGeneration?: boolean | undefined;
|
|
235
247
|
codeSplittingOptions?: CodeSplittingOptions | undefined;
|
|
236
248
|
plugin?: {
|
|
249
|
+
hmr?: {
|
|
250
|
+
hotExpression?: string | undefined;
|
|
251
|
+
} | undefined;
|
|
237
252
|
vite?: {
|
|
238
253
|
environmentName?: string | undefined;
|
|
239
254
|
} | undefined;
|
package/dist/esm/webpack.d.ts
CHANGED
|
@@ -33,6 +33,9 @@ declare const TanStackRouterGeneratorWebpack: (options?: Partial<{
|
|
|
33
33
|
enableRouteGeneration?: boolean | undefined;
|
|
34
34
|
codeSplittingOptions?: CodeSplittingOptions | undefined;
|
|
35
35
|
plugin?: {
|
|
36
|
+
hmr?: {
|
|
37
|
+
hotExpression?: string | undefined;
|
|
38
|
+
} | undefined;
|
|
36
39
|
vite?: {
|
|
37
40
|
environmentName?: string | undefined;
|
|
38
41
|
} | undefined;
|
|
@@ -62,51 +65,7 @@ declare const TanStackRouterGeneratorWebpack: (options?: Partial<{
|
|
|
62
65
|
* }
|
|
63
66
|
* ```
|
|
64
67
|
*/
|
|
65
|
-
declare const TanStackRouterCodeSplitterWebpack: (options?:
|
|
66
|
-
target: "react" | "solid" | "vue";
|
|
67
|
-
routeFileIgnorePrefix: string;
|
|
68
|
-
routesDirectory: string;
|
|
69
|
-
quoteStyle: "single" | "double";
|
|
70
|
-
semicolons: boolean;
|
|
71
|
-
disableLogging: boolean;
|
|
72
|
-
routeTreeFileHeader: string[];
|
|
73
|
-
indexToken: string | RegExp | {
|
|
74
|
-
regex: string;
|
|
75
|
-
flags?: string | undefined;
|
|
76
|
-
};
|
|
77
|
-
routeToken: string | RegExp | {
|
|
78
|
-
regex: string;
|
|
79
|
-
flags?: string | undefined;
|
|
80
|
-
};
|
|
81
|
-
generatedRouteTree: string;
|
|
82
|
-
disableTypes: boolean;
|
|
83
|
-
addExtensions: string | boolean;
|
|
84
|
-
enableRouteTreeFormatting: boolean;
|
|
85
|
-
tmpDir: string;
|
|
86
|
-
importRoutesUsingAbsolutePaths: boolean;
|
|
87
|
-
enableRouteGeneration?: boolean | undefined;
|
|
88
|
-
codeSplittingOptions?: CodeSplittingOptions | undefined;
|
|
89
|
-
plugin?: {
|
|
90
|
-
vite?: {
|
|
91
|
-
environmentName?: string | undefined;
|
|
92
|
-
} | undefined;
|
|
93
|
-
} | undefined;
|
|
94
|
-
virtualRouteConfig?: string | import('@tanstack/virtual-file-routes').VirtualRootRoute | undefined;
|
|
95
|
-
routeFilePrefix?: string | undefined;
|
|
96
|
-
routeFileIgnorePattern?: string | undefined;
|
|
97
|
-
pathParamsAllowedCharacters?: (";" | ":" | "@" | "&" | "=" | "+" | "$" | ",")[] | undefined;
|
|
98
|
-
verboseFileRoutes?: boolean | undefined;
|
|
99
|
-
routeTreeFileFooter?: string[] | ((...args: unknown[]) => string[]) | undefined;
|
|
100
|
-
autoCodeSplitting?: boolean | undefined;
|
|
101
|
-
customScaffolding?: {
|
|
102
|
-
routeTemplate?: string | undefined;
|
|
103
|
-
lazyRouteTemplate?: string | undefined;
|
|
104
|
-
} | undefined;
|
|
105
|
-
experimental?: {
|
|
106
|
-
enableCodeSplitting?: boolean | undefined;
|
|
107
|
-
} | undefined;
|
|
108
|
-
plugins?: import('@tanstack/router-generator').GeneratorPlugin[] | undefined;
|
|
109
|
-
} | (() => Config)> | undefined) => import('unplugin').WebpackPluginInstance;
|
|
68
|
+
declare const TanStackRouterCodeSplitterWebpack: (options?: unknown) => import('unplugin').WebpackPluginInstance;
|
|
110
69
|
/**
|
|
111
70
|
* @example
|
|
112
71
|
* ```ts
|
|
@@ -116,96 +75,8 @@ declare const TanStackRouterCodeSplitterWebpack: (options?: Partial<{
|
|
|
116
75
|
* }
|
|
117
76
|
* ```
|
|
118
77
|
*/
|
|
119
|
-
declare const TanStackRouterWebpack: (options?:
|
|
120
|
-
|
|
121
|
-
routeFileIgnorePrefix: string;
|
|
122
|
-
routesDirectory: string;
|
|
123
|
-
quoteStyle: "single" | "double";
|
|
124
|
-
semicolons: boolean;
|
|
125
|
-
disableLogging: boolean;
|
|
126
|
-
routeTreeFileHeader: string[];
|
|
127
|
-
indexToken: string | RegExp | {
|
|
128
|
-
regex: string;
|
|
129
|
-
flags?: string | undefined;
|
|
130
|
-
};
|
|
131
|
-
routeToken: string | RegExp | {
|
|
132
|
-
regex: string;
|
|
133
|
-
flags?: string | undefined;
|
|
134
|
-
};
|
|
135
|
-
generatedRouteTree: string;
|
|
136
|
-
disableTypes: boolean;
|
|
137
|
-
addExtensions: string | boolean;
|
|
138
|
-
enableRouteTreeFormatting: boolean;
|
|
139
|
-
tmpDir: string;
|
|
140
|
-
importRoutesUsingAbsolutePaths: boolean;
|
|
141
|
-
enableRouteGeneration?: boolean | undefined;
|
|
142
|
-
codeSplittingOptions?: CodeSplittingOptions | undefined;
|
|
143
|
-
plugin?: {
|
|
144
|
-
vite?: {
|
|
145
|
-
environmentName?: string | undefined;
|
|
146
|
-
} | undefined;
|
|
147
|
-
} | undefined;
|
|
148
|
-
virtualRouteConfig?: string | import('@tanstack/virtual-file-routes').VirtualRootRoute | undefined;
|
|
149
|
-
routeFilePrefix?: string | undefined;
|
|
150
|
-
routeFileIgnorePattern?: string | undefined;
|
|
151
|
-
pathParamsAllowedCharacters?: (";" | ":" | "@" | "&" | "=" | "+" | "$" | ",")[] | undefined;
|
|
152
|
-
verboseFileRoutes?: boolean | undefined;
|
|
153
|
-
routeTreeFileFooter?: string[] | ((...args: unknown[]) => string[]) | undefined;
|
|
154
|
-
autoCodeSplitting?: boolean | undefined;
|
|
155
|
-
customScaffolding?: {
|
|
156
|
-
routeTemplate?: string | undefined;
|
|
157
|
-
lazyRouteTemplate?: string | undefined;
|
|
158
|
-
} | undefined;
|
|
159
|
-
experimental?: {
|
|
160
|
-
enableCodeSplitting?: boolean | undefined;
|
|
161
|
-
} | undefined;
|
|
162
|
-
plugins?: import('@tanstack/router-generator').GeneratorPlugin[] | undefined;
|
|
163
|
-
}> | undefined) => import('unplugin').WebpackPluginInstance;
|
|
164
|
-
declare const tanstackRouter: (options?: Partial<{
|
|
165
|
-
target: "react" | "solid" | "vue";
|
|
166
|
-
routeFileIgnorePrefix: string;
|
|
167
|
-
routesDirectory: string;
|
|
168
|
-
quoteStyle: "single" | "double";
|
|
169
|
-
semicolons: boolean;
|
|
170
|
-
disableLogging: boolean;
|
|
171
|
-
routeTreeFileHeader: string[];
|
|
172
|
-
indexToken: string | RegExp | {
|
|
173
|
-
regex: string;
|
|
174
|
-
flags?: string | undefined;
|
|
175
|
-
};
|
|
176
|
-
routeToken: string | RegExp | {
|
|
177
|
-
regex: string;
|
|
178
|
-
flags?: string | undefined;
|
|
179
|
-
};
|
|
180
|
-
generatedRouteTree: string;
|
|
181
|
-
disableTypes: boolean;
|
|
182
|
-
addExtensions: string | boolean;
|
|
183
|
-
enableRouteTreeFormatting: boolean;
|
|
184
|
-
tmpDir: string;
|
|
185
|
-
importRoutesUsingAbsolutePaths: boolean;
|
|
186
|
-
enableRouteGeneration?: boolean | undefined;
|
|
187
|
-
codeSplittingOptions?: CodeSplittingOptions | undefined;
|
|
188
|
-
plugin?: {
|
|
189
|
-
vite?: {
|
|
190
|
-
environmentName?: string | undefined;
|
|
191
|
-
} | undefined;
|
|
192
|
-
} | undefined;
|
|
193
|
-
virtualRouteConfig?: string | import('@tanstack/virtual-file-routes').VirtualRootRoute | undefined;
|
|
194
|
-
routeFilePrefix?: string | undefined;
|
|
195
|
-
routeFileIgnorePattern?: string | undefined;
|
|
196
|
-
pathParamsAllowedCharacters?: (";" | ":" | "@" | "&" | "=" | "+" | "$" | ",")[] | undefined;
|
|
197
|
-
verboseFileRoutes?: boolean | undefined;
|
|
198
|
-
routeTreeFileFooter?: string[] | ((...args: unknown[]) => string[]) | undefined;
|
|
199
|
-
autoCodeSplitting?: boolean | undefined;
|
|
200
|
-
customScaffolding?: {
|
|
201
|
-
routeTemplate?: string | undefined;
|
|
202
|
-
lazyRouteTemplate?: string | undefined;
|
|
203
|
-
} | undefined;
|
|
204
|
-
experimental?: {
|
|
205
|
-
enableCodeSplitting?: boolean | undefined;
|
|
206
|
-
} | undefined;
|
|
207
|
-
plugins?: import('@tanstack/router-generator').GeneratorPlugin[] | undefined;
|
|
208
|
-
}> | undefined) => import('unplugin').WebpackPluginInstance;
|
|
78
|
+
declare const TanStackRouterWebpack: (options?: unknown) => import('unplugin').WebpackPluginInstance;
|
|
79
|
+
declare const tanstackRouter: (options?: unknown) => import('unplugin').WebpackPluginInstance;
|
|
209
80
|
export default TanStackRouterWebpack;
|
|
210
81
|
export { configSchema, TanStackRouterWebpack, TanStackRouterGeneratorWebpack, TanStackRouterCodeSplitterWebpack, tanstackRouter, };
|
|
211
82
|
export type { Config, CodeSplittingOptions };
|
package/dist/esm/webpack.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { configSchema } from "./core/config.js";
|
|
2
|
+
import { withHmrHotExpression } from "./core/hmr-hot-expression.js";
|
|
2
3
|
import { unpluginRouterCodeSplitterFactory } from "./core/router-code-splitter-plugin.js";
|
|
3
4
|
import { unpluginRouterGeneratorFactory } from "./core/router-generator-plugin.js";
|
|
4
5
|
import { unpluginRouterComposedFactory } from "./core/router-composed-plugin.js";
|
|
@@ -23,7 +24,7 @@ var TanStackRouterGeneratorWebpack = /* @__PURE__ */ createWebpackPlugin(unplugi
|
|
|
23
24
|
* }
|
|
24
25
|
* ```
|
|
25
26
|
*/
|
|
26
|
-
var TanStackRouterCodeSplitterWebpack = /* @__PURE__ */ createWebpackPlugin(unpluginRouterCodeSplitterFactory);
|
|
27
|
+
var TanStackRouterCodeSplitterWebpack = /* @__PURE__ */ createWebpackPlugin((options, meta) => unpluginRouterCodeSplitterFactory(withHmrHotExpression(options, "import.meta.webpackHot"), meta));
|
|
27
28
|
/**
|
|
28
29
|
* @example
|
|
29
30
|
* ```ts
|
|
@@ -33,7 +34,7 @@ var TanStackRouterCodeSplitterWebpack = /* @__PURE__ */ createWebpackPlugin(unpl
|
|
|
33
34
|
* }
|
|
34
35
|
* ```
|
|
35
36
|
*/
|
|
36
|
-
var TanStackRouterWebpack = /* @__PURE__ */ createWebpackPlugin(unpluginRouterComposedFactory);
|
|
37
|
+
var TanStackRouterWebpack = /* @__PURE__ */ createWebpackPlugin((options, meta) => unpluginRouterComposedFactory(withHmrHotExpression(options, "import.meta.webpackHot"), meta));
|
|
37
38
|
var tanstackRouter = TanStackRouterWebpack;
|
|
38
39
|
//#endregion
|
|
39
40
|
export { TanStackRouterCodeSplitterWebpack, TanStackRouterGeneratorWebpack, TanStackRouterWebpack, TanStackRouterWebpack as default, configSchema, tanstackRouter };
|
package/dist/esm/webpack.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webpack.js","names":[],"sources":["../../src/webpack.ts"],"sourcesContent":["import { createWebpackPlugin } from 'unplugin'\n\nimport { configSchema } from './core/config'\nimport { unpluginRouterCodeSplitterFactory } from './core/router-code-splitter-plugin'\nimport { unpluginRouterGeneratorFactory } from './core/router-generator-plugin'\nimport { unpluginRouterComposedFactory } from './core/router-composed-plugin'\nimport type { CodeSplittingOptions, Config } from './core/config'\n\n/**\n * @example\n * ```ts\n * export default {\n * // ...\n * plugins: [TanStackRouterGeneratorWebpack()],\n * }\n * ```\n */\nconst TanStackRouterGeneratorWebpack = /* #__PURE__ */ createWebpackPlugin(\n unpluginRouterGeneratorFactory,\n)\n\n/**\n * @example\n * ```ts\n * export default {\n * // ...\n * plugins: [TanStackRouterCodeSplitterWebpack()],\n * }\n * ```\n */\nconst TanStackRouterCodeSplitterWebpack = /* #__PURE__ */ createWebpackPlugin(\n unpluginRouterCodeSplitterFactory,\n)\n\n/**\n * @example\n * ```ts\n * export default {\n * // ...\n * plugins: [tanstackRouter()],\n * }\n * ```\n */\nconst TanStackRouterWebpack = /* #__PURE__ */ createWebpackPlugin(\n unpluginRouterComposedFactory,\n)\n\nconst tanstackRouter = TanStackRouterWebpack\nexport default TanStackRouterWebpack\nexport {\n configSchema,\n TanStackRouterWebpack,\n TanStackRouterGeneratorWebpack,\n TanStackRouterCodeSplitterWebpack,\n tanstackRouter,\n}\nexport type { Config, CodeSplittingOptions }\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"webpack.js","names":[],"sources":["../../src/webpack.ts"],"sourcesContent":["import { createWebpackPlugin } from 'unplugin'\n\nimport { configSchema } from './core/config'\nimport { withHmrHotExpression } from './core/hmr-hot-expression'\nimport { unpluginRouterCodeSplitterFactory } from './core/router-code-splitter-plugin'\nimport { unpluginRouterGeneratorFactory } from './core/router-generator-plugin'\nimport { unpluginRouterComposedFactory } from './core/router-composed-plugin'\nimport type { CodeSplittingOptions, Config } from './core/config'\n\n/**\n * @example\n * ```ts\n * export default {\n * // ...\n * plugins: [TanStackRouterGeneratorWebpack()],\n * }\n * ```\n */\nconst TanStackRouterGeneratorWebpack = /* #__PURE__ */ createWebpackPlugin(\n unpluginRouterGeneratorFactory,\n)\n\n/**\n * @example\n * ```ts\n * export default {\n * // ...\n * plugins: [TanStackRouterCodeSplitterWebpack()],\n * }\n * ```\n */\nconst TanStackRouterCodeSplitterWebpack = /* #__PURE__ */ createWebpackPlugin(\n (options, meta) =>\n unpluginRouterCodeSplitterFactory(\n withHmrHotExpression(\n options as Partial<Config> | undefined,\n 'import.meta.webpackHot',\n ),\n meta,\n ),\n)\n\n/**\n * @example\n * ```ts\n * export default {\n * // ...\n * plugins: [tanstackRouter()],\n * }\n * ```\n */\nconst TanStackRouterWebpack = /* #__PURE__ */ createWebpackPlugin(\n (options, meta) =>\n unpluginRouterComposedFactory(\n withHmrHotExpression(\n options as Partial<Config> | undefined,\n 'import.meta.webpackHot',\n ),\n meta,\n ),\n)\n\nconst tanstackRouter = TanStackRouterWebpack\nexport default TanStackRouterWebpack\nexport {\n configSchema,\n TanStackRouterWebpack,\n TanStackRouterGeneratorWebpack,\n TanStackRouterCodeSplitterWebpack,\n tanstackRouter,\n}\nexport type { Config, CodeSplittingOptions }\n"],"mappings":";;;;;;;;;;;;;;;;AAkBA,IAAM,iCAAiD,oCACrD,+BACD;;;;;;;;;;AAWD,IAAM,oCAAoD,qCACvD,SAAS,SACR,kCACE,qBACE,SACA,yBACD,EACD,KACD,CACJ;;;;;;;;;;AAWD,IAAM,wBAAwC,qCAC3C,SAAS,SACR,8BACE,qBACE,SACA,yBACD,EACD,KACD,CACJ;AAED,IAAM,iBAAiB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/router-plugin",
|
|
3
|
-
"version": "1.167.
|
|
3
|
+
"version": "1.167.13",
|
|
4
4
|
"description": "Modern and scalable routing for React applications",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -99,8 +99,8 @@
|
|
|
99
99
|
"chokidar": "^3.6.0",
|
|
100
100
|
"unplugin": "^2.1.2",
|
|
101
101
|
"zod": "^3.24.2",
|
|
102
|
-
"@tanstack/router-core": "1.168.
|
|
103
|
-
"@tanstack/router-generator": "1.166.
|
|
102
|
+
"@tanstack/router-core": "1.168.10",
|
|
103
|
+
"@tanstack/router-generator": "1.166.25",
|
|
104
104
|
"@tanstack/router-utils": "1.161.6",
|
|
105
105
|
"@tanstack/virtual-file-routes": "1.161.7"
|
|
106
106
|
},
|
|
@@ -116,7 +116,7 @@
|
|
|
116
116
|
"vite": ">=5.0.0 || >=6.0.0 || >=7.0.0",
|
|
117
117
|
"vite-plugin-solid": "^2.11.10",
|
|
118
118
|
"webpack": ">=5.92.0",
|
|
119
|
-
"@tanstack/react-router": "^1.168.
|
|
119
|
+
"@tanstack/react-router": "^1.168.14"
|
|
120
120
|
},
|
|
121
121
|
"peerDependenciesMeta": {
|
|
122
122
|
"@rsbuild/core": {
|
|
@@ -18,7 +18,6 @@ import type {
|
|
|
18
18
|
} from './plugins'
|
|
19
19
|
import type { GeneratorResult, ParseAstOptions } from '@tanstack/router-utils'
|
|
20
20
|
import type { CodeSplitGroupings, SplitRouteIdentNodes } from '../constants'
|
|
21
|
-
import type { Config, DeletableNodes } from '../config'
|
|
22
21
|
import type { SplitNodeMeta } from './types'
|
|
23
22
|
|
|
24
23
|
const SPLIT_NODES_CONFIG = new Map<SplitRouteIdentNodes, SplitNodeMeta>([
|
|
@@ -637,16 +636,10 @@ function removeSharedDeclarations(ast: t.File, sharedBindings: Set<string>) {
|
|
|
637
636
|
}
|
|
638
637
|
|
|
639
638
|
export function compileCodeSplitReferenceRoute(
|
|
640
|
-
opts: ParseAstOptions &
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
filename: string
|
|
645
|
-
id: string
|
|
646
|
-
addHmr?: boolean
|
|
647
|
-
sharedBindings?: Set<string>
|
|
648
|
-
compilerPlugins?: Array<ReferenceRouteCompilerPlugin>
|
|
649
|
-
},
|
|
639
|
+
opts: ParseAstOptions &
|
|
640
|
+
CompileCodeSplitReferenceRouteOptions & {
|
|
641
|
+
compilerPlugins?: Array<ReferenceRouteCompilerPlugin>
|
|
642
|
+
},
|
|
650
643
|
): GeneratorResult | null {
|
|
651
644
|
const ast = parseAst(opts)
|
|
652
645
|
|
|
@@ -733,7 +726,9 @@ export function compileCodeSplitReferenceRoute(
|
|
|
733
726
|
|
|
734
727
|
programPath.pushContainer(
|
|
735
728
|
'body',
|
|
736
|
-
createRouteHmrStatement(stableRouteOptionKeys
|
|
729
|
+
createRouteHmrStatement(stableRouteOptionKeys, {
|
|
730
|
+
hotExpression: opts.hmrHotExpression,
|
|
731
|
+
}),
|
|
737
732
|
)
|
|
738
733
|
modified = true
|
|
739
734
|
hmrAdded = true
|
|
@@ -904,6 +899,7 @@ export function compileCodeSplitReferenceRoute(
|
|
|
904
899
|
splitNodeMeta,
|
|
905
900
|
lazyRouteComponentIdent:
|
|
906
901
|
LAZY_ROUTE_COMPONENT_IDENT,
|
|
902
|
+
opts,
|
|
907
903
|
},
|
|
908
904
|
)
|
|
909
905
|
|
|
@@ -7,14 +7,19 @@ import type { Config } from '../../config'
|
|
|
7
7
|
export function getReferenceRouteCompilerPlugins(opts: {
|
|
8
8
|
targetFramework: Config['target']
|
|
9
9
|
addHmr?: boolean
|
|
10
|
+
hmrHotExpression?: string
|
|
10
11
|
}): Array<ReferenceRouteCompilerPlugin> | undefined {
|
|
11
12
|
switch (opts.targetFramework) {
|
|
12
13
|
case 'react': {
|
|
13
14
|
if (opts.addHmr) {
|
|
14
15
|
return [
|
|
15
|
-
createReactRefreshIgnoredRouteExportsPlugin(
|
|
16
|
+
createReactRefreshIgnoredRouteExportsPlugin({
|
|
17
|
+
hotExpression: opts.hmrHotExpression,
|
|
18
|
+
}),
|
|
16
19
|
createReactRefreshRouteComponentsPlugin(),
|
|
17
|
-
createReactStableHmrSplitRouteComponentsPlugin(
|
|
20
|
+
createReactStableHmrSplitRouteComponentsPlugin({
|
|
21
|
+
hotExpression: opts.hmrHotExpression,
|
|
22
|
+
}),
|
|
18
23
|
]
|
|
19
24
|
}
|
|
20
25
|
return undefined
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import * as template from '@babel/template'
|
|
2
2
|
import * as t from '@babel/types'
|
|
3
|
+
import { createHmrHotExpressionAst } from '../../hmr-hot-expression'
|
|
3
4
|
import { getUniqueProgramIdentifier } from '../../utils'
|
|
4
5
|
import type { ReferenceRouteCompilerPlugin } from '../plugins'
|
|
5
6
|
|
|
6
|
-
const
|
|
7
|
+
const buildReactRefreshIgnoredRouteExportsStatements = template.statements(
|
|
7
8
|
`
|
|
8
|
-
|
|
9
|
+
const hot = %%hotExpression%%
|
|
10
|
+
if (hot && typeof window !== 'undefined') {
|
|
11
|
+
;(hot.data ??= {})
|
|
9
12
|
const tsrReactRefresh = window.__TSR_REACT_REFRESH__ ??= (() => {
|
|
10
13
|
const ignoredExportsById = new Map()
|
|
11
14
|
const previousGetIgnoredExports = window.__getReactRefreshIgnoredExports
|
|
@@ -38,7 +41,9 @@ const buildRefreshAnchorStatement = template.statement(
|
|
|
38
41
|
{ syntacticPlaceholders: true },
|
|
39
42
|
)
|
|
40
43
|
|
|
41
|
-
export function createReactRefreshIgnoredRouteExportsPlugin(
|
|
44
|
+
export function createReactRefreshIgnoredRouteExportsPlugin(opts?: {
|
|
45
|
+
hotExpression?: string
|
|
46
|
+
}): ReferenceRouteCompilerPlugin {
|
|
42
47
|
return {
|
|
43
48
|
name: 'react-refresh-ignored-route-exports',
|
|
44
49
|
onAddHmr(ctx) {
|
|
@@ -49,7 +54,10 @@ export function createReactRefreshIgnoredRouteExportsPlugin(): ReferenceRouteCom
|
|
|
49
54
|
|
|
50
55
|
ctx.programPath.pushContainer(
|
|
51
56
|
'body',
|
|
52
|
-
|
|
57
|
+
buildReactRefreshIgnoredRouteExportsStatements({
|
|
58
|
+
hotExpression: createHmrHotExpressionAst(
|
|
59
|
+
opts?.hotExpression ?? ctx.opts.hmrHotExpression,
|
|
60
|
+
),
|
|
53
61
|
moduleId: t.stringLiteral(ctx.opts.id),
|
|
54
62
|
}),
|
|
55
63
|
)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as template from '@babel/template'
|
|
2
2
|
import * as t from '@babel/types'
|
|
3
|
+
import { createHmrHotExpressionAst } from '../../hmr-hot-expression'
|
|
3
4
|
import { getUniqueProgramIdentifier } from '../../utils'
|
|
4
5
|
import type { ReferenceRouteCompilerPlugin } from '../plugins'
|
|
5
6
|
|
|
@@ -13,10 +14,13 @@ function createHotDataKey(exportName: string) {
|
|
|
13
14
|
|
|
14
15
|
const buildStableSplitComponentStatements = template.statements(
|
|
15
16
|
`
|
|
16
|
-
const %%stableComponentIdent%% =
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
const %%stableComponentIdent%% = (() => {
|
|
18
|
+
const hot = %%hotExpression%%
|
|
19
|
+
const hotData = hot ? (hot.data ??= {}) : undefined
|
|
20
|
+
return hotData?.[%%hotDataKey%%] ?? %%lazyRouteComponentIdent%%(%%localImporterIdent%%, %%exporterIdent%%)
|
|
21
|
+
})()
|
|
22
|
+
if (%%hotExpression%%) {
|
|
23
|
+
((%%hotExpression%%).data ??= {})[%%hotDataKey%%] = %%stableComponentIdent%%
|
|
20
24
|
}
|
|
21
25
|
`,
|
|
22
26
|
{
|
|
@@ -24,7 +28,9 @@ const buildStableSplitComponentStatements = template.statements(
|
|
|
24
28
|
},
|
|
25
29
|
)
|
|
26
30
|
|
|
27
|
-
export function createReactStableHmrSplitRouteComponentsPlugin(
|
|
31
|
+
export function createReactStableHmrSplitRouteComponentsPlugin(opts?: {
|
|
32
|
+
hotExpression?: string
|
|
33
|
+
}): ReferenceRouteCompilerPlugin {
|
|
28
34
|
return {
|
|
29
35
|
name: 'react-stable-hmr-split-route-components',
|
|
30
36
|
onSplitRouteProperty(ctx) {
|
|
@@ -43,6 +49,9 @@ export function createReactStableHmrSplitRouteComponentsPlugin(): ReferenceRoute
|
|
|
43
49
|
buildStableSplitComponentStatements({
|
|
44
50
|
stableComponentIdent,
|
|
45
51
|
hotDataKey: t.stringLiteral(hotDataKey),
|
|
52
|
+
hotExpression: createHmrHotExpressionAst(
|
|
53
|
+
opts?.hotExpression ?? ctx.opts.hmrHotExpression,
|
|
54
|
+
),
|
|
46
55
|
lazyRouteComponentIdent: t.identifier(ctx.lazyRouteComponentIdent),
|
|
47
56
|
localImporterIdent: t.identifier(
|
|
48
57
|
ctx.splitNodeMeta.localImporterIdent,
|
|
@@ -11,6 +11,7 @@ export type CompileCodeSplitReferenceRouteOptions = {
|
|
|
11
11
|
filename: string
|
|
12
12
|
id: string
|
|
13
13
|
addHmr?: boolean
|
|
14
|
+
hmrHotExpression?: string
|
|
14
15
|
sharedBindings?: Set<string>
|
|
15
16
|
}
|
|
16
17
|
|
|
@@ -31,6 +32,7 @@ export type ReferenceRouteSplitPropertyCompilerPluginContext = {
|
|
|
31
32
|
prop: t.ObjectProperty
|
|
32
33
|
splitNodeMeta: SplitNodeMeta
|
|
33
34
|
lazyRouteComponentIdent: string
|
|
35
|
+
opts: CompileCodeSplitReferenceRouteOptions
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
export type ReferenceRouteCompilerPluginResult = {
|