@tanstack/router-plugin 1.168.10 → 1.168.12
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 +3 -3
- package/dist/cjs/core/code-splitter/compilers.cjs.map +1 -1
- package/dist/cjs/core/code-splitter/framework-options.cjs.map +1 -1
- package/dist/cjs/core/code-splitter/plugins/framework-plugins.cjs.map +1 -1
- package/dist/cjs/core/code-splitter/plugins/react-refresh-ignored-route-exports.cjs +2 -2
- 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-route-components.cjs +1 -1
- package/dist/cjs/core/code-splitter/plugins/react-refresh-route-components.cjs.map +1 -1
- package/dist/cjs/core/code-splitter/plugins/react-stable-hmr-split-route-components.cjs +2 -2
- package/dist/cjs/core/code-splitter/plugins/react-stable-hmr-split-route-components.cjs.map +1 -1
- package/dist/cjs/core/config.cjs +0 -1
- package/dist/cjs/core/config.cjs.map +1 -1
- package/dist/cjs/core/constants.cjs.map +1 -1
- package/dist/cjs/core/hmr/handle-route-update.cjs.map +1 -1
- package/dist/cjs/core/hmr/select-adapter.cjs.map +1 -1
- package/dist/cjs/core/hmr/vite-adapter.cjs +1 -1
- package/dist/cjs/core/hmr/vite-adapter.cjs.map +1 -1
- package/dist/cjs/core/hmr/webpack-adapter.cjs +1 -1
- package/dist/cjs/core/hmr/webpack-adapter.cjs.map +1 -1
- package/dist/cjs/core/router-code-splitter-plugin.cjs +0 -1
- package/dist/cjs/core/router-code-splitter-plugin.cjs.map +1 -1
- package/dist/cjs/core/router-composed-plugin.cjs +0 -1
- package/dist/cjs/core/router-composed-plugin.cjs.map +1 -1
- package/dist/cjs/core/router-generator-plugin.cjs +1 -2
- package/dist/cjs/core/router-generator-plugin.cjs.map +1 -1
- package/dist/cjs/core/router-hmr-plugin.cjs +0 -1
- package/dist/cjs/core/router-hmr-plugin.cjs.map +1 -1
- package/dist/cjs/core/router-plugin-context.cjs.map +1 -1
- package/dist/cjs/core/utils.cjs +1 -1
- package/dist/cjs/core/utils.cjs.map +1 -1
- package/dist/cjs/esbuild.cjs +0 -1
- package/dist/cjs/esbuild.cjs.map +1 -1
- package/dist/cjs/rspack.cjs +0 -1
- package/dist/cjs/rspack.cjs.map +1 -1
- package/dist/cjs/vite.cjs +0 -1
- package/dist/cjs/vite.cjs.map +1 -1
- package/dist/cjs/webpack.cjs +0 -1
- package/dist/cjs/webpack.cjs.map +1 -1
- package/dist/esm/core/code-splitter/compilers.js.map +1 -1
- package/dist/esm/core/code-splitter/framework-options.js.map +1 -1
- 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.js.map +1 -1
- package/dist/esm/core/code-splitter/plugins/react-refresh-route-components.js.map +1 -1
- package/dist/esm/core/code-splitter/plugins/react-stable-hmr-split-route-components.js.map +1 -1
- package/dist/esm/core/config.js.map +1 -1
- package/dist/esm/core/constants.js.map +1 -1
- package/dist/esm/core/hmr/handle-route-update.js.map +1 -1
- package/dist/esm/core/hmr/select-adapter.js.map +1 -1
- package/dist/esm/core/hmr/vite-adapter.js.map +1 -1
- package/dist/esm/core/hmr/webpack-adapter.js.map +1 -1
- package/dist/esm/core/router-code-splitter-plugin.js.map +1 -1
- package/dist/esm/core/router-composed-plugin.js.map +1 -1
- package/dist/esm/core/router-generator-plugin.js +1 -1
- package/dist/esm/core/router-generator-plugin.js.map +1 -1
- package/dist/esm/core/router-hmr-plugin.js.map +1 -1
- package/dist/esm/core/router-plugin-context.js.map +1 -1
- package/dist/esm/core/utils.js.map +1 -1
- package/dist/esm/esbuild.js.map +1 -1
- package/dist/esm/rspack.js.map +1 -1
- package/dist/esm/vite.js.map +1 -1
- package/dist/esm/webpack.js.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.cjs","names":[],"sources":["../../../src/core/constants.ts"],"sourcesContent":["export const tsrSplit = 'tsr-split'\nexport const tsrShared = 'tsr-shared'\n\nexport const splitRouteIdentNodes = [\n 'loader',\n 'component',\n 'pendingComponent',\n 'errorComponent',\n 'notFoundComponent',\n] as const\nexport type SplitRouteIdentNodes = (typeof splitRouteIdentNodes)[number]\nexport type CodeSplitGroupings = Array<Array<SplitRouteIdentNodes>>\n\nexport const defaultCodeSplitGroupings: CodeSplitGroupings = [\n ['component'],\n ['errorComponent'],\n ['notFoundComponent'],\n]\n"],"mappings":";AAAA,IAAa,WAAW;AACxB,IAAa,YAAY;AAEzB,IAAa,uBAAuB;CAClC;CACA;CACA;CACA;CACA;
|
|
1
|
+
{"version":3,"file":"constants.cjs","names":[],"sources":["../../../src/core/constants.ts"],"sourcesContent":["export const tsrSplit = 'tsr-split'\nexport const tsrShared = 'tsr-shared'\n\nexport const splitRouteIdentNodes = [\n 'loader',\n 'component',\n 'pendingComponent',\n 'errorComponent',\n 'notFoundComponent',\n] as const\nexport type SplitRouteIdentNodes = (typeof splitRouteIdentNodes)[number]\nexport type CodeSplitGroupings = Array<Array<SplitRouteIdentNodes>>\n\nexport const defaultCodeSplitGroupings: CodeSplitGroupings = [\n ['component'],\n ['errorComponent'],\n ['notFoundComponent'],\n]\n"],"mappings":";AAAA,IAAa,WAAW;AACxB,IAAa,YAAY;AAEzB,IAAa,uBAAuB;CAClC;CACA;CACA;CACA;CACA;AACF;AAIA,IAAa,4BAAgD;CAC3D,CAAC,WAAW;CACZ,CAAC,gBAAgB;CACjB,CAAC,mBAAmB;AACtB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handle-route-update.cjs","names":[],"sources":["../../../../src/core/hmr/handle-route-update.ts"],"sourcesContent":["import type {\n AnyRoute,\n AnyRouteMatch,\n AnyRouter,\n RouterWritableStore,\n} from '@tanstack/router-core'\n\ntype AnyRouteWithPrivateProps = AnyRoute & {\n options: Record<string, unknown>\n _componentsPromise?: Promise<void>\n _lazyPromise?: Promise<void>\n update: (options: Record<string, unknown>) => unknown\n _path: string\n _id: string\n _fullPath: string\n _to: string\n}\n\ntype AnyRouterWithPrivateMaps = AnyRouter & {\n routesById: Record<string, AnyRoute>\n buildRouteTree: () => Parameters<AnyRouter['setRoutes']>[0]\n setRoutes: AnyRouter['setRoutes']\n stores: AnyRouter['stores'] & {\n cachedMatchStores: Map<\n string,\n Pick<RouterWritableStore<AnyRouteMatch>, 'get' | 'set'>\n >\n pendingMatchStores: Map<\n string,\n Pick<RouterWritableStore<AnyRouteMatch>, 'get' | 'set'>\n >\n matchStores: Map<\n string,\n Pick<RouterWritableStore<AnyRouteMatch>, 'get' | 'set'>\n >\n }\n}\n\ntype AnyRouteMatchWithPrivateProps = AnyRouteMatch & {\n __beforeLoadContext?: unknown\n __routeContext?: Record<string, unknown>\n context?: Record<string, unknown>\n}\n\nfunction handleRouteUpdate(\n routeId: string,\n newRoute: AnyRouteWithPrivateProps,\n) {\n const router = window.__TSR_ROUTER__ as AnyRouterWithPrivateMaps\n const oldRoute = router.routesById[routeId] as\n | AnyRouteWithPrivateProps\n | undefined\n\n if (!oldRoute) {\n return\n }\n\n // Generated route-tree options are not present on the freshly imported route\n // module, but they must stay on the live route before rebuilding indexes.\n const generatedRouteOptionKeys = new Set(['id', 'path', 'getParentRoute'])\n const generatedRouteOptions: Record<string, unknown> = {}\n generatedRouteOptionKeys.forEach((key) => {\n if (key in oldRoute.options) {\n generatedRouteOptions[key] = oldRoute.options[key]\n }\n })\n\n const removedKeys = new Set<string>()\n Object.keys(oldRoute.options).forEach((key) => {\n if (!generatedRouteOptionKeys.has(key) && !(key in newRoute.options)) {\n removedKeys.add(key)\n delete oldRoute.options[key]\n }\n })\n\n const oldHasShellComponent = 'shellComponent' in oldRoute.options\n const newHasShellComponent = 'shellComponent' in newRoute.options\n const preserveComponentIdentity =\n oldHasShellComponent === newHasShellComponent\n\n // Keys whose identity must remain stable to prevent React from\n // unmounting/remounting the component tree. React Fast Refresh already\n // handles hot-updating the function bodies of these components — our job\n // is only to update non-component route options (loader, head, etc.).\n // For code-split (splittable) routes, the lazyRouteComponent wrapper is\n // already cached in the bundler hot data so its identity is stable.\n // For unsplittable routes (e.g. root routes), the component is a plain\n // function reference that gets recreated on every module re-execution,\n // so we must explicitly preserve the old reference.\n // Preserve component identity so React doesn't remount.\n // React Fast Refresh patches the function bodies in-place.\n const componentKeys = '__TSR_COMPONENT_TYPES__' as unknown as Array<string>\n if (preserveComponentIdentity) {\n componentKeys.forEach((key) => {\n if (key in oldRoute.options && key in newRoute.options) {\n newRoute.options[key] = oldRoute.options[key]\n }\n })\n }\n\n const nextOptions = {\n ...newRoute.options,\n ...generatedRouteOptions,\n }\n\n oldRoute.options = nextOptions\n oldRoute.update(nextOptions)\n oldRoute._componentsPromise = undefined\n oldRoute._lazyPromise = undefined\n\n router.setRoutes(router.buildRouteTree())\n router.resolvePathCache.clear()\n\n const filter = (m: AnyRouteMatch) => m.routeId === oldRoute.id\n const activeMatch = router.stores.matches.get().find(filter)\n const pendingMatch = router.stores.pendingMatches.get().find(filter)\n const cachedMatches = router.stores.cachedMatches.get().filter(filter)\n\n if (activeMatch || pendingMatch || cachedMatches.length > 0) {\n // Clear stale match data for removed route options BEFORE invalidating.\n // Without this, router.invalidate() -> matchRoutes() reuses the existing\n // match from the store (via ...existingMatch spread) and the stale\n // loaderData / __beforeLoadContext survives the reload cycle.\n //\n // We must update the store directly (not via router.updateMatch) because\n // updateMatch wraps in startTransition which may defer the state update,\n // and we need the clear to be visible before invalidate reads the store.\n if (removedKeys.has('loader') || removedKeys.has('beforeLoad')) {\n const matchIds = [\n activeMatch?.id,\n pendingMatch?.id,\n ...cachedMatches.map((match) => match.id),\n ].filter(Boolean) as Array<string>\n router.batch(() => {\n for (const matchId of matchIds) {\n const store =\n router.stores.pendingMatchStores.get(matchId) ||\n router.stores.matchStores.get(matchId) ||\n router.stores.cachedMatchStores.get(matchId)\n if (store) {\n store.set((prev) => {\n const next: AnyRouteMatchWithPrivateProps = { ...prev }\n\n if (removedKeys.has('loader')) {\n next.loaderData = undefined\n }\n if (removedKeys.has('beforeLoad')) {\n next.__beforeLoadContext = undefined\n next.context = rebuildMatchContextWithoutBeforeLoad(next)\n }\n\n return next\n })\n }\n }\n })\n }\n\n router.invalidate({ filter, sync: true })\n }\n\n function getStoreMatch(matchId: string) {\n return (\n router.stores.pendingMatchStores.get(matchId)?.get() ||\n router.stores.matchStores.get(matchId)?.get() ||\n router.stores.cachedMatchStores.get(matchId)?.get()\n )\n }\n\n function getMatchList(matchId: string) {\n const pendingMatches = router.stores.pendingMatches.get()\n if (pendingMatches.some((match) => match.id === matchId)) {\n return pendingMatches\n }\n\n const activeMatches = router.stores.matches.get()\n if (activeMatches.some((match) => match.id === matchId)) {\n return activeMatches\n }\n\n const cachedMatches = router.stores.cachedMatches.get()\n if (cachedMatches.some((match) => match.id === matchId)) {\n return cachedMatches\n }\n\n return []\n }\n\n function getParentMatch(match: AnyRouteMatch) {\n const matchList = getMatchList(match.id)\n const matchIndex = matchList.findIndex((item) => item.id === match.id)\n\n if (matchIndex <= 0) {\n return undefined\n }\n\n const parentMatch = matchList[matchIndex - 1]!\n return getStoreMatch(parentMatch.id) || parentMatch\n }\n\n function rebuildMatchContextWithoutBeforeLoad(\n match: AnyRouteMatchWithPrivateProps,\n ) {\n const parentMatch = getParentMatch(match)\n const getParentContext = (\n router as unknown as {\n getParentContext?: (\n parentMatch?: AnyRouteMatch,\n ) => Record<string, unknown> | undefined\n }\n ).getParentContext\n const parentContext = getParentContext\n ? getParentContext.call(router, parentMatch)\n : (parentMatch?.context ?? router.options.context)\n\n return {\n ...(parentContext ?? {}),\n ...(match.__routeContext ?? {}),\n }\n }\n}\n\nconst handleRouteUpdateStr = handleRouteUpdate.toString()\n\nexport function getHandleRouteUpdateCode(stableRouteOptionKeys: Array<string>) {\n return handleRouteUpdateStr.replace(\n /['\"]__TSR_COMPONENT_TYPES__['\"]/,\n JSON.stringify(st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5C,MAAM,YAAY,aAAa,MAAM,GAAG;EACxC,MAAM,aAAa,UAAU,WAAW,SAAS,KAAK,OAAO,MAAM,GAAG;AAEtE,MAAI,cAAc,EAChB;EAGF,MAAM,cAAc,UAAU,aAAa;AAC3C,SAAO,cAAc,YAAY,GAAG,IAAI;;CAG1C,SAAS,qCACP,OACA;EACA,MAAM,cAAc,eAAe,MAAM;EACzC,MAAM,mBACJ,OAKA;AAKF,SAAO;GACL,IALoB,mBAClB,iBAAiB,KAAK,QAAQ,YAAY,GACzC,aAAa,WAAW,OAAO,QAAQ,YAGrB,EAAE;GACvB,GAAI,MAAM,kBAAkB,EAAE;GAC/B;;;AAIL,IAAM,uBAAuB,kBAAkB,UAAU;AAEzD,SAAgB,yBAAyB,uBAAsC;AAC7E,QAAO,qBAAqB,QAC1B,mCACA,KAAK,UAAU,sBAAsB,CACtC"}
|
|
1
|
+
{"version":3,"file":"handle-route-update.cjs","names":[],"sources":["../../../../src/core/hmr/handle-route-update.ts"],"sourcesContent":["import type {\n AnyRoute,\n AnyRouteMatch,\n AnyRouter,\n RouterWritableStore,\n} from '@tanstack/router-core'\n\ntype AnyRouteWithPrivateProps = AnyRoute & {\n options: Record<string, unknown>\n _componentsPromise?: Promise<void>\n _lazyPromise?: Promise<void>\n update: (options: Record<string, unknown>) => unknown\n _path: string\n _id: string\n _fullPath: string\n _to: string\n}\n\ntype AnyRouterWithPrivateMaps = AnyRouter & {\n routesById: Record<string, AnyRoute>\n buildRouteTree: () => Parameters<AnyRouter['setRoutes']>[0]\n setRoutes: AnyRouter['setRoutes']\n stores: AnyRouter['stores'] & {\n cachedMatchStores: Map<\n string,\n Pick<RouterWritableStore<AnyRouteMatch>, 'get' | 'set'>\n >\n pendingMatchStores: Map<\n string,\n Pick<RouterWritableStore<AnyRouteMatch>, 'get' | 'set'>\n >\n matchStores: Map<\n string,\n Pick<RouterWritableStore<AnyRouteMatch>, 'get' | 'set'>\n >\n }\n}\n\ntype AnyRouteMatchWithPrivateProps = AnyRouteMatch & {\n __beforeLoadContext?: unknown\n __routeContext?: Record<string, unknown>\n context?: Record<string, unknown>\n}\n\nfunction handleRouteUpdate(\n routeId: string,\n newRoute: AnyRouteWithPrivateProps,\n) {\n const router = window.__TSR_ROUTER__ as AnyRouterWithPrivateMaps\n const oldRoute = router.routesById[routeId] as\n | AnyRouteWithPrivateProps\n | undefined\n\n if (!oldRoute) {\n return\n }\n\n // Generated route-tree options are not present on the freshly imported route\n // module, but they must stay on the live route before rebuilding indexes.\n const generatedRouteOptionKeys = new Set(['id', 'path', 'getParentRoute'])\n const generatedRouteOptions: Record<string, unknown> = {}\n generatedRouteOptionKeys.forEach((key) => {\n if (key in oldRoute.options) {\n generatedRouteOptions[key] = oldRoute.options[key]\n }\n })\n\n const removedKeys = new Set<string>()\n Object.keys(oldRoute.options).forEach((key) => {\n if (!generatedRouteOptionKeys.has(key) && !(key in newRoute.options)) {\n removedKeys.add(key)\n delete oldRoute.options[key]\n }\n })\n\n const oldHasShellComponent = 'shellComponent' in oldRoute.options\n const newHasShellComponent = 'shellComponent' in newRoute.options\n const preserveComponentIdentity =\n oldHasShellComponent === newHasShellComponent\n\n // Keys whose identity must remain stable to prevent React from\n // unmounting/remounting the component tree. React Fast Refresh already\n // handles hot-updating the function bodies of these components — our job\n // is only to update non-component route options (loader, head, etc.).\n // For code-split (splittable) routes, the lazyRouteComponent wrapper is\n // already cached in the bundler hot data so its identity is stable.\n // For unsplittable routes (e.g. root routes), the component is a plain\n // function reference that gets recreated on every module re-execution,\n // so we must explicitly preserve the old reference.\n // Preserve component identity so React doesn't remount.\n // React Fast Refresh patches the function bodies in-place.\n const componentKeys = '__TSR_COMPONENT_TYPES__' as unknown as Array<string>\n if (preserveComponentIdentity) {\n componentKeys.forEach((key) => {\n if (key in oldRoute.options && key in newRoute.options) {\n newRoute.options[key] = oldRoute.options[key]\n }\n })\n }\n\n const nextOptions = {\n ...newRoute.options,\n ...generatedRouteOptions,\n }\n\n oldRoute.options = nextOptions\n oldRoute.update(nextOptions)\n oldRoute._componentsPromise = undefined\n oldRoute._lazyPromise = undefined\n\n router.setRoutes(router.buildRouteTree())\n router.resolvePathCache.clear()\n\n const filter = (m: AnyRouteMatch) => m.routeId === oldRoute.id\n const activeMatch = router.stores.matches.get().find(filter)\n const pendingMatch = router.stores.pendingMatches.get().find(filter)\n const cachedMatches = router.stores.cachedMatches.get().filter(filter)\n\n if (activeMatch || pendingMatch || cachedMatches.length > 0) {\n // Clear stale match data for removed route options BEFORE invalidating.\n // Without this, router.invalidate() -> matchRoutes() reuses the existing\n // match from the store (via ...existingMatch spread) and the stale\n // loaderData / __beforeLoadContext survives the reload cycle.\n //\n // We must update the store directly (not via router.updateMatch) because\n // updateMatch wraps in startTransition which may defer the state update,\n // and we need the clear to be visible before invalidate reads the store.\n if (removedKeys.has('loader') || removedKeys.has('beforeLoad')) {\n const matchIds = [\n activeMatch?.id,\n pendingMatch?.id,\n ...cachedMatches.map((match) => match.id),\n ].filter(Boolean) as Array<string>\n router.batch(() => {\n for (const matchId of matchIds) {\n const store =\n router.stores.pendingMatchStores.get(matchId) ||\n router.stores.matchStores.get(matchId) ||\n router.stores.cachedMatchStores.get(matchId)\n if (store) {\n store.set((prev) => {\n const next: AnyRouteMatchWithPrivateProps = { ...prev }\n\n if (removedKeys.has('loader')) {\n next.loaderData = undefined\n }\n if (removedKeys.has('beforeLoad')) {\n next.__beforeLoadContext = undefined\n next.context = rebuildMatchContextWithoutBeforeLoad(next)\n }\n\n return next\n })\n }\n }\n })\n }\n\n router.invalidate({ filter, sync: true })\n }\n\n function getStoreMatch(matchId: string) {\n return (\n router.stores.pendingMatchStores.get(matchId)?.get() ||\n router.stores.matchStores.get(matchId)?.get() ||\n router.stores.cachedMatchStores.get(matchId)?.get()\n )\n }\n\n function getMatchList(matchId: string) {\n const pendingMatches = router.stores.pendingMatches.get()\n if (pendingMatches.some((match) => match.id === matchId)) {\n return pendingMatches\n }\n\n const activeMatches = router.stores.matches.get()\n if (activeMatches.some((match) => match.id === matchId)) {\n return activeMatches\n }\n\n const cachedMatches = router.stores.cachedMatches.get()\n if (cachedMatches.some((match) => match.id === matchId)) {\n return cachedMatches\n }\n\n return []\n }\n\n function getParentMatch(match: AnyRouteMatch) {\n const matchList = getMatchList(match.id)\n const matchIndex = matchList.findIndex((item) => item.id === match.id)\n\n if (matchIndex <= 0) {\n return undefined\n }\n\n const parentMatch = matchList[matchIndex - 1]!\n return getStoreMatch(parentMatch.id) || parentMatch\n }\n\n function rebuildMatchContextWithoutBeforeLoad(\n match: AnyRouteMatchWithPrivateProps,\n ) {\n const parentMatch = getParentMatch(match)\n const getParentContext = (\n router as unknown as {\n getParentContext?: (\n parentMatch?: AnyRouteMatch,\n ) => Record<string, unknown> | undefined\n }\n ).getParentContext\n const parentContext = getParentContext\n ? getParentContext.call(router, parentMatch)\n : (parentMatch?.context ?? router.options.context)\n\n return {\n ...(parentContext ?? {}),\n ...(match.__routeContext ?? {}),\n }\n }\n}\n\nconst handleRouteUpdateStr = handleRouteUpdate.toString()\n\nexport function getHandleRouteUpdateCode(stableRouteOptionKeys: Array<string>) {\n return handleRouteUpdateStr.replace(\n /['\"]__TSR_COMPONENT_TYPES__['\"]/,\n JSON.stringify(stableRouteOptionKeys),\n )\n}\n"],"mappings":";AA4CA,SAAS,kBACP,SACA,UACA;CACA,MAAM,SAAS,OAAO;CACtB,MAAM,WAAW,OAAO,WAAW;CAInC,IAAI,CAAC,UACH;CAKF,MAAM,2BAA2B,IAAI,IAAI;EAAC;EAAM;EAAQ;CAAgB,CAAC;CACzE,MAAM,wBAAiD,CAAC;CACxD,yBAAyB,SAAS,QAAQ;EACxC,IAAI,OAAO,SAAS,SAClB,sBAAsB,OAAO,SAAS,QAAQ;CAElD,CAAC;CAED,MAAM,8BAAc,IAAI,IAAY;CACpC,OAAO,KAAK,SAAS,OAAO,EAAE,SAAS,QAAQ;EAC7C,IAAI,CAAC,yBAAyB,IAAI,GAAG,KAAK,EAAE,OAAO,SAAS,UA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BAAuB,kBAAkB,SAAS;AAExD,SAAgB,yBAAyB,uBAAsC;CAC7E,OAAO,qBAAqB,QAC1B,mCACA,KAAK,UAAU,qBAAqB,CACtC;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select-adapter.cjs","names":[],"sources":["../../../../src/core/hmr/select-adapter.ts"],"sourcesContent":["import { createViteHmrStatement } from './vite-adapter'\nimport { createWebpackHmrStatement } from './webpack-adapter'\nimport type { Config, HmrStyle } from '../config'\nimport type * as t from '@babel/types'\n\nexport type CreateRouteHmrStatementOpts = {\n hmrStyle: HmrStyle\n targetFramework: Config['target']\n routeId?: string\n}\n\n/**\n * Dispatches to the configured HMR adapter. `hmrStyle` is set explicitly by\n * the bundler-specific plugin entry (e.g. `rspack.ts` → `'webpack'`), so there\n * is no runtime inference based on config string shapes.\n */\nexport function createRouteHmrStatement(\n stableRouteOptionKeys: Array<string>,\n opts: CreateRouteHmrStatementOpts,\n): Array<t.Statement> {\n const routeId = opts.routeId === '/__root' ? '__root__' : opts.routeId\n\n if (opts.hmrStyle === 'webpack') {\n return createWebpackHmrStatement(stableRouteOptionKeys, {\n targetFramework: opts.targetFramework,\n routeId,\n })\n }\n return createViteHmrStatement(stableRouteOptionKeys, {\n routeId,\n })\n}\n"],"mappings":";;;;;;;;AAgBA,SAAgB,wBACd,uBACA,MACoB;CACpB,MAAM,UAAU,KAAK,YAAY,YAAY,aAAa,KAAK;
|
|
1
|
+
{"version":3,"file":"select-adapter.cjs","names":[],"sources":["../../../../src/core/hmr/select-adapter.ts"],"sourcesContent":["import { createViteHmrStatement } from './vite-adapter'\nimport { createWebpackHmrStatement } from './webpack-adapter'\nimport type { Config, HmrStyle } from '../config'\nimport type * as t from '@babel/types'\n\nexport type CreateRouteHmrStatementOpts = {\n hmrStyle: HmrStyle\n targetFramework: Config['target']\n routeId?: string\n}\n\n/**\n * Dispatches to the configured HMR adapter. `hmrStyle` is set explicitly by\n * the bundler-specific plugin entry (e.g. `rspack.ts` → `'webpack'`), so there\n * is no runtime inference based on config string shapes.\n */\nexport function createRouteHmrStatement(\n stableRouteOptionKeys: Array<string>,\n opts: CreateRouteHmrStatementOpts,\n): Array<t.Statement> {\n const routeId = opts.routeId === '/__root' ? '__root__' : opts.routeId\n\n if (opts.hmrStyle === 'webpack') {\n return createWebpackHmrStatement(stableRouteOptionKeys, {\n targetFramework: opts.targetFramework,\n routeId,\n })\n }\n return createViteHmrStatement(stableRouteOptionKeys, {\n routeId,\n })\n}\n"],"mappings":";;;;;;;;AAgBA,SAAgB,wBACd,uBACA,MACoB;CACpB,MAAM,UAAU,KAAK,YAAY,YAAY,aAAa,KAAK;CAE/D,IAAI,KAAK,aAAa,WACpB,OAAO,wBAAA,0BAA0B,uBAAuB;EACtD,iBAAiB,KAAK;EACtB;CACF,CAAC;CAEH,OAAO,qBAAA,uBAAuB,uBAAuB,EACnD,QACF,CAAC;AACH"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
2
|
const require_handle_route_update = require("./handle-route-update.cjs");
|
|
3
3
|
let _babel_template = require("@babel/template");
|
|
4
|
-
_babel_template = require_runtime.__toESM(_babel_template);
|
|
4
|
+
_babel_template = require_runtime.__toESM(_babel_template, 1);
|
|
5
5
|
//#region src/core/hmr/vite-adapter.ts
|
|
6
6
|
/**
|
|
7
7
|
* Emits HMR accept code for Vite / native ESM HMR: `import.meta.hot.accept`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite-adapter.cjs","names":[],"sources":["../../../../src/core/hmr/vite-adapter.ts"],"sourcesContent":["import * as template from '@babel/template'\nimport { getHandleRouteUpdateCode } from './handle-route-update'\nimport type * as t from '@babel/types'\n\n/**\n * Emits HMR accept code for Vite / native ESM HMR: `import.meta.hot.accept`\n * with a callback that receives the freshly re-imported module.\n *\n * `targetFramework` is currently unused — Vite's framework-specific fast-refresh\n * plugins handle component body patching via their own accept boundaries — but\n * we take it for API symmetry with `createWebpackHmrStatement`.\n */\nexport function createViteHmrStatement(\n stableRouteOptionKeys: Array<string>,\n opts: {\n routeId?: string\n } = {},\n): Array<t.Statement> {\n const handleRouteUpdateCode = getHandleRouteUpdateCode(stableRouteOptionKeys)\n // The replacement Route object can be uninitialized; keep a generated id as\n // fallback for the existing router route we need to patch.\n const routeIdFallback =\n typeof opts.routeId === 'string' ? JSON.stringify(opts.routeId) : 'Route.id'\n\n return [\n template.statement(\n `\nif (import.meta.hot) {\n const hot = import.meta.hot\n const hotData = hot.data ??= {}\n hot.accept((newModule) => {\n if (Route && newModule && newModule.Route) {\n const routeId = hotData['tsr-route-id'] ?? ${routeIdFallback}\n if (routeId) {\n hotData['tsr-route-id'] = routeId\n }\n (${handleRouteUpdateCode})(routeId, newModule.Route)\n }\n })\n}\n`,\n {\n syntacticPlaceholders: true,\n },\n )(),\n ]\n}\n"],"mappings":";;;;;;;;;;;;;AAYA,SAAgB,uBACd,uBACA,OAEI,
|
|
1
|
+
{"version":3,"file":"vite-adapter.cjs","names":[],"sources":["../../../../src/core/hmr/vite-adapter.ts"],"sourcesContent":["import * as template from '@babel/template'\nimport { getHandleRouteUpdateCode } from './handle-route-update'\nimport type * as t from '@babel/types'\n\n/**\n * Emits HMR accept code for Vite / native ESM HMR: `import.meta.hot.accept`\n * with a callback that receives the freshly re-imported module.\n *\n * `targetFramework` is currently unused — Vite's framework-specific fast-refresh\n * plugins handle component body patching via their own accept boundaries — but\n * we take it for API symmetry with `createWebpackHmrStatement`.\n */\nexport function createViteHmrStatement(\n stableRouteOptionKeys: Array<string>,\n opts: {\n routeId?: string\n } = {},\n): Array<t.Statement> {\n const handleRouteUpdateCode = getHandleRouteUpdateCode(stableRouteOptionKeys)\n // The replacement Route object can be uninitialized; keep a generated id as\n // fallback for the existing router route we need to patch.\n const routeIdFallback =\n typeof opts.routeId === 'string' ? JSON.stringify(opts.routeId) : 'Route.id'\n\n return [\n template.statement(\n `\nif (import.meta.hot) {\n const hot = import.meta.hot\n const hotData = hot.data ??= {}\n hot.accept((newModule) => {\n if (Route && newModule && newModule.Route) {\n const routeId = hotData['tsr-route-id'] ?? ${routeIdFallback}\n if (routeId) {\n hotData['tsr-route-id'] = routeId\n }\n (${handleRouteUpdateCode})(routeId, newModule.Route)\n }\n })\n}\n`,\n {\n syntacticPlaceholders: true,\n },\n )(),\n ]\n}\n"],"mappings":";;;;;;;;;;;;;AAYA,SAAgB,uBACd,uBACA,OAEI,CAAC,GACe;CACpB,MAAM,wBAAwB,4BAAA,yBAAyB,qBAAqB;CAG5E,MAAM,kBACJ,OAAO,KAAK,YAAY,WAAW,KAAK,UAAU,KAAK,OAAO,IAAI;CAEpE,OAAO,CACL,gBAAS,UACP;;;;;;mDAM6C,gBAAgB;;;;SAI1D,sBAAsB;;;;GAKzB,EACE,uBAAuB,KACzB,CACF,EAAE,CACJ;AACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
2
|
const require_handle_route_update = require("./handle-route-update.cjs");
|
|
3
3
|
let _babel_template = require("@babel/template");
|
|
4
|
-
_babel_template = require_runtime.__toESM(_babel_template);
|
|
4
|
+
_babel_template = require_runtime.__toESM(_babel_template, 1);
|
|
5
5
|
//#region src/core/hmr/webpack-adapter.ts
|
|
6
6
|
/**
|
|
7
7
|
* Emits HMR accept code for bundlers with webpack-compatible `module.hot`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webpack-adapter.cjs","names":[],"sources":["../../../../src/core/hmr/webpack-adapter.ts"],"sourcesContent":["import * as template from '@babel/template'\nimport { getHandleRouteUpdateCode } from './handle-route-update'\nimport type { Config } from '../config'\nimport type * as t from '@babel/types'\n\n/**\n * Emits HMR accept code for bundlers with webpack-compatible `module.hot`\n * semantics (classic webpack via `import.meta.webpackHot`, and Rspack).\n *\n * Unlike Vite's `hot.accept((newModule) => {...})` — where the callback receives\n * the freshly re-imported module — webpack re-executes the module factory on\n * accept, so our HMR logic must live at module top level and read the previous\n * `routeId` out of `hot.data`. `hot.dispose` stashes it for the next run, and\n * `hot.accept()` (no callback) enrolls us as a self-accepting boundary.\n *\n * Returns an array of statements that patches route definitions during HMR.\n */\nexport function createWebpackHmrStatement(\n stableRouteOptionKeys: Array<string>,\n opts: {\n targetFramework: Config['target']\n routeId?: string\n },\n): Array<t.Statement> {\n const handleRouteUpdateCode = getHandleRouteUpdateCode(stableRouteOptionKeys)\n const staticRouteIdLiteral =\n typeof opts.routeId === 'string'\n ? JSON.stringify(opts.routeId)\n : 'undefined'\n\n // React-only: route modules aren't React Refresh \"boundaries\" (they export\n // a non-component `Route`), so the bundler's react-refresh runtime won't\n // call `performReactRefresh` for us. We kick it manually after swapping\n // route options so newly-registered component bodies get patched into live\n // fibers.\n //\n // Webpack and Rspack refresh plugins inject `__react_refresh_utils__` via\n // ProvidePlugin. Use it when present instead of importing\n // `react-refresh/runtime`, because Rsbuild apps may use React without the\n // React plugin and therefore may not have that optional dependency installed.\n //\n // Use the same delayed refresh style as Rspack's React Refresh runtime.\n // Route modules and their split component chunks can arrive in separate HMR\n // steps under CI load; a microtask can run before the split chunk registers\n // its new component family, causing the refresh to no-op or remount.\n //\n // For non-React frameworks we skip this entirely.\n const reactRefreshCall =\n opts.targetFramework === 'react'\n ? `\n try {\n const tsrReactRefreshUtils =\n typeof __react_refresh_utils__ !== 'undefined'\n ? __react_refresh_utils__\n : undefined\n const tsrEnqueueUpdate =\n tsrReactRefreshUtils && typeof tsrReactRefreshUtils.enqueueUpdate === 'function'\n ? tsrReactRefreshUtils.enqueueUpdate\n : undefined\n if (tsrEnqueueUpdate) {\n tsrEnqueueUpdate(() => {})\n }\n } catch (_err) { /* noop */ }`\n : ''\n\n return [\n template.statement(\n `\nif (import.meta.webpackHot) {\n const hot = import.meta.webpackHot\n const hotData = hot.data ??= {}\n const routeId = hotData['tsr-route-id'] ?? Route.id ?? (Route.isRoot ? '__root__' : ${staticRouteIdLiteral})\n if (routeId) {\n hotData['tsr-route-id'] = routeId\n }\n const existingRoute =\n typeof window !== 'undefined' && routeId\n ? window.__TSR_ROUTER__?.routesById?.[routeId]\n : undefined\n if (routeId && existingRoute && existingRoute !== Route) {\n (${handleRouteUpdateCode})(routeId, Route)${reactRefreshCall}\n }\n hot.dispose((data) => {\n if (routeId) {\n data['tsr-route-id'] = routeId\n }\n })\n hot.accept()\n}\n`,\n {\n syntacticPlaceholders: true,\n },\n )(),\n ]\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,SAAgB,0BACd,uBACA,MAIoB;CACpB,MAAM,wBAAwB,4BAAA,yBAAyB,
|
|
1
|
+
{"version":3,"file":"webpack-adapter.cjs","names":[],"sources":["../../../../src/core/hmr/webpack-adapter.ts"],"sourcesContent":["import * as template from '@babel/template'\nimport { getHandleRouteUpdateCode } from './handle-route-update'\nimport type { Config } from '../config'\nimport type * as t from '@babel/types'\n\n/**\n * Emits HMR accept code for bundlers with webpack-compatible `module.hot`\n * semantics (classic webpack via `import.meta.webpackHot`, and Rspack).\n *\n * Unlike Vite's `hot.accept((newModule) => {...})` — where the callback receives\n * the freshly re-imported module — webpack re-executes the module factory on\n * accept, so our HMR logic must live at module top level and read the previous\n * `routeId` out of `hot.data`. `hot.dispose` stashes it for the next run, and\n * `hot.accept()` (no callback) enrolls us as a self-accepting boundary.\n *\n * Returns an array of statements that patches route definitions during HMR.\n */\nexport function createWebpackHmrStatement(\n stableRouteOptionKeys: Array<string>,\n opts: {\n targetFramework: Config['target']\n routeId?: string\n },\n): Array<t.Statement> {\n const handleRouteUpdateCode = getHandleRouteUpdateCode(stableRouteOptionKeys)\n const staticRouteIdLiteral =\n typeof opts.routeId === 'string'\n ? JSON.stringify(opts.routeId)\n : 'undefined'\n\n // React-only: route modules aren't React Refresh \"boundaries\" (they export\n // a non-component `Route`), so the bundler's react-refresh runtime won't\n // call `performReactRefresh` for us. We kick it manually after swapping\n // route options so newly-registered component bodies get patched into live\n // fibers.\n //\n // Webpack and Rspack refresh plugins inject `__react_refresh_utils__` via\n // ProvidePlugin. Use it when present instead of importing\n // `react-refresh/runtime`, because Rsbuild apps may use React without the\n // React plugin and therefore may not have that optional dependency installed.\n //\n // Use the same delayed refresh style as Rspack's React Refresh runtime.\n // Route modules and their split component chunks can arrive in separate HMR\n // steps under CI load; a microtask can run before the split chunk registers\n // its new component family, causing the refresh to no-op or remount.\n //\n // For non-React frameworks we skip this entirely.\n const reactRefreshCall =\n opts.targetFramework === 'react'\n ? `\n try {\n const tsrReactRefreshUtils =\n typeof __react_refresh_utils__ !== 'undefined'\n ? __react_refresh_utils__\n : undefined\n const tsrEnqueueUpdate =\n tsrReactRefreshUtils && typeof tsrReactRefreshUtils.enqueueUpdate === 'function'\n ? tsrReactRefreshUtils.enqueueUpdate\n : undefined\n if (tsrEnqueueUpdate) {\n tsrEnqueueUpdate(() => {})\n }\n } catch (_err) { /* noop */ }`\n : ''\n\n return [\n template.statement(\n `\nif (import.meta.webpackHot) {\n const hot = import.meta.webpackHot\n const hotData = hot.data ??= {}\n const routeId = hotData['tsr-route-id'] ?? Route.id ?? (Route.isRoot ? '__root__' : ${staticRouteIdLiteral})\n if (routeId) {\n hotData['tsr-route-id'] = routeId\n }\n const existingRoute =\n typeof window !== 'undefined' && routeId\n ? window.__TSR_ROUTER__?.routesById?.[routeId]\n : undefined\n if (routeId && existingRoute && existingRoute !== Route) {\n (${handleRouteUpdateCode})(routeId, Route)${reactRefreshCall}\n }\n hot.dispose((data) => {\n if (routeId) {\n data['tsr-route-id'] = routeId\n }\n })\n hot.accept()\n}\n`,\n {\n syntacticPlaceholders: true,\n },\n )(),\n ]\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,SAAgB,0BACd,uBACA,MAIoB;CACpB,MAAM,wBAAwB,4BAAA,yBAAyB,qBAAqB;CAC5E,MAAM,uBACJ,OAAO,KAAK,YAAY,WACpB,KAAK,UAAU,KAAK,OAAO,IAC3B;CAmBN,MAAM,mBACJ,KAAK,oBAAoB,UACrB;;;;;;;;;;;;;qCAcA;CAEN,OAAO,CACL,gBAAS,UACP;;;;wFAIkF,qBAAqB;;;;;;;;;OAStG,sBAAsB,mBAAmB,iBAAiB;;;;;;;;;GAU3D,EACE,uBAAuB,KACzB,CACF,EAAE,CACJ;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router-code-splitter-plugin.cjs","names":[],"sources":["../../../src/core/router-code-splitter-plugin.ts"],"sourcesContent":["/**\n * It is important to familiarize yourself with how the code-splitting works in this plugin.\n * https://github.com/TanStack/router/pull/3355\n */\n\nimport { fileURLToPath, pathToFileURL } from 'node:url'\nimport { decodeIdentifier, logDiff } from '@tanstack/router-utils'\nimport { getConfig, splitGroupingsSchema } from './config'\nimport {\n compileCodeSplitReferenceRoute,\n compileCodeSplitSharedRoute,\n compileCodeSplitVirtualRoute,\n computeSharedBindings,\n detectCodeSplitGroupingsFromRoute,\n} from './code-splitter/compilers'\nimport { getReferenceRouteCompilerPlugins } from './code-splitter/plugins/framework-plugins'\nimport {\n defaultCodeSplitGroupings,\n splitRouteIdentNodes,\n tsrShared,\n tsrSplit,\n} from './constants'\nimport { debug, normalizePath, routeFactoryCallCodeFilter } from './utils'\nimport { createRouterPluginContext } from './router-plugin-context'\nimport type { CodeSplitGroupings, SplitRouteIdentNodes } from './constants'\nimport type { GetRoutesByFileMapResultValue } from '@tanstack/router-generator'\nimport type { Config } from './config'\nimport type { RouterPluginContext } from './router-plugin-context'\nimport type {\n UnpluginFactory,\n TransformResult as UnpluginTransformResult,\n} from 'unplugin'\n\nconst CODE_SPLITTER_PLUGIN_NAME =\n 'tanstack-router:code-splitter:compile-reference-file'\n\ntype TransformationPluginInfo = {\n pluginNames: Array<string>\n pkg: string\n usage: string\n}\n\n/**\n * JSX transformation plugins grouped by framework.\n * These plugins must come AFTER the TanStack Router plugin in the Vite config.\n */\nconst TRANSFORMATION_PLUGINS_BY_FRAMEWORK: Record<\n string,\n Array<TransformationPluginInfo>\n> = {\n react: [\n {\n // Babel-based React plugin\n pluginNames: ['vite:react-babel', 'vite:react-refresh'],\n pkg: '@vitejs/plugin-react',\n usage: 'react()',\n },\n {\n // SWC-based React plugin\n pluginNames: ['vite:react-swc', 'vite:react-swc:resolve-runtime'],\n pkg: '@vitejs/plugin-react-swc',\n usage: 'reactSwc()',\n },\n {\n // OXC-based React plugin (deprecated but should still be handled)\n pluginNames: ['vite:react-oxc:config', 'vite:react-oxc:refresh-runtime'],\n pkg: '@vitejs/plugin-react-oxc',\n usage: 'reactOxc()',\n },\n ],\n solid: [\n {\n pluginNames: ['solid'],\n pkg: 'vite-plugin-solid',\n usage: 'solid()',\n },\n ],\n}\n\nexport function createRouterCodeSplitterPlugin(\n options: Partial<Config | (() => Config)> | undefined = {},\n routerPluginContext: RouterPluginContext,\n): ReturnType<UnpluginFactory<Partial<Config | (() => Config)> | undefined>> {\n let ROOT: string = process.cwd()\n let userConfig: Config\n\n function initUserConfig() {\n if (typeof options === 'function') {\n userConfig = options()\n } else {\n userConfig = getConfig(options, ROOT)\n }\n }\n const isProduction = process.env.NODE_ENV === 'production'\n // Map from normalized route file path → set of shared binding names.\n // Populated by the reference compiler, consumed by virtual and shared compilers.\n const sharedBindingsMap = new Map<string, Set<string>>()\n\n const getGlobalCodeSplitGroupings = () => {\n return (\n userConfig.codeSplittingOptions?.defaultBehavior ||\n defaultCodeSplitGroupings\n )\n }\n const getShouldSplitFn = () => {\n return userConfig.codeSplittingOptions?.splitBehavior\n }\n\n const handleCompilingReferenceFile = (\n code: string,\n id: string,\n generatorNodeInfo: GetRoutesByFileMapResultValue,\n ): UnpluginTransformResult => {\n if (debug) console.info('Compiling Route: ', id)\n\n const fromCode = detectCodeSplitGroupingsFromRoute({\n code,\n filename: id,\n })\n\n if (fromCode.groupings !== undefined) {\n const res = splitGroupingsSchema.safeParse(fromCode.groupings)\n if (!res.success) {\n const message = res.error.issues.map((e) => e.message).join('. ')\n throw new Error(\n `The groupings for the route \"${id}\" are invalid.\\n${message}`,\n )\n }\n }\n\n const userShouldSplitFn = getShouldSplitFn()\n\n const pluginSplitBehavior = userShouldSplitFn?.({\n routeId: generatorNodeInfo.routeId,\n }) as CodeSplitGroupings | undefined\n\n if (pluginSplitBehavior) {\n const res = splitGroupingsSchema.safeParse(pluginSplitBehavior)\n if (!res.success) {\n const message = res.error.issues.map((e) => e.message).join('. ')\n throw new Error(\n `The groupings returned when using \\`splitBehavior\\` for the route \"${id}\" are invalid.\\n${message}`,\n )\n }\n }\n\n const splitGroupings: CodeSplitGroupings =\n fromCode.groupings ?? pluginSplitBehavior ?? getGlobalCodeSplitGroupings()\n\n // Compute shared bindings before compiling the reference route\n const sharedBindings = computeSharedBindings({\n code,\n filename: id,\n codeSplitGroupings: splitGroupings,\n })\n if (sharedBindings.size > 0) {\n sharedBindingsMap.set(id, sharedBindings)\n } else {\n sharedBindingsMap.delete(id)\n }\n\n const addHmr =\n (userConfig.codeSplittingOptions?.addHmr ?? true) && !isProduction\n const hmrStyle = userConfig.plugin?.hmr?.style ?? 'vite'\n\n const compiledReferenceRoute = compileCodeSplitReferenceRoute({\n code,\n codeSplitGroupings: splitGroupings,\n targetFramework: userConfig.target,\n filename: id,\n id,\n deleteNodes: userConfig.codeSplittingOptions?.deleteNodes\n ? new Set(userConfig.codeSplittingOptions.deleteNodes)\n : undefined,\n addHmr,\n hmrStyle,\n hmrRouteId: generatorNodeInfo.routeId,\n sharedBindings: sharedBindings.size > 0 ? sharedBindings : undefined,\n compilerPlugins: [\n ...(getReferenceRouteCompilerPlugins({\n targetFramework: userConfig.target,\n addHmr,\n hmrStyle,\n }) ?? []),\n ...(userConfig.codeSplittingOptions?.compilerPlugins ?? []),\n ],\n })\n\n if (compiledReferenceRoute === null) {\n if (debug) {\n console.info(\n `No changes made to route \"${id}\", skipping code-splitting.`,\n )\n }\n return null\n }\n if (debug) {\n logDiff(code, compiledReferenceRoute.code)\n console.log('Output:\\n', compiledReferenceRoute.code + '\\n\\n')\n }\n\n return compiledReferenceRoute\n }\n\n const handleCompilingVirtualFile = (\n code: string,\n id: string,\n ): UnpluginTransformResult => {\n if (debug) console.info('Splitting Route: ', id)\n\n const [_, ...pathnameParts] = id.split('?')\n\n const searchParams = new URLSearchParams(pathnameParts.join('?'))\n const splitValue = searchParams.get(tsrSplit)\n\n if (!splitValue) {\n throw new Error(\n `The split value for the virtual route \"${id}\" was not found.`,\n )\n }\n\n const rawGrouping = decodeIdentifier(splitValue)\n const grouping = [...new Set(rawGrouping)].filter((p) =>\n splitRouteIdentNodes.includes(p as any),\n ) as Array<SplitRouteIdentNodes>\n\n const baseId = id.split('?')[0]!\n const resolvedSharedBindings = sharedBindingsMap.get(baseId)\n\n const result = compileCodeSplitVirtualRoute({\n code,\n filename: id,\n splitTargets: grouping,\n sharedBindings: resolvedSharedBindings,\n })\n\n if (debug) {\n logDiff(code, result.code)\n console.log('Output:\\n', result.code + '\\n\\n')\n }\n\n return result\n }\n\n return [\n {\n name: 'tanstack-router:code-splitter:compile-reference-file',\n enforce: 'pre',\n\n transform: {\n filter: {\n id: {\n exclude: [tsrSplit, tsrShared],\n // this is necessary for webpack / rspack to avoid matching .html files\n include: /\\.(m|c)?(j|t)sx?$/,\n },\n code: {\n include: routeFactoryCallCodeFilter,\n },\n },\n handler(code, id) {\n const normalizedId = normalizePath(id)\n const generatorFileInfo =\n routerPluginContext.routesByFile.get(normalizedId)\n if (generatorFileInfo) {\n return handleCompilingReferenceFile(\n code,\n normalizedId,\n generatorFileInfo,\n )\n }\n\n return null\n },\n },\n\n vite: {\n configResolved(config) {\n ROOT = config.root\n initUserConfig()\n\n // Validate plugin order - router must come before JSX transformation plugins\n const routerPluginIndex = config.plugins.findIndex(\n (p) => p.name === CODE_SPLITTER_PLUGIN_NAME,\n )\n\n if (routerPluginIndex === -1) return\n\n const frameworkPlugins =\n TRANSFORMATION_PLUGINS_BY_FRAMEWORK[userConfig.target]\n if (!frameworkPlugins) return\n\n for (const transformPlugin of frameworkPlugins) {\n const transformPluginIndex = config.plugins.findIndex((p) =>\n transformPlugin.pluginNames.includes(p.name),\n )\n\n if (\n transformPluginIndex !== -1 &&\n transformPluginIndex < routerPluginIndex\n ) {\n throw new Error(\n `Plugin order error: '${transformPlugin.pkg}' is placed before '@tanstack/router-plugin'.\\n\\n` +\n `The TanStack Router plugin must come BEFORE JSX transformation plugins.\\n\\n` +\n `Please update your Vite config:\\n\\n` +\n ` plugins: [\\n` +\n ` tanstackRouter(),\\n` +\n ` ${transformPlugin.usage},\\n` +\n ` ]\\n`,\n )\n }\n }\n },\n applyToEnvironment(environment) {\n if (userConfig.plugin?.vite?.environmentName) {\n return userConfig.plugin.vite.environmentName === environment.name\n }\n return true\n },\n },\n\n rspack() {\n ROOT = process.cwd()\n initUserConfig()\n },\n\n webpack() {\n ROOT = process.cwd()\n initUserConfig()\n },\n },\n {\n name: 'tanstack-router:code-splitter:compile-virtual-file',\n enforce: 'pre',\n\n transform: {\n filter: {\n id: /tsr-split/,\n },\n handler(code, id) {\n const url = pathToFileURL(id)\n url.searchParams.delete('v')\n const normalizedId = normalizePath(fileURLToPath(url))\n return handleCompilingVirtualFile(code, normalizedId)\n },\n },\n\n vite: {\n applyToEnvironment(environment) {\n if (userConfig.plugin?.vite?.environmentName) {\n return userConfig.plugin.vite.environmentName === environment.name\n }\n return true\n },\n },\n },\n {\n name: 'tanstack-router:code-splitter:compile-shared-file',\n enforce: 'pre',\n\n transform: {\n filter: {\n id: /tsr-shared/,\n },\n handler(code, id) {\n const url = pathToFileURL(id)\n url.searchParams.delete('v')\n const normalizedId = normalizePath(fileURLToPath(url))\n const [baseId] = normalizedId.split('?')\n\n if (!baseId) return null\n\n const sharedBindings = sharedBindingsMap.get(baseId)\n if (!sharedBindings || sharedBindings.size === 0) return null\n\n if (debug) console.info('Compiling Shared Module: ', id)\n\n const result = compileCodeSplitSharedRoute({\n code,\n sharedBindings,\n filename: normalizedId,\n })\n\n if (debug) {\n logDiff(code, result.code)\n console.log('Output:\\n', result.code + '\\n\\n')\n }\n\n return result\n },\n },\n\n vite: {\n applyToEnvironment(environment) {\n if (userConfig.plugin?.vite?.environmentName) {\n return userConfig.plugin.vite.environmentName === environment.name\n }\n return true\n },\n },\n },\n ]\n}\n\nexport const unpluginRouterCodeSplitterFactory: UnpluginFactory<\n Partial<Config | (() => Config)> | undefined\n> = (options = {}) => {\n return createRouterCodeSplitterPlugin(options, createRouterPluginContext())\n}\n"],"mappings":";;;;;;;;;;;;;;AAiCA,IAAM,4BACJ;;;;;AAYF,IAAM,sCAGF;CACF,OAAO;EACL;GAEE,aAAa,CAAC,oBAAoB,qBAAqB;GACvD,KAAK;GACL,OAAO;GACR;EACD;GAEE,aAAa,CAAC,kBAAkB,iCAAiC;GACjE,KAAK;GACL,OAAO;GACR;EACD;GAEE,aAAa,CAAC,yBAAyB,iCAAiC;GACxE,KAAK;GACL,OAAO;GACR;EACF;CACD,OAAO,CACL;EACE,aAAa,CAAC,QAAQ;EACtB,KAAK;EACL,OAAO;EACR,CACF;CACF;AAED,SAAgB,+BACd,UAAwD,EAAE,EAC1D,qBAC2E;CAC3E,IAAI,OAAe,QAAQ,KAAK;CAChC,IAAI;CAEJ,SAAS,iBAAiB;AACxB,MAAI,OAAO,YAAY,WACrB,cAAa,SAAS;MAEtB,cAAa,eAAA,UAAU,SAAS,KAAK;;CAGzC,MAAM,eAAA,QAAA,IAAA,aAAwC;CAG9C,MAAM,oCAAoB,IAAI,KAA0B;CAExD,MAAM,oCAAoC;AACxC,SACE,WAAW,sBAAsB,mBACjC,kBAAA;;CAGJ,MAAM,yBAAyB;AAC7B,SAAO,WAAW,sBAAsB;;CAG1C,MAAM,gCACJ,MACA,IACA,sBAC4B;AAC5B,MAAI,cAAA,MAAO,SAAQ,KAAK,qBAAqB,GAAG;EAEhD,MAAM,WAAW,kBAAA,kCAAkC;GACjD;GACA,UAAU;GACX,CAAC;AAEF,MAAI,SAAS,cAAc,KAAA,GAAW;GACpC,MAAM,MAAM,eAAA,q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AG;AAC7B,SAAI,aAAa,OAAO,IAAI;KAC5B,MAAM,eAAe,cAAA,eAAA,GAAA,SAAA,eAA4B,IAAI,CAAC;KACtD,MAAM,CAAC,UAAU,aAAa,MAAM,IAAI;AAExC,SAAI,CAAC,OAAQ,QAAO;KAEpB,MAAM,iBAAiB,kBAAkB,IAAI,OAAO;AACpD,SAAI,CAAC,kBAAkB,eAAe,SAAS,EAAG,QAAO;AAEzD,SAAI,cAAA,MAAO,SAAQ,KAAK,6BAA6B,GAAG;KAExD,MAAM,SAAS,kBAAA,4BAA4B;MACzC;MACA;MACA,UAAU;MACX,CAAC;AAEF,SAAI,cAAA,OAAO;AACT,OAAA,GAAA,uBAAA,SAAQ,MAAM,OAAO,KAAK;AAC1B,cAAQ,IAAI,aAAa,OAAO,OAAO,OAAO;;AAGhD,YAAO;;IAEV;GAED,MAAM,EACJ,mBAAmB,aAAa;AAC9B,QAAI,WAAW,QAAQ,MAAM,gBAC3B,QAAO,WAAW,OAAO,KAAK,oBAAoB,YAAY;AAEhE,WAAO;MAEV;GACF;EACF;;AAGH,IAAa,qCAER,UAAU,EAAE,KAAK;AACpB,QAAO,+BAA+B,SAAS,8BAAA,2BAA2B,CAAC"}
|
|
1
|
+
{"version":3,"file":"router-code-splitter-plugin.cjs","names":[],"sources":["../../../src/core/router-code-splitter-plugin.ts"],"sourcesContent":["/**\n * It is important to familiarize yourself with how the code-splitting works in this plugin.\n * https://github.com/TanStack/router/pull/3355\n */\n\nimport { fileURLToPath, pathToFileURL } from 'node:url'\nimport { decodeIdentifier, logDiff } from '@tanstack/router-utils'\nimport { getConfig, splitGroupingsSchema } from './config'\nimport {\n compileCodeSplitReferenceRoute,\n compileCodeSplitSharedRoute,\n compileCodeSplitVirtualRoute,\n computeSharedBindings,\n detectCodeSplitGroupingsFromRoute,\n} from './code-splitter/compilers'\nimport { getReferenceRouteCompilerPlugins } from './code-splitter/plugins/framework-plugins'\nimport {\n defaultCodeSplitGroupings,\n splitRouteIdentNodes,\n tsrShared,\n tsrSplit,\n} from './constants'\nimport { debug, normalizePath, routeFactoryCallCodeFilter } from './utils'\nimport { createRouterPluginContext } from './router-plugin-context'\nimport type { CodeSplitGroupings, SplitRouteIdentNodes } from './constants'\nimport type { GetRoutesByFileMapResultValue } from '@tanstack/router-generator'\nimport type { Config } from './config'\nimport type { RouterPluginContext } from './router-plugin-context'\nimport type {\n UnpluginFactory,\n TransformResult as UnpluginTransformResult,\n} from 'unplugin'\n\nconst CODE_SPLITTER_PLUGIN_NAME =\n 'tanstack-router:code-splitter:compile-reference-file'\n\ntype TransformationPluginInfo = {\n pluginNames: Array<string>\n pkg: string\n usage: string\n}\n\n/**\n * JSX transformation plugins grouped by framework.\n * These plugins must come AFTER the TanStack Router plugin in the Vite config.\n */\nconst TRANSFORMATION_PLUGINS_BY_FRAMEWORK: Record<\n string,\n Array<TransformationPluginInfo>\n> = {\n react: [\n {\n // Babel-based React plugin\n pluginNames: ['vite:react-babel', 'vite:react-refresh'],\n pkg: '@vitejs/plugin-react',\n usage: 'react()',\n },\n {\n // SWC-based React plugin\n pluginNames: ['vite:react-swc', 'vite:react-swc:resolve-runtime'],\n pkg: '@vitejs/plugin-react-swc',\n usage: 'reactSwc()',\n },\n {\n // OXC-based React plugin (deprecated but should still be handled)\n pluginNames: ['vite:react-oxc:config', 'vite:react-oxc:refresh-runtime'],\n pkg: '@vitejs/plugin-react-oxc',\n usage: 'reactOxc()',\n },\n ],\n solid: [\n {\n pluginNames: ['solid'],\n pkg: 'vite-plugin-solid',\n usage: 'solid()',\n },\n ],\n}\n\nexport function createRouterCodeSplitterPlugin(\n options: Partial<Config | (() => Config)> | undefined = {},\n routerPluginContext: RouterPluginContext,\n): ReturnType<UnpluginFactory<Partial<Config | (() => Config)> | undefined>> {\n let ROOT: string = process.cwd()\n let userConfig: Config\n\n function initUserConfig() {\n if (typeof options === 'function') {\n userConfig = options()\n } else {\n userConfig = getConfig(options, ROOT)\n }\n }\n const isProduction = process.env.NODE_ENV === 'production'\n // Map from normalized route file path → set of shared binding names.\n // Populated by the reference compiler, consumed by virtual and shared compilers.\n const sharedBindingsMap = new Map<string, Set<string>>()\n\n const getGlobalCodeSplitGroupings = () => {\n return (\n userConfig.codeSplittingOptions?.defaultBehavior ||\n defaultCodeSplitGroupings\n )\n }\n const getShouldSplitFn = () => {\n return userConfig.codeSplittingOptions?.splitBehavior\n }\n\n const handleCompilingReferenceFile = (\n code: string,\n id: string,\n generatorNodeInfo: GetRoutesByFileMapResultValue,\n ): UnpluginTransformResult => {\n if (debug) console.info('Compiling Route: ', id)\n\n const fromCode = detectCodeSplitGroupingsFromRoute({\n code,\n filename: id,\n })\n\n if (fromCode.groupings !== undefined) {\n const res = splitGroupingsSchema.safeParse(fromCode.groupings)\n if (!res.success) {\n const message = res.error.issues.map((e) => e.message).join('. ')\n throw new Error(\n `The groupings for the route \"${id}\" are invalid.\\n${message}`,\n )\n }\n }\n\n const userShouldSplitFn = getShouldSplitFn()\n\n const pluginSplitBehavior = userShouldSplitFn?.({\n routeId: generatorNodeInfo.routeId,\n }) as CodeSplitGroupings | undefined\n\n if (pluginSplitBehavior) {\n const res = splitGroupingsSchema.safeParse(pluginSplitBehavior)\n if (!res.success) {\n const message = res.error.issues.map((e) => e.message).join('. ')\n throw new Error(\n `The groupings returned when using \\`splitBehavior\\` for the route \"${id}\" are invalid.\\n${message}`,\n )\n }\n }\n\n const splitGroupings: CodeSplitGroupings =\n fromCode.groupings ?? pluginSplitBehavior ?? getGlobalCodeSplitGroupings()\n\n // Compute shared bindings before compiling the reference route\n const sharedBindings = computeSharedBindings({\n code,\n filename: id,\n codeSplitGroupings: splitGroupings,\n })\n if (sharedBindings.size > 0) {\n sharedBindingsMap.set(id, sharedBindings)\n } else {\n sharedBindingsMap.delete(id)\n }\n\n const addHmr =\n (userConfig.codeSplittingOptions?.addHmr ?? true) && !isProduction\n const hmrStyle = userConfig.plugin?.hmr?.style ?? 'vite'\n\n const compiledReferenceRoute = compileCodeSplitReferenceRoute({\n code,\n codeSplitGroupings: splitGroupings,\n targetFramework: userConfig.target,\n filename: id,\n id,\n deleteNodes: userConfig.codeSplittingOptions?.deleteNodes\n ? new Set(userConfig.codeSplittingOptions.deleteNodes)\n : undefined,\n addHmr,\n hmrStyle,\n hmrRouteId: generatorNodeInfo.routeId,\n sharedBindings: sharedBindings.size > 0 ? sharedBindings : undefined,\n compilerPlugins: [\n ...(getReferenceRouteCompilerPlugins({\n targetFramework: userConfig.target,\n addHmr,\n hmrStyle,\n }) ?? []),\n ...(userConfig.codeSplittingOptions?.compilerPlugins ?? []),\n ],\n })\n\n if (compiledReferenceRoute === null) {\n if (debug) {\n console.info(\n `No changes made to route \"${id}\", skipping code-splitting.`,\n )\n }\n return null\n }\n if (debug) {\n logDiff(code, compiledReferenceRoute.code)\n console.log('Output:\\n', compiledReferenceRoute.code + '\\n\\n')\n }\n\n return compiledReferenceRoute\n }\n\n const handleCompilingVirtualFile = (\n code: string,\n id: string,\n ): UnpluginTransformResult => {\n if (debug) console.info('Splitting Route: ', id)\n\n const [_, ...pathnameParts] = id.split('?')\n\n const searchParams = new URLSearchParams(pathnameParts.join('?'))\n const splitValue = searchParams.get(tsrSplit)\n\n if (!splitValue) {\n throw new Error(\n `The split value for the virtual route \"${id}\" was not found.`,\n )\n }\n\n const rawGrouping = decodeIdentifier(splitValue)\n const grouping = [...new Set(rawGrouping)].filter((p) =>\n splitRouteIdentNodes.includes(p as any),\n ) as Array<SplitRouteIdentNodes>\n\n const baseId = id.split('?')[0]!\n const resolvedSharedBindings = sharedBindingsMap.get(baseId)\n\n const result = compileCodeSplitVirtualRoute({\n code,\n filename: id,\n splitTargets: grouping,\n sharedBindings: resolvedSharedBindings,\n })\n\n if (debug) {\n logDiff(code, result.code)\n console.log('Output:\\n', result.code + '\\n\\n')\n }\n\n return result\n }\n\n return [\n {\n name: 'tanstack-router:code-splitter:compile-reference-file',\n enforce: 'pre',\n\n transform: {\n filter: {\n id: {\n exclude: [tsrSplit, tsrShared],\n // this is necessary for webpack / rspack to avoid matching .html files\n include: /\\.(m|c)?(j|t)sx?$/,\n },\n code: {\n include: routeFactoryCallCodeFilter,\n },\n },\n handler(code, id) {\n const normalizedId = normalizePath(id)\n const generatorFileInfo =\n routerPluginContext.routesByFile.get(normalizedId)\n if (generatorFileInfo) {\n return handleCompilingReferenceFile(\n code,\n normalizedId,\n generatorFileInfo,\n )\n }\n\n return null\n },\n },\n\n vite: {\n configResolved(config) {\n ROOT = config.root\n initUserConfig()\n\n // Validate plugin order - router must come before JSX transformation plugins\n const routerPluginIndex = config.plugins.findIndex(\n (p) => p.name === CODE_SPLITTER_PLUGIN_NAME,\n )\n\n if (routerPluginIndex === -1) return\n\n const frameworkPlugins =\n TRANSFORMATION_PLUGINS_BY_FRAMEWORK[userConfig.target]\n if (!frameworkPlugins) return\n\n for (const transformPlugin of frameworkPlugins) {\n const transformPluginIndex = config.plugins.findIndex((p) =>\n transformPlugin.pluginNames.includes(p.name),\n )\n\n if (\n transformPluginIndex !== -1 &&\n transformPluginIndex < routerPluginIndex\n ) {\n throw new Error(\n `Plugin order error: '${transformPlugin.pkg}' is placed before '@tanstack/router-plugin'.\\n\\n` +\n `The TanStack Router plugin must come BEFORE JSX transformation plugins.\\n\\n` +\n `Please update your Vite config:\\n\\n` +\n ` plugins: [\\n` +\n ` tanstackRouter(),\\n` +\n ` ${transformPlugin.usage},\\n` +\n ` ]\\n`,\n )\n }\n }\n },\n applyToEnvironment(environment) {\n if (userConfig.plugin?.vite?.environmentName) {\n return userConfig.plugin.vite.environmentName === environment.name\n }\n return true\n },\n },\n\n rspack() {\n ROOT = process.cwd()\n initUserConfig()\n },\n\n webpack() {\n ROOT = process.cwd()\n initUserConfig()\n },\n },\n {\n name: 'tanstack-router:code-splitter:compile-virtual-file',\n enforce: 'pre',\n\n transform: {\n filter: {\n id: /tsr-split/,\n },\n handler(code, id) {\n const url = pathToFileURL(id)\n url.searchParams.delete('v')\n const normalizedId = normalizePath(fileURLToPath(url))\n return handleCompilingVirtualFile(code, normalizedId)\n },\n },\n\n vite: {\n applyToEnvironment(environment) {\n if (userConfig.plugin?.vite?.environmentName) {\n return userConfig.plugin.vite.environmentName === environment.name\n }\n return true\n },\n },\n },\n {\n name: 'tanstack-router:code-splitter:compile-shared-file',\n enforce: 'pre',\n\n transform: {\n filter: {\n id: /tsr-shared/,\n },\n handler(code, id) {\n const url = pathToFileURL(id)\n url.searchParams.delete('v')\n const normalizedId = normalizePath(fileURLToPath(url))\n const [baseId] = normalizedId.split('?')\n\n if (!baseId) return null\n\n const sharedBindings = sharedBindingsMap.get(baseId)\n if (!sharedBindings || sharedBindings.size === 0) return null\n\n if (debug) console.info('Compiling Shared Module: ', id)\n\n const result = compileCodeSplitSharedRoute({\n code,\n sharedBindings,\n filename: normalizedId,\n })\n\n if (debug) {\n logDiff(code, result.code)\n console.log('Output:\\n', result.code + '\\n\\n')\n }\n\n return result\n },\n },\n\n vite: {\n applyToEnvironment(environment) {\n if (userConfig.plugin?.vite?.environmentName) {\n return userConfig.plugin.vite.environmentName === environment.name\n }\n return true\n },\n },\n },\n ]\n}\n\nexport const unpluginRouterCodeSplitterFactory: UnpluginFactory<\n Partial<Config | (() => Config)> | undefined\n> = (options = {}) => {\n return createRouterCodeSplitterPlugin(options, createRouterPluginContext())\n}\n"],"mappings":";;;;;;;;;;;;;AAiCA,IAAM,4BACJ;;;;;AAYF,IAAM,sCAGF;CACF,OAAO;EACL;GAEE,aAAa,CAAC,oBAAoB,oBAAoB;GACtD,KAAK;GACL,OAAO;EACT;EACA;GAEE,aAAa,CAAC,kBAAkB,gCAAgC;GAChE,KAAK;GACL,OAAO;EACT;EACA;GAEE,aAAa,CAAC,yBAAyB,gCAAgC;GACvE,KAAK;GACL,OAAO;EACT;CACF;CACA,OAAO,CACL;EACE,aAAa,CAAC,OAAO;EACrB,KAAK;EACL,OAAO;CACT,CACF;AACF;AAEA,SAAgB,+BACd,UAAwD,CAAC,GACzD,qBAC2E;CAC3E,IAAI,OAAe,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oB,YAAY;IAEhE,OAAO;GACT,EACF;EACF;CACF;AACF;AAEA,IAAa,qCAER,UAAU,CAAC,MAAM;CACpB,OAAO,+BAA+B,SAAS,8BAAA,0BAA0B,CAAC;AAC5E"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
require("../_virtual/_rolldown/runtime.cjs");
|
|
2
1
|
const require_router_plugin_context = require("./router-plugin-context.cjs");
|
|
3
2
|
const require_router_code_splitter_plugin = require("./router-code-splitter-plugin.cjs");
|
|
4
3
|
const require_router_generator_plugin = require("./router-generator-plugin.cjs");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router-composed-plugin.cjs","names":[],"sources":["../../../src/core/router-composed-plugin.ts"],"sourcesContent":["import { getConfig } from '@tanstack/router-generator'\nimport { createRouterGeneratorPlugin } from './router-generator-plugin'\nimport { createRouterCodeSplitterPlugin } from './router-code-splitter-plugin'\nimport { createRouterHmrPlugin } from './router-hmr-plugin'\nimport { createRouterPluginContext } from './router-plugin-context'\nimport type { Config } from './config'\nimport type {\n RspackCompiler,\n UnpluginFactory,\n UnpluginOptions,\n WebpackCompiler,\n} from 'unplugin'\n\nconst INLINE_CSS_DEFAULT_DEFINES = {\n 'process.env.TSS_INLINE_CSS_ENABLED': JSON.stringify('false'),\n 'import.meta.env.TSS_INLINE_CSS_ENABLED': JSON.stringify('false'),\n}\n\ntype EsbuildOptionsWithDefine = Parameters<\n NonNullable<NonNullable<UnpluginOptions['esbuild']>['config']>\n>[0]\n\nfunction applyWebpackInlineCssDefaultDefinePlugin(compiler: WebpackCompiler) {\n new compiler.webpack.DefinePlugin(INLINE_CSS_DEFAULT_DEFINES).apply(compiler)\n}\n\nfunction applyRspackInlineCssDefaultDefinePlugin(compiler: RspackCompiler) {\n new compiler.webpack.DefinePlugin(INLINE_CSS_DEFAULT_DEFINES).apply(compiler)\n}\n\nexport const unpluginRouterComposedFactory: UnpluginFactory<\n Partial<Config | (() => Config)> | undefined\n> = (options = {}, _meta) => {\n const ROOT: string = process.cwd()\n const userConfig = getConfig(\n (typeof options === 'function' ? options() : options) as Partial<Config>,\n ROOT,\n )\n const routerPluginContext = createRouterPluginContext()\n\n const getPlugin = (plugin: ReturnType<UnpluginFactory<any>>) => {\n if (!Array.isArray(plugin)) {\n return [plugin]\n }\n return plugin\n }\n\n const routerGenerator = getPlugin(\n createRouterGeneratorPlugin(options, routerPluginContext),\n )\n const routerCodeSplitter = getPlugin(\n createRouterCodeSplitterPlugin(options, routerPluginContext),\n )\n\n const result = [\n {\n name: 'tanstack:router-inline-css-defaults',\n vite: {\n config() {\n return {\n define: {\n ...INLINE_CSS_DEFAULT_DEFINES,\n },\n }\n },\n },\n webpack(compiler: WebpackCompiler) {\n applyWebpackInlineCssDefaultDefinePlugin(compiler)\n },\n rspack(compiler: RspackCompiler) {\n applyRspackInlineCssDefaultDefinePlugin(compiler)\n },\n esbuild: {\n config(options: EsbuildOptionsWithDefine) {\n options.define = {\n ...INLINE_CSS_DEFAULT_DEFINES,\n ...options.define,\n }\n },\n },\n },\n ...routerGenerator,\n ]\n if (userConfig.autoCodeSplitting) {\n result.push(...routerCodeSplitter)\n }\n\n const isProduction = process.env.NODE_ENV === 'production'\n\n if (!isProduction && !userConfig.autoCodeSplitting) {\n const routerHmr = getPlugin(\n createRouterHmrPlugin(options, routerPluginContext),\n )\n result.push(...routerHmr)\n }\n return result\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"router-composed-plugin.cjs","names":[],"sources":["../../../src/core/router-composed-plugin.ts"],"sourcesContent":["import { getConfig } from '@tanstack/router-generator'\nimport { createRouterGeneratorPlugin } from './router-generator-plugin'\nimport { createRouterCodeSplitterPlugin } from './router-code-splitter-plugin'\nimport { createRouterHmrPlugin } from './router-hmr-plugin'\nimport { createRouterPluginContext } from './router-plugin-context'\nimport type { Config } from './config'\nimport type {\n RspackCompiler,\n UnpluginFactory,\n UnpluginOptions,\n WebpackCompiler,\n} from 'unplugin'\n\nconst INLINE_CSS_DEFAULT_DEFINES = {\n 'process.env.TSS_INLINE_CSS_ENABLED': JSON.stringify('false'),\n 'import.meta.env.TSS_INLINE_CSS_ENABLED': JSON.stringify('false'),\n}\n\ntype EsbuildOptionsWithDefine = Parameters<\n NonNullable<NonNullable<UnpluginOptions['esbuild']>['config']>\n>[0]\n\nfunction applyWebpackInlineCssDefaultDefinePlugin(compiler: WebpackCompiler) {\n new compiler.webpack.DefinePlugin(INLINE_CSS_DEFAULT_DEFINES).apply(compiler)\n}\n\nfunction applyRspackInlineCssDefaultDefinePlugin(compiler: RspackCompiler) {\n new compiler.webpack.DefinePlugin(INLINE_CSS_DEFAULT_DEFINES).apply(compiler)\n}\n\nexport const unpluginRouterComposedFactory: UnpluginFactory<\n Partial<Config | (() => Config)> | undefined\n> = (options = {}, _meta) => {\n const ROOT: string = process.cwd()\n const userConfig = getConfig(\n (typeof options === 'function' ? options() : options) as Partial<Config>,\n ROOT,\n )\n const routerPluginContext = createRouterPluginContext()\n\n const getPlugin = (plugin: ReturnType<UnpluginFactory<any>>) => {\n if (!Array.isArray(plugin)) {\n return [plugin]\n }\n return plugin\n }\n\n const routerGenerator = getPlugin(\n createRouterGeneratorPlugin(options, routerPluginContext),\n )\n const routerCodeSplitter = getPlugin(\n createRouterCodeSplitterPlugin(options, routerPluginContext),\n )\n\n const result = [\n {\n name: 'tanstack:router-inline-css-defaults',\n vite: {\n config() {\n return {\n define: {\n ...INLINE_CSS_DEFAULT_DEFINES,\n },\n }\n },\n },\n webpack(compiler: WebpackCompiler) {\n applyWebpackInlineCssDefaultDefinePlugin(compiler)\n },\n rspack(compiler: RspackCompiler) {\n applyRspackInlineCssDefaultDefinePlugin(compiler)\n },\n esbuild: {\n config(options: EsbuildOptionsWithDefine) {\n options.define = {\n ...INLINE_CSS_DEFAULT_DEFINES,\n ...options.define,\n }\n },\n },\n },\n ...routerGenerator,\n ]\n if (userConfig.autoCodeSplitting) {\n result.push(...routerCodeSplitter)\n }\n\n const isProduction = process.env.NODE_ENV === 'production'\n\n if (!isProduction && !userConfig.autoCodeSplitting) {\n const routerHmr = getPlugin(\n createRouterHmrPlugin(options, routerPluginContext),\n )\n result.push(...routerHmr)\n }\n return result\n}\n"],"mappings":";;;;;;AAaA,IAAM,6BAA6B;CACjC,sCAAsC,KAAK,UAAU,OAAO;CAC5D,0CAA0C,KAAK,UAAU,OAAO;AAClE;AAMA,SAAS,yCAAyC,UAA2B;CAC3E,IAAI,SAAS,QAAQ,aAAa,0BAA0B,EAAE,MAAM,QAAQ;AAC9E;AAEA,SAAS,wCAAwC,UAA0B;CACzE,IAAI,SAAS,QAAQ,aAAa,0BAA0B,EAAE,MAAM,QAAQ;AAC9E;AAEA,IAAa,iCAER,UAAU,CAAC,GAAG,UAAU;CAC3B,MAAM,OAAe,QAAQ,IAAI;CACjC,MAAM,cAAA,GAAA,2BAAA,WACH,OAAO,YAAY,aAAa,QAAQ,IAAI,SAC7C,IACF;CACA,MAAM,sBAAsB,8BAAA,0BAA0B;CAEtD,MAAM,aAAa,WAA6C;EAC9D,IAAI,CAAC,MAAM,QAAQ,MAAM,GACvB,OAAO,CAAC,MAAM;EAEhB,OAAO;CACT;CAEA,MAAM,kBAAkB,UACtB,gCAAA,4BAA4B,SAAS,mBAAmB,CAC1D;CACA,MAAM,qBAAqB,UACzB,oCAAA,+BAA+B,SAAS,mBAAmB,CAC7D;CAEA,MAAM,SAAS,CACb;EACE,MAAM;EACN,MAAM,EACJ,SAAS;GACP,OAAO,EACL,QAAQ,EACN,GAAG,2BACL,EACF;EACF,EACF;EACA,QAAQ,UAA2B;GACjC,yCAAyC,QAAQ;EACnD;EACA,OAAO,UAA0B;GAC/B,wCAAwC,QAAQ;EAClD;EACA,SAAS,EACP,OAAO,SAAmC;GACxC,QAAQ,SAAS;IACf,GAAG;IACH,GAAG,QAAQ;GACb;EACF,EACF;CACF,GACA,GAAG,eACL;CACA,IAAI,WAAW,mBACb,OAAO,KAAK,GAAG,kBAAkB;CAKnC,IAAI,EAAA,QAAA,IAAA,aAF0C,iBAEzB,CAAC,WAAW,mBAAmB;EAClD,MAAM,YAAY,UAChB,0BAAA,sBAAsB,SAAS,mBAAmB,CACpD;EACA,OAAO,KAAK,GAAG,SAAS;CAC1B;CACA,OAAO;AACT"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
require("../_virtual/_rolldown/runtime.cjs");
|
|
2
1
|
const require_config = require("./config.cjs");
|
|
3
2
|
const require_router_plugin_context = require("./router-plugin-context.cjs");
|
|
4
3
|
let _tanstack_router_generator = require("@tanstack/router-generator");
|
|
@@ -90,7 +89,7 @@ function createRouterGeneratorPlugin(options = {}, routerPluginContext) {
|
|
|
90
89
|
if (handle) await handle.close();
|
|
91
90
|
});
|
|
92
91
|
compiler.hooks.done.tap(PLUGIN_NAME, () => {
|
|
93
|
-
console.info("✅
|
|
92
|
+
console.info("✅ unplugin:router-generator: route-tree generation done");
|
|
94
93
|
});
|
|
95
94
|
},
|
|
96
95
|
esbuild: { config() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router-generator-plugin.cjs","names":[],"sources":["../../../src/core/router-generator-plugin.ts"],"sourcesContent":["import { isAbsolute, join, normalize } from 'node:path'\nimport { Generator, resolveConfigPath } from '@tanstack/router-generator'\nimport { getConfig } from './config'\nimport { createRouterPluginContext } from './router-plugin-context'\n\nimport type { GeneratorEvent } from '@tanstack/router-generator'\nimport type { FSWatcher } from 'chokidar'\nimport type { UnpluginFactory } from 'unplugin'\nimport type { Config } from './config'\nimport type { RouterPluginContext } from './router-plugin-context'\n\nconst PLUGIN_NAME = 'unplugin:router-generator'\n\nexport function createRouterGeneratorPlugin(\n options: Partial<Config | (() => Config)> | undefined = {},\n routerPluginContext: RouterPluginContext,\n): ReturnType<UnpluginFactory<Partial<Config | (() => Config)> | undefined>> {\n let ROOT: string = process.cwd()\n let userConfig: Config\n let generator: Generator\n\n const routeGenerationDisabled = () =>\n userConfig.enableRouteGeneration === false\n const getRoutesDirectoryPath = () => {\n return isAbsolute(userConfig.routesDirectory)\n ? userConfig.routesDirectory\n : join(ROOT, userConfig.routesDirectory)\n }\n\n const initConfigAndGenerator = (opts?: { root?: string }) => {\n if (opts?.root) {\n ROOT = opts.root\n }\n if (typeof options === 'function') {\n userConfig = options()\n } else {\n userConfig = getConfig(options, ROOT)\n }\n generator = new Generator({\n config: userConfig,\n root: ROOT,\n })\n }\n\n const generate = async (opts?: {\n file: string\n event: 'create' | 'update' | 'delete'\n }) => {\n if (routeGenerationDisabled()) {\n return\n }\n let generatorEvent: GeneratorEvent | undefined = undefined\n if (opts) {\n const filePath = normalize(opts.file)\n if (filePath === resolveConfigPath({ configDirectory: ROOT })) {\n initConfigAndGenerator()\n return\n }\n generatorEvent = { path: filePath, type: opts.event }\n }\n\n try {\n await generator.run(generatorEvent)\n routerPluginContext.routesByFile = generator.getRoutesByFileMap()\n } catch (e) {\n console.error(e)\n }\n }\n\n return {\n name: 'tanstack:router-generator',\n enforce: 'pre',\n async watchChange(id, { event }) {\n await generate({\n file: id,\n event,\n })\n },\n vite: {\n async configResolved(config) {\n initConfigAndGenerator({ root: config.root })\n await generate()\n },\n },\n rspack(compiler) {\n initConfigAndGenerator()\n\n let handle: FSWatcher | null = null\n\n compiler.hooks.beforeRun.tapPromise(PLUGIN_NAME, () => generate())\n\n compiler.hooks.watchRun.tapPromise(PLUGIN_NAME, async () => {\n if (handle) {\n return\n }\n\n // rspack watcher doesn't register newly created files\n const routesDirectoryPath = getRoutesDirectoryPath()\n const chokidar = await import('chokidar')\n handle = chokidar\n .watch(routesDirectoryPath, { ignoreInitial: true })\n .on('add', (file) => generate({ file, event: 'create' }))\n\n await generate()\n })\n\n compiler.hooks.watchClose.tap(PLUGIN_NAME, async () => {\n if (handle) {\n await handle.close()\n }\n })\n },\n webpack(compiler) {\n initConfigAndGenerator()\n\n let handle: FSWatcher | null = null\n\n compiler.hooks.beforeRun.tapPromise(PLUGIN_NAME, () => generate())\n\n compiler.hooks.watchRun.tapPromise(PLUGIN_NAME, async () => {\n if (handle) {\n return\n }\n\n // webpack watcher doesn't register newly created files\n const routesDirectoryPath = getRoutesDirectoryPath()\n const chokidar = await import('chokidar')\n handle = chokidar\n .watch(routesDirectoryPath, { ignoreInitial: true })\n .on('add', (file) => generate({ file, event: 'create' }))\n\n await generate()\n })\n\n compiler.hooks.watchClose.tap(PLUGIN_NAME, async () => {\n if (handle) {\n await handle.close()\n }\n })\n\n compiler.hooks.done.tap(PLUGIN_NAME, () => {\n console.info('✅ ' + PLUGIN_NAME + ': route-tree generation done')\n })\n },\n esbuild: {\n config() {\n initConfigAndGenerator()\n },\n },\n }\n}\n\nexport const unpluginRouterGeneratorFactory: UnpluginFactory<\n Partial<Config | (() => Config)> | undefined\n> = (options = {}) => {\n return createRouterGeneratorPlugin(options, createRouterPluginContext())\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"router-generator-plugin.cjs","names":[],"sources":["../../../src/core/router-generator-plugin.ts"],"sourcesContent":["import { isAbsolute, join, normalize } from 'node:path'\nimport { Generator, resolveConfigPath } from '@tanstack/router-generator'\nimport { getConfig } from './config'\nimport { createRouterPluginContext } from './router-plugin-context'\n\nimport type { GeneratorEvent } from '@tanstack/router-generator'\nimport type { FSWatcher } from 'chokidar'\nimport type { UnpluginFactory } from 'unplugin'\nimport type { Config } from './config'\nimport type { RouterPluginContext } from './router-plugin-context'\n\nconst PLUGIN_NAME = 'unplugin:router-generator'\n\nexport function createRouterGeneratorPlugin(\n options: Partial<Config | (() => Config)> | undefined = {},\n routerPluginContext: RouterPluginContext,\n): ReturnType<UnpluginFactory<Partial<Config | (() => Config)> | undefined>> {\n let ROOT: string = process.cwd()\n let userConfig: Config\n let generator: Generator\n\n const routeGenerationDisabled = () =>\n userConfig.enableRouteGeneration === false\n const getRoutesDirectoryPath = () => {\n return isAbsolute(userConfig.routesDirectory)\n ? userConfig.routesDirectory\n : join(ROOT, userConfig.routesDirectory)\n }\n\n const initConfigAndGenerator = (opts?: { root?: string }) => {\n if (opts?.root) {\n ROOT = opts.root\n }\n if (typeof options === 'function') {\n userConfig = options()\n } else {\n userConfig = getConfig(options, ROOT)\n }\n generator = new Generator({\n config: userConfig,\n root: ROOT,\n })\n }\n\n const generate = async (opts?: {\n file: string\n event: 'create' | 'update' | 'delete'\n }) => {\n if (routeGenerationDisabled()) {\n return\n }\n let generatorEvent: GeneratorEvent | undefined = undefined\n if (opts) {\n const filePath = normalize(opts.file)\n if (filePath === resolveConfigPath({ configDirectory: ROOT })) {\n initConfigAndGenerator()\n return\n }\n generatorEvent = { path: filePath, type: opts.event }\n }\n\n try {\n await generator.run(generatorEvent)\n routerPluginContext.routesByFile = generator.getRoutesByFileMap()\n } catch (e) {\n console.error(e)\n }\n }\n\n return {\n name: 'tanstack:router-generator',\n enforce: 'pre',\n async watchChange(id, { event }) {\n await generate({\n file: id,\n event,\n })\n },\n vite: {\n async configResolved(config) {\n initConfigAndGenerator({ root: config.root })\n await generate()\n },\n },\n rspack(compiler) {\n initConfigAndGenerator()\n\n let handle: FSWatcher | null = null\n\n compiler.hooks.beforeRun.tapPromise(PLUGIN_NAME, () => generate())\n\n compiler.hooks.watchRun.tapPromise(PLUGIN_NAME, async () => {\n if (handle) {\n return\n }\n\n // rspack watcher doesn't register newly created files\n const routesDirectoryPath = getRoutesDirectoryPath()\n const chokidar = await import('chokidar')\n handle = chokidar\n .watch(routesDirectoryPath, { ignoreInitial: true })\n .on('add', (file) => generate({ file, event: 'create' }))\n\n await generate()\n })\n\n compiler.hooks.watchClose.tap(PLUGIN_NAME, async () => {\n if (handle) {\n await handle.close()\n }\n })\n },\n webpack(compiler) {\n initConfigAndGenerator()\n\n let handle: FSWatcher | null = null\n\n compiler.hooks.beforeRun.tapPromise(PLUGIN_NAME, () => generate())\n\n compiler.hooks.watchRun.tapPromise(PLUGIN_NAME, async () => {\n if (handle) {\n return\n }\n\n // webpack watcher doesn't register newly created files\n const routesDirectoryPath = getRoutesDirectoryPath()\n const chokidar = await import('chokidar')\n handle = chokidar\n .watch(routesDirectoryPath, { ignoreInitial: true })\n .on('add', (file) => generate({ file, event: 'create' }))\n\n await generate()\n })\n\n compiler.hooks.watchClose.tap(PLUGIN_NAME, async () => {\n if (handle) {\n await handle.close()\n }\n })\n\n compiler.hooks.done.tap(PLUGIN_NAME, () => {\n console.info('✅ ' + PLUGIN_NAME + ': route-tree generation done')\n })\n },\n esbuild: {\n config() {\n initConfigAndGenerator()\n },\n },\n }\n}\n\nexport const unpluginRouterGeneratorFactory: UnpluginFactory<\n Partial<Config | (() => Config)> | undefined\n> = (options = {}) => {\n return createRouterGeneratorPlugin(options, createRouterPluginContext())\n}\n"],"mappings":";;;;;AAWA,IAAM,cAAc;AAEpB,SAAgB,4BACd,UAAwD,CAAC,GACzD,qBAC2E;CAC3E,IAAI,OAAe,QAAQ,IAAI;CAC/B,IAAI;CACJ,IAAI;CAEJ,MAAM,gCACJ,WAAW,0BAA0B;CACvC,MAAM,+BAA+B;EACnC,QAAA,GAAA,UAAA,YAAkB,WAAW,eAAe,IACxC,WAAW,mBAAA,GAAA,UAAA,MACN,MAAM,WAAW,eAAe;CAC3C;CAEA,MAAM,0BAA0B,SAA6B;EAC3D,IAAI,MAAM,MACR,OAAO,KAAK;EAEd,IAAI,OAAO,YAAY,YACrB,aAAa,QAAQ;OAErB,aAAa,eAAA,UAAU,SAAS,IAAI;EAEtC,YAAY,IAAI,2BAAA,UAAU;GACxB,QAAQ;GACR,MAAM;EACR,CAAC;CACH;CAEA,MAAM,WAAW,OAAO,SAGlB;EACJ,IAAI,wBAAwB,GAC1B;EAEF,IAAI,iBAA6C,KAAA;EACjD,IAAI,MAAM;GACR,MAAM,YAAA,GAAA,UAAA,WAAqB,KAAK,IAAI;GACpC,IAAI,cAAA,GAAA,2BAAA,mBAA+B,EAAE,iBAAiB,KAAK,CAAC,GAAG;IAC7D,uBAAuB;IACvB;GACF;GACA,iBAAiB;IAAE,MAAM;IAAU,MAAM,KAAK;GAAM;EACtD;EAEA,IAAI;GACF,MAA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;GAEvB,CAAC;GAED,SAAS,MAAM,KAAK,IAAI,mBAAmB;IACzC,QAAQ,KAAK,yDAAmD;GAClE,CAAC;EACH;EACA,SAAS,EACP,SAAS;GACP,uBAAuB;EACzB,EACF;CACF;AACF;AAEA,IAAa,kCAER,UAAU,CAAC,MAAM;CACpB,OAAO,4BAA4B,SAAS,8BAAA,0BAA0B,CAAC;AACzE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router-hmr-plugin.cjs","names":[],"sources":["../../../src/core/router-hmr-plugin.ts"],"sourcesContent":["import { generateFromAst, logDiff, parseAst } from '@tanstack/router-utils'\nimport { compileCodeSplitReferenceRoute } from './code-splitter/compilers'\nimport { getReferenceRouteCompilerPlugins } from './code-splitter/plugins/framework-plugins'\nimport { createRouteHmrStatement } from './hmr'\nimport { debug, normalizePath, routeFactoryCallCodeFilter } from './utils'\nimport { getConfig } from './config'\nimport { createRouterPluginContext } from './router-plugin-context'\nimport type { UnpluginFactory } from 'unplugin'\nimport type { Config } from './config'\nimport type { RouterPluginContext } from './router-plugin-context'\n\n/**\n * This plugin adds HMR support for file routes.\n * It is only added to the composed plugin in dev when autoCodeSplitting is disabled, since the code splitting plugin\n * handles HMR for code-split routes itself.\n */\n\nexport function createRouterHmrPlugin(\n options: Partial<Config | (() => Config)> | undefined = {},\n routerPluginContext: RouterPluginContext,\n): ReturnType<UnpluginFactory<Partial<Config> | undefined>> {\n let ROOT: string = process.cwd()\n\n const resolveUserConfig = () => {\n return getConfig(typeof options === 'function' ? options() : options, ROOT)\n }\n\n let userConfig = resolveUserConfig()\n\n return {\n name: 'tanstack-router:hmr',\n enforce: 'pre',\n transform: {\n filter: {\n // this is necessary for webpack / rspack to avoid matching .html files\n id: /\\.(m|c)?(j|t)sx?$/,\n code: {\n include: routeFactoryCallCodeFilter,\n },\n },\n handler(code, id) {\n const normalizedId = normalizePath(id)\n const routeEntry = routerPluginContext.routesByFile.get(normalizedId)\n if (!routeEntry) {\n return null\n }\n\n if (debug) console.info('Adding HMR handling to route ', normalizedId)\n\n const hmrStyle = userConfig.plugin?.hmr?.style ?? 'vite'\n\n if (userConfig.target === 'react') {\n const compilerPlugins = getReferenceRouteCompilerPlugins({\n targetFramework: 'react',\n addHmr: true,\n hmrStyle,\n })\n const compiled = compileCodeSplitReferenceRoute({\n code,\n filename: normalizedId,\n id: normalizedId,\n addHmr: true,\n hmrStyle,\n hmrRouteId: routeEntry.routeId,\n codeSplitGroupings: [],\n targetFramework: 'react',\n compilerPlugins,\n })\n\n if (compiled) {\n if (debug) {\n logDiff(code, compiled.code)\n console.log('Output:\\n', compiled.code + '\\n\\n')\n }\n\n return compiled\n }\n }\n\n const ast = parseAst({ code, filename: normalizedId })\n ast.program.body.push(\n ...createRouteHmrStatement([], {\n hmrStyle,\n targetFramework: userConfig.target,\n routeId: routeEntry.routeId,\n }),\n )\n const result = generateFromAst(ast, {\n sourceMaps: true,\n filename: normalizedId,\n sourceFileName: normalizedId,\n })\n if (debug) {\n logDiff(code, result.code)\n console.log('Output:\\n', result.code + '\\n\\n')\n }\n return result\n },\n },\n vite: {\n configResolved(config) {\n ROOT = config.root\n userConfig = resolveUserConfig()\n },\n applyToEnvironment(environment) {\n if (userConfig.plugin?.vite?.environmentName) {\n return userConfig.plugin.vite.environmentName === environment.name\n }\n return true\n },\n },\n }\n}\n\nexport const unpluginRouterHmrFactory: UnpluginFactory<\n Partial<Config> | undefined\n> = (options = {}) => {\n return createRouterHmrPlugin(options, createRouterPluginContext())\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"router-hmr-plugin.cjs","names":[],"sources":["../../../src/core/router-hmr-plugin.ts"],"sourcesContent":["import { generateFromAst, logDiff, parseAst } from '@tanstack/router-utils'\nimport { compileCodeSplitReferenceRoute } from './code-splitter/compilers'\nimport { getReferenceRouteCompilerPlugins } from './code-splitter/plugins/framework-plugins'\nimport { createRouteHmrStatement } from './hmr'\nimport { debug, normalizePath, routeFactoryCallCodeFilter } from './utils'\nimport { getConfig } from './config'\nimport { createRouterPluginContext } from './router-plugin-context'\nimport type { UnpluginFactory } from 'unplugin'\nimport type { Config } from './config'\nimport type { RouterPluginContext } from './router-plugin-context'\n\n/**\n * This plugin adds HMR support for file routes.\n * It is only added to the composed plugin in dev when autoCodeSplitting is disabled, since the code splitting plugin\n * handles HMR for code-split routes itself.\n */\n\nexport function createRouterHmrPlugin(\n options: Partial<Config | (() => Config)> | undefined = {},\n routerPluginContext: RouterPluginContext,\n): ReturnType<UnpluginFactory<Partial<Config> | undefined>> {\n let ROOT: string = process.cwd()\n\n const resolveUserConfig = () => {\n return getConfig(typeof options === 'function' ? options() : options, ROOT)\n }\n\n let userConfig = resolveUserConfig()\n\n return {\n name: 'tanstack-router:hmr',\n enforce: 'pre',\n transform: {\n filter: {\n // this is necessary for webpack / rspack to avoid matching .html files\n id: /\\.(m|c)?(j|t)sx?$/,\n code: {\n include: routeFactoryCallCodeFilter,\n },\n },\n handler(code, id) {\n const normalizedId = normalizePath(id)\n const routeEntry = routerPluginContext.routesByFile.get(normalizedId)\n if (!routeEntry) {\n return null\n }\n\n if (debug) console.info('Adding HMR handling to route ', normalizedId)\n\n const hmrStyle = userConfig.plugin?.hmr?.style ?? 'vite'\n\n if (userConfig.target === 'react') {\n const compilerPlugins = getReferenceRouteCompilerPlugins({\n targetFramework: 'react',\n addHmr: true,\n hmrStyle,\n })\n const compiled = compileCodeSplitReferenceRoute({\n code,\n filename: normalizedId,\n id: normalizedId,\n addHmr: true,\n hmrStyle,\n hmrRouteId: routeEntry.routeId,\n codeSplitGroupings: [],\n targetFramework: 'react',\n compilerPlugins,\n })\n\n if (compiled) {\n if (debug) {\n logDiff(code, compiled.code)\n console.log('Output:\\n', compiled.code + '\\n\\n')\n }\n\n return compiled\n }\n }\n\n const ast = parseAst({ code, filename: normalizedId })\n ast.program.body.push(\n ...createRouteHmrStatement([], {\n hmrStyle,\n targetFramework: userConfig.target,\n routeId: routeEntry.routeId,\n }),\n )\n const result = generateFromAst(ast, {\n sourceMaps: true,\n filename: normalizedId,\n sourceFileName: normalizedId,\n })\n if (debug) {\n logDiff(code, result.code)\n console.log('Output:\\n', result.code + '\\n\\n')\n }\n return result\n },\n },\n vite: {\n configResolved(config) {\n ROOT = config.root\n userConfig = resolveUserConfig()\n },\n applyToEnvironment(environment) {\n if (userConfig.plugin?.vite?.environmentName) {\n return userConfig.plugin.vite.environmentName === environment.name\n }\n return true\n },\n },\n }\n}\n\nexport const unpluginRouterHmrFactory: UnpluginFactory<\n Partial<Config> | undefined\n> = (options = {}) => {\n return createRouterHmrPlugin(options, createRouterPluginContext())\n}\n"],"mappings":";;;;;;;;;;;;AAiBA,SAAgB,sBACd,UAAwD,CAAC,GACzD,qBAC0D;CAC1D,IAAI,OAAe,QAAQ,IAAI;CAE/B,MAAM,0BAA0B;EAC9B,OAAO,eAAA,UAAU,OAAO,YAAY,aAAa,QAAQ,IAAI,SAAS,IAAI;CAC5E;CAEA,IAAI,aAAa,kBAAkB;CAEnC,OAAO;EACL,MAAM;EACN,SAAS;EACT,WAAW;GACT,QAAQ;IAEN,IAAI;IACJ,MAAM,EACJ,SAAS,cAAA,2BACX;GACF;GACA,QAAQ,MAAM,IAAI;IAChB,MAAM,eAAe,cAAA,cAAc,EAAE;IACrC,MAAM,aAAa,oBAAoB,aAAa,IAAI,YAAY;IACpE,IAAI,CAAC,YACH,OAAO;IAGT,IAAI,cAAA,OAAO,QAAQ,KAAK,iCAAiC,YAAY;IAErE,MAAM,WAAW,WAAW,QAAQ,KAAK,SAAS;IAElD,IAAI,WAAW,WAAW,SAAS;KACjC,MAAM,kBAAkB,0BAAA,iCAAiC;MACvD,iBAAiB;MACjB,QAAQ;MACR;KACF,CAAC;KACD,MAAM,WAAW,kBAAA,+BAA+B;MAC9C;MACA,UAAU;MACV,IAAI;MACJ,QAAQ;MACR;MACA,YAAY,WAAW;MACvB,oBAAoB,CAAC;MACrB,iBAAiB;MACjB;KACF,CAAC;KAED,IAAI,UAAU;MACZ,IAAI,cAAA,OAAO;OACT,CAAA,GAAA,uBAAA,SAAQ,MAAM,SAAS,IAAI;OAC3B,QAAQ,IAAI,aAAa,SAAS,OAAO,MAAM;MACjD;MAEA,OAAO;KACT;IACF;IAEA,MAAM,OAAA,GAAA,uBAAA,UAAe;KAAE;KAAM,UAAU;IAAa,CAAC;IACrD,IAAI,QAAQ,KAAK,KACf,GAAG,uBAAA,wBAAwB,CAAC,GAAG;KAC7B;KACA,iBAAiB,WAAW;KAC5B,SAAS,WAAW;IACtB,CAAC,CACH;IACA,MAAM,UAAA,GAAA,uBAAA,iBAAyB,KAAK;KAClC,YAAY;KACZ,UAAU;KACV,gBAAgB;IAClB,CAAC;IACD,IAAI,cAAA,OAAO;KACT,CAAA,GAAA,uBAAA,SAAQ,MAAM,OAAO,IAAI;KACzB,QAAQ,IAAI,aAAa,OAAO,OAAO,MAAM;IAC/C;IACA,OAAO;GACT;EACF;EACA,MAAM;GACJ,eAAe,QAAQ;IACrB,OAAO,OAAO;IACd,aAAa,kBAAkB;GACjC;GACA,mBAAmB,aAAa;IAC9B,IAAI,WAAW,QAAQ,MAAM,iBAC3B,OAAO,WAAW,OAAO,KAAK,oBAAoB,YAAY;IAEhE,OAAO;GACT;EACF;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router-plugin-context.cjs","names":[],"sources":["../../../src/core/router-plugin-context.ts"],"sourcesContent":["import type { GetRoutesByFileMapResult } from '@tanstack/router-generator'\n\nexport type RouterPluginContext = {\n routesByFile: GetRoutesByFileMapResult\n}\n\nexport function createRouterPluginContext(): RouterPluginContext {\n return {\n routesByFile: new Map(),\n }\n}\n"],"mappings":";AAMA,SAAgB,4BAAiD;
|
|
1
|
+
{"version":3,"file":"router-plugin-context.cjs","names":[],"sources":["../../../src/core/router-plugin-context.ts"],"sourcesContent":["import type { GetRoutesByFileMapResult } from '@tanstack/router-generator'\n\nexport type RouterPluginContext = {\n routesByFile: GetRoutesByFileMapResult\n}\n\nexport function createRouterPluginContext(): RouterPluginContext {\n return {\n routesByFile: new Map(),\n }\n}\n"],"mappings":";AAMA,SAAgB,4BAAiD;CAC/D,OAAO,EACL,8BAAc,IAAI,IAAI,EACxB;AACF"}
|
package/dist/cjs/core/utils.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
2
2
|
let _babel_types = require("@babel/types");
|
|
3
|
-
_babel_types = require_runtime.__toESM(_babel_types);
|
|
3
|
+
_babel_types = require_runtime.__toESM(_babel_types, 1);
|
|
4
4
|
//#region src/core/utils.ts
|
|
5
5
|
var debug = process.env.TSR_VITE_DEBUG && ["true", "router-plugin"].includes(process.env.TSR_VITE_DEBUG);
|
|
6
6
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.cjs","names":[],"sources":["../../../src/core/utils.ts"],"sourcesContent":["import * as t from '@babel/types'\nimport type babel from '@babel/core'\n\nexport const debug =\n process.env.TSR_VITE_DEBUG &&\n ['true', 'router-plugin'].includes(process.env.TSR_VITE_DEBUG)\n\n/**\n * Normalizes a file path by converting Windows backslashes to forward slashes.\n * This ensures consistent path handling across different bundlers and operating systems.\n *\n * The route generator stores paths with forward slashes, but rspack/webpack on Windows\n * pass native paths with backslashes to transform handlers.\n */\nexport function normalizePath(path: string): string {\n return path.replace(/\\\\/g, '/')\n}\n\nexport const routeFactoryCallCodeFilter = [\n /\\bcreateFileRoute\\s*\\(/,\n /\\bcreateRootRoute\\s*\\(/,\n /\\bcreateRootRouteWithContext\\s*(?:<|\\()/,\n]\n\nexport function getObjectPropertyKeyName(\n prop: t.ObjectProperty,\n): string | undefined {\n if (prop.computed) {\n return undefined\n }\n\n if (t.isIdentifier(prop.key)) {\n return prop.key.name\n }\n\n if (t.isStringLiteral(prop.key)) {\n return prop.key.value\n }\n\n return undefined\n}\n\nexport function getUniqueProgramIdentifier(\n programPath: babel.NodePath<t.Program>,\n baseName: string,\n): t.Identifier {\n let name = baseName\n let suffix = 2\n\n const programScope = programPath.scope.getProgramParent()\n\n while (\n programScope.hasBinding(name) ||\n programScope.hasGlobal(name) ||\n programScope.hasReference(name)\n ) {\n name = `${baseName}${suffix}`\n suffix++\n }\n\n // Register the name so subsequent calls within the same traversal\n // see it and avoid collisions\n programScope.references[name] = true\n\n return t.identifier(name)\n}\n"],"mappings":";;;;AAGA,IAAa,QACX,QAAQ,IAAI,kBACZ,CAAC,QAAQ,
|
|
1
|
+
{"version":3,"file":"utils.cjs","names":[],"sources":["../../../src/core/utils.ts"],"sourcesContent":["import * as t from '@babel/types'\nimport type babel from '@babel/core'\n\nexport const debug =\n process.env.TSR_VITE_DEBUG &&\n ['true', 'router-plugin'].includes(process.env.TSR_VITE_DEBUG)\n\n/**\n * Normalizes a file path by converting Windows backslashes to forward slashes.\n * This ensures consistent path handling across different bundlers and operating systems.\n *\n * The route generator stores paths with forward slashes, but rspack/webpack on Windows\n * pass native paths with backslashes to transform handlers.\n */\nexport function normalizePath(path: string): string {\n return path.replace(/\\\\/g, '/')\n}\n\nexport const routeFactoryCallCodeFilter = [\n /\\bcreateFileRoute\\s*\\(/,\n /\\bcreateRootRoute\\s*\\(/,\n /\\bcreateRootRouteWithContext\\s*(?:<|\\()/,\n]\n\nexport function getObjectPropertyKeyName(\n prop: t.ObjectProperty,\n): string | undefined {\n if (prop.computed) {\n return undefined\n }\n\n if (t.isIdentifier(prop.key)) {\n return prop.key.name\n }\n\n if (t.isStringLiteral(prop.key)) {\n return prop.key.value\n }\n\n return undefined\n}\n\nexport function getUniqueProgramIdentifier(\n programPath: babel.NodePath<t.Program>,\n baseName: string,\n): t.Identifier {\n let name = baseName\n let suffix = 2\n\n const programScope = programPath.scope.getProgramParent()\n\n while (\n programScope.hasBinding(name) ||\n programScope.hasGlobal(name) ||\n programScope.hasReference(name)\n ) {\n name = `${baseName}${suffix}`\n suffix++\n }\n\n // Register the name so subsequent calls within the same traversal\n // see it and avoid collisions\n programScope.references[name] = true\n\n return t.identifier(name)\n}\n"],"mappings":";;;;AAGA,IAAa,QACX,QAAQ,IAAI,kBACZ,CAAC,QAAQ,eAAe,EAAE,SAAS,QAAQ,IAAI,cAAc;;;;;;;;AAS/D,SAAgB,cAAc,MAAsB;CAClD,OAAO,KAAK,QAAQ,OAAO,GAAG;AAChC;AAEA,IAAa,6BAA6B;CACxC;CACA;CACA;AACF;AAEA,SAAgB,yBACd,MACoB;CACpB,IAAI,KAAK,UACP;CAGF,IAAI,aAAE,aAAa,KAAK,GAAG,GACzB,OAAO,KAAK,IAAI;CAGlB,IAAI,aAAE,gBAAgB,KAAK,GAAG,GAC5B,OAAO,KAAK,IAAI;AAIpB;AAEA,SAAgB,2BACd,aACA,UACc;CACd,IAAI,OAAO;CACX,IAAI,SAAS;CAEb,MAAM,eAAe,YAAY,MAAM,iBAAiB;CAExD,OACE,aAAa,WAAW,IAAI,KAC5B,aAAa,UAAU,IAAI,KAC3B,aAAa,aAAa,IAAI,GAC9B;EACA,OAAO,GAAG,WAAW;EACrB;CACF;CAIA,aAAa,WAAW,QAAQ;CAEhC,OAAO,aAAE,WAAW,IAAI;AAC1B"}
|
package/dist/cjs/esbuild.cjs
CHANGED
|
@@ -2,7 +2,6 @@ Object.defineProperties(exports, {
|
|
|
2
2
|
__esModule: { value: true },
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
|
-
require("./_virtual/_rolldown/runtime.cjs");
|
|
6
5
|
const require_config = require("./core/config.cjs");
|
|
7
6
|
const require_router_plugin_context = require("./core/router-plugin-context.cjs");
|
|
8
7
|
const require_router_code_splitter_plugin = require("./core/router-code-splitter-plugin.cjs");
|
package/dist/cjs/esbuild.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"esbuild.cjs","names":[],"sources":["../../src/esbuild.ts"],"sourcesContent":["import { createEsbuildPlugin } from 'unplugin'\n\nimport { configSchema } from './core/config'\nimport { createRouterCodeSplitterPlugin } from './core/router-code-splitter-plugin'\nimport { createRouterGeneratorPlugin } from './core/router-generator-plugin'\nimport { unpluginRouterComposedFactory } from './core/router-composed-plugin'\nimport { createRouterPluginContext } from './core/router-plugin-context'\n\nimport type { CodeSplittingOptions, Config } from './core/config'\nimport type { RouterPluginContext } from './core/router-plugin-context'\n\ntype RouterPluginOptions = Partial<Config | (() => Config)> | undefined\n\nconst defaultRouterPluginContext = createRouterPluginContext()\n\n/**\n * @example\n * ```ts\n * export default {\n * plugins: [TanStackRouterGeneratorEsbuild()],\n * // ...\n * }\n * ```\n */\nconst TanStackRouterGeneratorEsbuild = (\n options?: RouterPluginOptions,\n routerPluginContext?: RouterPluginContext,\n) => {\n const pluginContext = routerPluginContext ?? defaultRouterPluginContext\n return createEsbuildPlugin((pluginOptions: RouterPluginOptions) =>\n createRouterGeneratorPlugin(pluginOptions, pluginContext),\n )(options)\n}\n\n/**\n * @example\n * ```ts\n * export default {\n * plugins: [TanStackRouterCodeSplitterEsbuild()],\n * // ...\n * }\n * ```\n */\nconst TanStackRouterCodeSplitterEsbuild = (\n options?: RouterPluginOptions,\n routerPluginContext?: RouterPluginContext,\n) => {\n const pluginContext = routerPluginContext ?? defaultRouterPluginContext\n return createEsbuildPlugin((pluginOptions: RouterPluginOptions) =>\n createRouterCodeSplitterPlugin(pluginOptions, pluginContext),\n )(options)\n}\n\n/**\n * @example\n * ```ts\n * export default {\n * plugins: [tanstackRouter()],\n * // ...\n * }\n * ```\n */\nconst TanStackRouterEsbuild = createEsbuildPlugin(unpluginRouterComposedFactory)\nconst tanstackRouter = TanStackRouterEsbuild\nexport default TanStackRouterEsbuild\n\nexport {\n configSchema,\n TanStackRouterGeneratorEsbuild,\n TanStackRouterCodeSplitterEsbuild,\n TanStackRouterEsbuild,\n tanstackRouter,\n}\n\nexport type { Config, CodeSplittingOptions, RouterPluginContext }\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"esbuild.cjs","names":[],"sources":["../../src/esbuild.ts"],"sourcesContent":["import { createEsbuildPlugin } from 'unplugin'\n\nimport { configSchema } from './core/config'\nimport { createRouterCodeSplitterPlugin } from './core/router-code-splitter-plugin'\nimport { createRouterGeneratorPlugin } from './core/router-generator-plugin'\nimport { unpluginRouterComposedFactory } from './core/router-composed-plugin'\nimport { createRouterPluginContext } from './core/router-plugin-context'\n\nimport type { CodeSplittingOptions, Config } from './core/config'\nimport type { RouterPluginContext } from './core/router-plugin-context'\n\ntype RouterPluginOptions = Partial<Config | (() => Config)> | undefined\n\nconst defaultRouterPluginContext = createRouterPluginContext()\n\n/**\n * @example\n * ```ts\n * export default {\n * plugins: [TanStackRouterGeneratorEsbuild()],\n * // ...\n * }\n * ```\n */\nconst TanStackRouterGeneratorEsbuild = (\n options?: RouterPluginOptions,\n routerPluginContext?: RouterPluginContext,\n) => {\n const pluginContext = routerPluginContext ?? defaultRouterPluginContext\n return createEsbuildPlugin((pluginOptions: RouterPluginOptions) =>\n createRouterGeneratorPlugin(pluginOptions, pluginContext),\n )(options)\n}\n\n/**\n * @example\n * ```ts\n * export default {\n * plugins: [TanStackRouterCodeSplitterEsbuild()],\n * // ...\n * }\n * ```\n */\nconst TanStackRouterCodeSplitterEsbuild = (\n options?: RouterPluginOptions,\n routerPluginContext?: RouterPluginContext,\n) => {\n const pluginContext = routerPluginContext ?? defaultRouterPluginContext\n return createEsbuildPlugin((pluginOptions: RouterPluginOptions) =>\n createRouterCodeSplitterPlugin(pluginOptions, pluginContext),\n )(options)\n}\n\n/**\n * @example\n * ```ts\n * export default {\n * plugins: [tanstackRouter()],\n * // ...\n * }\n * ```\n */\nconst TanStackRouterEsbuild = createEsbuildPlugin(unpluginRouterComposedFactory)\nconst tanstackRouter = TanStackRouterEsbuild\nexport default TanStackRouterEsbuild\n\nexport {\n configSchema,\n TanStackRouterGeneratorEsbuild,\n TanStackRouterCodeSplitterEsbuild,\n TanStackRouterEsbuild,\n tanstackRouter,\n}\n\nexport type { Config, CodeSplittingOptions, RouterPluginContext }\n"],"mappings":";;;;;;;;;;;AAaA,IAAM,6BAA6B,8BAAA,0BAA0B;;;;;;;;;;AAW7D,IAAM,kCACJ,SACA,wBACG;CACH,MAAM,gBAAgB,uBAAuB;CAC7C,QAAA,GAAA,SAAA,sBAA4B,kBAC1B,gCAAA,4BAA4B,eAAe,aAAa,CAC1D,EAAE,OAAO;AACX;;;;;;;;;;AAWA,IAAM,qCACJ,SACA,wBACG;CACH,MAAM,gBAAgB,uBAAuB;CAC7C,QAAA,GAAA,SAAA,sBAA4B,kBAC1B,oCAAA,+BAA+B,eAAe,aAAa,CAC7D,EAAE,OAAO;AACX;;;;;;;;;;AAWA,IAAM,yBAAA,GAAA,SAAA,qBAA4C,+BAAA,6BAA6B;AAC/E,IAAM,iBAAiB"}
|
package/dist/cjs/rspack.cjs
CHANGED
|
@@ -2,7 +2,6 @@ Object.defineProperties(exports, {
|
|
|
2
2
|
__esModule: { value: true },
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
|
-
require("./_virtual/_rolldown/runtime.cjs");
|
|
6
5
|
const require_config = require("./core/config.cjs");
|
|
7
6
|
const require_router_plugin_context = require("./core/router-plugin-context.cjs");
|
|
8
7
|
const require_router_code_splitter_plugin = require("./core/router-code-splitter-plugin.cjs");
|
package/dist/cjs/rspack.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rspack.cjs","names":[],"sources":["../../src/rspack.ts"],"sourcesContent":["import { createRspackPlugin } from 'unplugin'\n\nimport { configSchema } from './core/config'\nimport { createRouterCodeSplitterPlugin } from './core/router-code-splitter-plugin'\nimport { createRouterGeneratorPlugin } from './core/router-generator-plugin'\nimport { unpluginRouterComposedFactory } from './core/router-composed-plugin'\nimport { createRouterPluginContext } from './core/router-plugin-context'\nimport type { CodeSplittingOptions, Config } from './core/config'\nimport type { RouterPluginContext } from './core/router-plugin-context'\n\ntype RspackRouterPluginOptions = Partial<Config> | (() => Partial<Config>)\n\nconst defaultRouterPluginContext = createRouterPluginContext()\n\n/**\n * Rspack uses webpack-compatible `module.hot` / `import.meta.webpackHot` HMR.\n * Force `plugin.hmr.style = 'webpack'` so the router HMR adapter emits\n * `module.hot`-style accept/dispose code instead of Vite's callback-receive\n * variant, regardless of what the user passes (or doesn't pass).\n */\nfunction withWebpackHmrStyle(\n options: RspackRouterPluginOptions | undefined,\n): RspackRouterPluginOptions {\n const mergeHmrStyle = (\n config: Partial<Config> | undefined,\n ): Partial<Config> => ({\n ...config,\n plugin: {\n ...config?.plugin,\n hmr: {\n ...config?.plugin?.hmr,\n style: 'webpack',\n },\n },\n })\n\n if (typeof options === 'function') {\n return () => mergeHmrStyle(options())\n }\n\n return mergeHmrStyle(options)\n}\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 = (\n options?: RspackRouterPluginOptions,\n routerPluginContext?: RouterPluginContext,\n) => {\n const pluginContext = routerPluginContext ?? defaultRouterPluginContext\n return createRspackPlugin((pluginOptions) =>\n createRouterGeneratorPlugin(\n pluginOptions as Partial<Config | (() => Config)> | undefined,\n pluginContext,\n ),\n )(options)\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 = (\n options?: RspackRouterPluginOptions,\n routerPluginContext?: RouterPluginContext,\n) => {\n const pluginContext = routerPluginContext ?? defaultRouterPluginContext\n return createRspackPlugin((pluginOptions) =>\n createRouterCodeSplitterPlugin(\n withWebpackHmrStyle(\n pluginOptions as RspackRouterPluginOptions | undefined,\n ) as Partial<Config | (() => Config)>,\n pluginContext,\n ),\n )(options)\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 withWebpackHmrStyle(\n options as RspackRouterPluginOptions | undefined,\n ) as Partial<Config | (() => Config)>,\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, RouterPluginContext }\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"rspack.cjs","names":[],"sources":["../../src/rspack.ts"],"sourcesContent":["import { createRspackPlugin } from 'unplugin'\n\nimport { configSchema } from './core/config'\nimport { createRouterCodeSplitterPlugin } from './core/router-code-splitter-plugin'\nimport { createRouterGeneratorPlugin } from './core/router-generator-plugin'\nimport { unpluginRouterComposedFactory } from './core/router-composed-plugin'\nimport { createRouterPluginContext } from './core/router-plugin-context'\nimport type { CodeSplittingOptions, Config } from './core/config'\nimport type { RouterPluginContext } from './core/router-plugin-context'\n\ntype RspackRouterPluginOptions = Partial<Config> | (() => Partial<Config>)\n\nconst defaultRouterPluginContext = createRouterPluginContext()\n\n/**\n * Rspack uses webpack-compatible `module.hot` / `import.meta.webpackHot` HMR.\n * Force `plugin.hmr.style = 'webpack'` so the router HMR adapter emits\n * `module.hot`-style accept/dispose code instead of Vite's callback-receive\n * variant, regardless of what the user passes (or doesn't pass).\n */\nfunction withWebpackHmrStyle(\n options: RspackRouterPluginOptions | undefined,\n): RspackRouterPluginOptions {\n const mergeHmrStyle = (\n config: Partial<Config> | undefined,\n ): Partial<Config> => ({\n ...config,\n plugin: {\n ...config?.plugin,\n hmr: {\n ...config?.plugin?.hmr,\n style: 'webpack',\n },\n },\n })\n\n if (typeof options === 'function') {\n return () => mergeHmrStyle(options())\n }\n\n return mergeHmrStyle(options)\n}\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 = (\n options?: RspackRouterPluginOptions,\n routerPluginContext?: RouterPluginContext,\n) => {\n const pluginContext = routerPluginContext ?? defaultRouterPluginContext\n return createRspackPlugin((pluginOptions) =>\n createRouterGeneratorPlugin(\n pluginOptions as Partial<Config | (() => Config)> | undefined,\n pluginContext,\n ),\n )(options)\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 = (\n options?: RspackRouterPluginOptions,\n routerPluginContext?: RouterPluginContext,\n) => {\n const pluginContext = routerPluginContext ?? defaultRouterPluginContext\n return createRspackPlugin((pluginOptions) =>\n createRouterCodeSplitterPlugin(\n withWebpackHmrStyle(\n pluginOptions as RspackRouterPluginOptions | undefined,\n ) as Partial<Config | (() => Config)>,\n pluginContext,\n ),\n )(options)\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 withWebpackHmrStyle(\n options as RspackRouterPluginOptions | undefined,\n ) as Partial<Config | (() => Config)>,\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, RouterPluginContext }\n"],"mappings":";;;;;;;;;;;AAYA,IAAM,6BAA6B,8BAAA,0BAA0B;;;;;;;AAQ7D,SAAS,oBACP,SAC2B;CAC3B,MAAM,iBACJ,YACqB;EACrB,GAAG;EACH,QAAQ;GACN,GAAG,QAAQ;GACX,KAAK;IACH,GAAG,QAAQ,QAAQ;IACnB,OAAO;GACT;EACF;CACF;CAEA,IAAI,OAAO,YAAY,YACrB,aAAa,cAAc,QAAQ,CAAC;CAGtC,OAAO,cAAc,OAAO;AAC9B;;;;;;;;;;;;;;AAeA,IAAM,iCACJ,SACA,wBACG;CACH,MAAM,gBAAgB,uBAAuB;CAC7C,QAAA,GAAA,SAAA,qBAA2B,kBACzB,gCAAA,4BACE,eACA,aACF,CACF,EAAE,OAAO;AACX;;;;;;;;;;;;;;AAeA,IAAM,oCACJ,SACA,wBACG;CACH,MAAM,gBAAgB,uBAAuB;CAC7C,QAAA,GAAA,SAAA,qBAA2B,kBACzB,oCAAA,+BACE,oBACE,aACF,GACA,aACF,CACF,EAAE,OAAO;AACX;;;;;;;;;;;;;;AAeA,IAAM,uBAAuC,iBAAA,GAAA,SAAA,qBAC1C,SAAS,SACR,+BAAA,8BACE,oBACE,OACF,GACA,IACF,CACJ;AACA,IAAM,iBAAiB"}
|
package/dist/cjs/vite.cjs
CHANGED
|
@@ -2,7 +2,6 @@ Object.defineProperties(exports, {
|
|
|
2
2
|
__esModule: { value: true },
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
|
-
require("./_virtual/_rolldown/runtime.cjs");
|
|
6
5
|
const require_config = require("./core/config.cjs");
|
|
7
6
|
const require_router_plugin_context = require("./core/router-plugin-context.cjs");
|
|
8
7
|
const require_router_code_splitter_plugin = require("./core/router-code-splitter-plugin.cjs");
|
package/dist/cjs/vite.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.cjs","names":[],"sources":["../../src/vite.ts"],"sourcesContent":["import { createVitePlugin } from 'unplugin'\n\nimport { configSchema, getConfig } from './core/config'\nimport { createRouterCodeSplitterPlugin } from './core/router-code-splitter-plugin'\nimport { createRouterGeneratorPlugin } from './core/router-generator-plugin'\nimport { unpluginRouterComposedFactory } from './core/router-composed-plugin'\nimport { createRouterPluginContext } from './core/router-plugin-context'\nimport type { CodeSplittingOptions, Config } from './core/config'\nimport type { RouterPluginContext } from './core/router-plugin-context'\n\ntype RouterPluginOptions = Partial<Config | (() => Config)> | undefined\n\nconst defaultRouterPluginContext = createRouterPluginContext()\n\n/**\n * @example\n * ```ts\n * export default defineConfig({\n * plugins: [tanstackRouterGenerator()],\n * // ...\n * })\n * ```\n */\nconst tanstackRouterGenerator = (\n options?: RouterPluginOptions,\n routerPluginContext?: RouterPluginContext,\n) => {\n const pluginContext = routerPluginContext ?? defaultRouterPluginContext\n return createVitePlugin((pluginOptions: RouterPluginOptions) =>\n createRouterGeneratorPlugin(pluginOptions, pluginContext),\n )(options)\n}\n\n/**\n * @example\n * ```ts\n * export default defineConfig({\n * plugins: [tanStackRouterCodeSplitter()],\n * // ...\n * })\n * ```\n */\nconst tanStackRouterCodeSplitter = (\n options?: RouterPluginOptions,\n routerPluginContext?: RouterPluginContext,\n) => {\n const pluginContext = routerPluginContext ?? defaultRouterPluginContext\n return createVitePlugin((pluginOptions: RouterPluginOptions) =>\n createRouterCodeSplitterPlugin(pluginOptions, pluginContext),\n )(options)\n}\n\n/**\n * @example\n * ```ts\n * export default defineConfig({\n * plugins: [tanstackRouter()],\n * // ...\n * })\n * ```\n */\nconst tanstackRouter = createVitePlugin(unpluginRouterComposedFactory)\n\n/**\n * @deprecated Use `tanstackRouter` instead.\n */\nconst TanStackRouterVite = tanstackRouter\n\nexport default tanstackRouter\nexport {\n configSchema,\n getConfig,\n tanStackRouterCodeSplitter,\n tanstackRouterGenerator,\n TanStackRouterVite,\n tanstackRouter,\n}\n\nexport type { Config, CodeSplittingOptions, RouterPluginContext }\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"vite.cjs","names":[],"sources":["../../src/vite.ts"],"sourcesContent":["import { createVitePlugin } from 'unplugin'\n\nimport { configSchema, getConfig } from './core/config'\nimport { createRouterCodeSplitterPlugin } from './core/router-code-splitter-plugin'\nimport { createRouterGeneratorPlugin } from './core/router-generator-plugin'\nimport { unpluginRouterComposedFactory } from './core/router-composed-plugin'\nimport { createRouterPluginContext } from './core/router-plugin-context'\nimport type { CodeSplittingOptions, Config } from './core/config'\nimport type { RouterPluginContext } from './core/router-plugin-context'\n\ntype RouterPluginOptions = Partial<Config | (() => Config)> | undefined\n\nconst defaultRouterPluginContext = createRouterPluginContext()\n\n/**\n * @example\n * ```ts\n * export default defineConfig({\n * plugins: [tanstackRouterGenerator()],\n * // ...\n * })\n * ```\n */\nconst tanstackRouterGenerator = (\n options?: RouterPluginOptions,\n routerPluginContext?: RouterPluginContext,\n) => {\n const pluginContext = routerPluginContext ?? defaultRouterPluginContext\n return createVitePlugin((pluginOptions: RouterPluginOptions) =>\n createRouterGeneratorPlugin(pluginOptions, pluginContext),\n )(options)\n}\n\n/**\n * @example\n * ```ts\n * export default defineConfig({\n * plugins: [tanStackRouterCodeSplitter()],\n * // ...\n * })\n * ```\n */\nconst tanStackRouterCodeSplitter = (\n options?: RouterPluginOptions,\n routerPluginContext?: RouterPluginContext,\n) => {\n const pluginContext = routerPluginContext ?? defaultRouterPluginContext\n return createVitePlugin((pluginOptions: RouterPluginOptions) =>\n createRouterCodeSplitterPlugin(pluginOptions, pluginContext),\n )(options)\n}\n\n/**\n * @example\n * ```ts\n * export default defineConfig({\n * plugins: [tanstackRouter()],\n * // ...\n * })\n * ```\n */\nconst tanstackRouter = createVitePlugin(unpluginRouterComposedFactory)\n\n/**\n * @deprecated Use `tanstackRouter` instead.\n */\nconst TanStackRouterVite = tanstackRouter\n\nexport default tanstackRouter\nexport {\n configSchema,\n getConfig,\n tanStackRouterCodeSplitter,\n tanstackRouterGenerator,\n TanStackRouterVite,\n tanstackRouter,\n}\n\nexport type { Config, CodeSplittingOptions, RouterPluginContext }\n"],"mappings":";;;;;;;;;;;AAYA,IAAM,6BAA6B,8BAAA,0BAA0B;;;;;;;;;;AAW7D,IAAM,2BACJ,SACA,wBACG;CACH,MAAM,gBAAgB,uBAAuB;CAC7C,QAAA,GAAA,SAAA,mBAAyB,kBACvB,gCAAA,4BAA4B,eAAe,aAAa,CAC1D,EAAE,OAAO;AACX;;;;;;;;;;AAWA,IAAM,8BACJ,SACA,wBACG;CACH,MAAM,gBAAgB,uBAAuB;CAC7C,QAAA,GAAA,SAAA,mBAAyB,kBACvB,oCAAA,+BAA+B,eAAe,aAAa,CAC7D,EAAE,OAAO;AACX;;;;;;;;;;AAWA,IAAM,kBAAA,GAAA,SAAA,kBAAkC,+BAAA,6BAA6B;;;;AAKrE,IAAM,qBAAqB"}
|
package/dist/cjs/webpack.cjs
CHANGED
|
@@ -2,7 +2,6 @@ Object.defineProperties(exports, {
|
|
|
2
2
|
__esModule: { value: true },
|
|
3
3
|
[Symbol.toStringTag]: { value: "Module" }
|
|
4
4
|
});
|
|
5
|
-
require("./_virtual/_rolldown/runtime.cjs");
|
|
6
5
|
const require_config = require("./core/config.cjs");
|
|
7
6
|
const require_router_plugin_context = require("./core/router-plugin-context.cjs");
|
|
8
7
|
const require_router_code_splitter_plugin = require("./core/router-code-splitter-plugin.cjs");
|
package/dist/cjs/webpack.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webpack.cjs","names":[],"sources":["../../src/webpack.ts"],"sourcesContent":["import { createWebpackPlugin } from 'unplugin'\n\nimport { configSchema } from './core/config'\nimport { createRouterCodeSplitterPlugin } from './core/router-code-splitter-plugin'\nimport { createRouterGeneratorPlugin } from './core/router-generator-plugin'\nimport { unpluginRouterComposedFactory } from './core/router-composed-plugin'\nimport { createRouterPluginContext } from './core/router-plugin-context'\nimport type { CodeSplittingOptions, Config } from './core/config'\nimport type { RouterPluginContext } from './core/router-plugin-context'\n\nconst defaultRouterPluginContext = createRouterPluginContext()\n\n/**\n * Webpack uses `module.hot` / `import.meta.webpackHot` HMR. Force\n * `plugin.hmr.style = 'webpack'` so the router HMR adapter emits the correct\n * accept/dispose shape regardless of user config.\n */\nfunction withWebpackHmrStyle(\n options: Partial<Config> | undefined,\n): Partial<Config> {\n return {\n ...options,\n plugin: {\n ...options?.plugin,\n hmr: {\n ...options?.plugin?.hmr,\n style: 'webpack',\n },\n },\n }\n}\n\n/**\n * @example\n * ```ts\n * export default {\n * // ...\n * plugins: [TanStackRouterGeneratorWebpack()],\n * }\n * ```\n */\nconst TanStackRouterGeneratorWebpack = (\n options?: Partial<Config>,\n routerPluginContext?: RouterPluginContext,\n) => {\n const pluginContext = routerPluginContext ?? defaultRouterPluginContext\n return createWebpackPlugin((pluginOptions: Partial<Config> | undefined) =>\n createRouterGeneratorPlugin(pluginOptions, pluginContext),\n )(options)\n}\n\n/**\n * @example\n * ```ts\n * export default {\n * // ...\n * plugins: [TanStackRouterCodeSplitterWebpack()],\n * }\n * ```\n */\nconst TanStackRouterCodeSplitterWebpack = (\n options?: Partial<Config>,\n routerPluginContext?: RouterPluginContext,\n) => {\n const pluginContext = routerPluginContext ?? defaultRouterPluginContext\n return createWebpackPlugin((pluginOptions: Partial<Config> | undefined) =>\n createRouterCodeSplitterPlugin(\n withWebpackHmrStyle(pluginOptions),\n pluginContext,\n ),\n )(options)\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 withWebpackHmrStyle(options as Partial<Config> | undefined),\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, RouterPluginContext }\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"webpack.cjs","names":[],"sources":["../../src/webpack.ts"],"sourcesContent":["import { createWebpackPlugin } from 'unplugin'\n\nimport { configSchema } from './core/config'\nimport { createRouterCodeSplitterPlugin } from './core/router-code-splitter-plugin'\nimport { createRouterGeneratorPlugin } from './core/router-generator-plugin'\nimport { unpluginRouterComposedFactory } from './core/router-composed-plugin'\nimport { createRouterPluginContext } from './core/router-plugin-context'\nimport type { CodeSplittingOptions, Config } from './core/config'\nimport type { RouterPluginContext } from './core/router-plugin-context'\n\nconst defaultRouterPluginContext = createRouterPluginContext()\n\n/**\n * Webpack uses `module.hot` / `import.meta.webpackHot` HMR. Force\n * `plugin.hmr.style = 'webpack'` so the router HMR adapter emits the correct\n * accept/dispose shape regardless of user config.\n */\nfunction withWebpackHmrStyle(\n options: Partial<Config> | undefined,\n): Partial<Config> {\n return {\n ...options,\n plugin: {\n ...options?.plugin,\n hmr: {\n ...options?.plugin?.hmr,\n style: 'webpack',\n },\n },\n }\n}\n\n/**\n * @example\n * ```ts\n * export default {\n * // ...\n * plugins: [TanStackRouterGeneratorWebpack()],\n * }\n * ```\n */\nconst TanStackRouterGeneratorWebpack = (\n options?: Partial<Config>,\n routerPluginContext?: RouterPluginContext,\n) => {\n const pluginContext = routerPluginContext ?? defaultRouterPluginContext\n return createWebpackPlugin((pluginOptions: Partial<Config> | undefined) =>\n createRouterGeneratorPlugin(pluginOptions, pluginContext),\n )(options)\n}\n\n/**\n * @example\n * ```ts\n * export default {\n * // ...\n * plugins: [TanStackRouterCodeSplitterWebpack()],\n * }\n * ```\n */\nconst TanStackRouterCodeSplitterWebpack = (\n options?: Partial<Config>,\n routerPluginContext?: RouterPluginContext,\n) => {\n const pluginContext = routerPluginContext ?? defaultRouterPluginContext\n return createWebpackPlugin((pluginOptions: Partial<Config> | undefined) =>\n createRouterCodeSplitterPlugin(\n withWebpackHmrStyle(pluginOptions),\n pluginContext,\n ),\n )(options)\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 withWebpackHmrStyle(options as Partial<Config> | undefined),\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, RouterPluginContext }\n"],"mappings":";;;;;;;;;;;AAUA,IAAM,6BAA6B,8BAAA,0BAA0B;;;;;;AAO7D,SAAS,oBACP,SACiB;CACjB,OAAO;EACL,GAAG;EACH,QAAQ;GACN,GAAG,SAAS;GACZ,KAAK;IACH,GAAG,SAAS,QAAQ;IACpB,OAAO;GACT;EACF;CACF;AACF;;;;;;;;;;AAWA,IAAM,kCACJ,SACA,wBACG;CACH,MAAM,gBAAgB,uBAAuB;CAC7C,QAAA,GAAA,SAAA,sBAA4B,kBAC1B,gCAAA,4BAA4B,eAAe,aAAa,CAC1D,EAAE,OAAO;AACX;;;;;;;;;;AAWA,IAAM,qCACJ,SACA,wBACG;CACH,MAAM,gBAAgB,uBAAuB;CAC7C,QAAA,GAAA,SAAA,sBAA4B,kBAC1B,oCAAA,+BACE,oBAAoB,aAAa,GACjC,aACF,CACF,EAAE,OAAO;AACX;;;;;;;;;;AAWA,IAAM,wBAAwC,iBAAA,GAAA,SAAA,sBAC3C,SAAS,SACR,+BAAA,8BACE,oBAAoB,OAAsC,GAC1D,IACF,CACJ;AAEA,IAAM,iBAAiB"}
|