@tanstack/router-plugin 1.167.30 → 1.167.32

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.
Files changed (73) hide show
  1. package/dist/cjs/context.cjs +3 -0
  2. package/dist/cjs/context.d.cts +2 -0
  3. package/dist/cjs/core/router-code-splitter-plugin.cjs +7 -2
  4. package/dist/cjs/core/router-code-splitter-plugin.cjs.map +1 -1
  5. package/dist/cjs/core/router-code-splitter-plugin.d.cts +2 -0
  6. package/dist/cjs/core/router-composed-plugin.cjs +7 -6
  7. package/dist/cjs/core/router-composed-plugin.cjs.map +1 -1
  8. package/dist/cjs/core/router-generator-plugin.cjs +7 -2
  9. package/dist/cjs/core/router-generator-plugin.cjs.map +1 -1
  10. package/dist/cjs/core/router-generator-plugin.d.cts +2 -0
  11. package/dist/cjs/core/router-hmr-plugin.cjs +9 -6
  12. package/dist/cjs/core/router-hmr-plugin.cjs.map +1 -1
  13. package/dist/cjs/core/router-hmr-plugin.d.cts +2 -0
  14. package/dist/cjs/core/router-plugin-context.cjs +8 -0
  15. package/dist/cjs/core/router-plugin-context.cjs.map +1 -0
  16. package/dist/cjs/core/router-plugin-context.d.cts +5 -0
  17. package/dist/cjs/esbuild.cjs +10 -2
  18. package/dist/cjs/esbuild.cjs.map +1 -1
  19. package/dist/cjs/esbuild.d.cts +5 -95
  20. package/dist/cjs/index.cjs +2 -0
  21. package/dist/cjs/index.d.cts +2 -0
  22. package/dist/cjs/rspack.cjs +10 -2
  23. package/dist/cjs/rspack.cjs.map +1 -1
  24. package/dist/cjs/rspack.d.cts +5 -49
  25. package/dist/cjs/vite.cjs +11 -2
  26. package/dist/cjs/vite.cjs.map +1 -1
  27. package/dist/cjs/vite.d.cts +6 -96
  28. package/dist/cjs/webpack.cjs +10 -2
  29. package/dist/cjs/webpack.cjs.map +1 -1
  30. package/dist/cjs/webpack.d.cts +4 -49
  31. package/dist/esm/context.d.ts +2 -0
  32. package/dist/esm/context.js +2 -0
  33. package/dist/esm/core/router-code-splitter-plugin.d.ts +2 -0
  34. package/dist/esm/core/router-code-splitter-plugin.js +7 -3
  35. package/dist/esm/core/router-code-splitter-plugin.js.map +1 -1
  36. package/dist/esm/core/router-composed-plugin.js +10 -9
  37. package/dist/esm/core/router-composed-plugin.js.map +1 -1
  38. package/dist/esm/core/router-generator-plugin.d.ts +2 -0
  39. package/dist/esm/core/router-generator-plugin.js +7 -3
  40. package/dist/esm/core/router-generator-plugin.js.map +1 -1
  41. package/dist/esm/core/router-hmr-plugin.d.ts +2 -0
  42. package/dist/esm/core/router-hmr-plugin.js +9 -6
  43. package/dist/esm/core/router-hmr-plugin.js.map +1 -1
  44. package/dist/esm/core/router-plugin-context.d.ts +5 -0
  45. package/dist/esm/core/router-plugin-context.js +8 -0
  46. package/dist/esm/core/router-plugin-context.js.map +1 -0
  47. package/dist/esm/esbuild.d.ts +5 -95
  48. package/dist/esm/esbuild.js +12 -4
  49. package/dist/esm/esbuild.js.map +1 -1
  50. package/dist/esm/index.d.ts +2 -0
  51. package/dist/esm/index.js +2 -1
  52. package/dist/esm/rspack.d.ts +5 -49
  53. package/dist/esm/rspack.js +12 -4
  54. package/dist/esm/rspack.js.map +1 -1
  55. package/dist/esm/vite.d.ts +6 -96
  56. package/dist/esm/vite.js +14 -6
  57. package/dist/esm/vite.js.map +1 -1
  58. package/dist/esm/webpack.d.ts +4 -49
  59. package/dist/esm/webpack.js +12 -4
  60. package/dist/esm/webpack.js.map +1 -1
  61. package/package.json +14 -4
  62. package/src/context.ts +2 -0
  63. package/src/core/router-code-splitter-plugin.ts +13 -4
  64. package/src/core/router-composed-plugin.ts +16 -11
  65. package/src/core/router-generator-plugin.ts +13 -4
  66. package/src/core/router-hmr-plugin.ts +21 -6
  67. package/src/core/router-plugin-context.ts +11 -0
  68. package/src/esbuild.ts +27 -9
  69. package/src/index.ts +2 -0
  70. package/src/rspack.ts +30 -12
  71. package/src/vite.ts +29 -9
  72. package/src/webpack.ts +27 -12
  73. package/src/global.d.ts +0 -7
@@ -1,9 +1,10 @@
1
1
  import { getConfig as getConfig$1 } from "./config.js";
2
+ import { createRouterPluginContext } from "./router-plugin-context.js";
2
3
  import { Generator, resolveConfigPath } from "@tanstack/router-generator";
3
4
  import { isAbsolute, join, normalize } from "node:path";
4
5
  //#region src/core/router-generator-plugin.ts
5
6
  var PLUGIN_NAME = "unplugin:router-generator";
6
- var unpluginRouterGeneratorFactory = (options = {}) => {
7
+ function createRouterGeneratorPlugin(options = {}, routerPluginContext) {
7
8
  let ROOT = process.cwd();
8
9
  let userConfig;
9
10
  let generator;
@@ -36,7 +37,7 @@ var unpluginRouterGeneratorFactory = (options = {}) => {
36
37
  }
37
38
  try {
38
39
  await generator.run(generatorEvent);
39
- globalThis.TSR_ROUTES_BY_ID_MAP = generator.getRoutesByFileMap();
40
+ routerPluginContext.routesByFile = generator.getRoutesByFileMap();
40
41
  } catch (e) {
41
42
  console.error(e);
42
43
  }
@@ -95,8 +96,11 @@ var unpluginRouterGeneratorFactory = (options = {}) => {
95
96
  initConfigAndGenerator();
96
97
  } }
97
98
  };
99
+ }
100
+ var unpluginRouterGeneratorFactory = (options = {}) => {
101
+ return createRouterGeneratorPlugin(options, createRouterPluginContext());
98
102
  };
99
103
  //#endregion
100
- export { unpluginRouterGeneratorFactory };
104
+ export { createRouterGeneratorPlugin, unpluginRouterGeneratorFactory };
101
105
 
102
106
  //# sourceMappingURL=router-generator-plugin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"router-generator-plugin.js","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'\n\nimport type { GeneratorEvent } from '@tanstack/router-generator'\nimport type { FSWatcher } from 'chokidar'\nimport type { UnpluginFactory } from 'unplugin'\nimport type { Config } from './config'\n\nconst PLUGIN_NAME = 'unplugin:router-generator'\n\nexport const unpluginRouterGeneratorFactory: UnpluginFactory<\n Partial<Config | (() => Config)> | undefined\n> = (options = {}) => {\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 globalThis.TSR_ROUTES_BY_ID_MAP = 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"],"mappings":";;;;AASA,IAAM,cAAc;AAEpB,IAAa,kCAER,UAAU,EAAE,KAAK;CACpB,IAAI,OAAe,QAAQ,KAAK;CAChC,IAAI;CACJ,IAAI;CAEJ,MAAM,gCACJ,WAAW,0BAA0B;CACvC,MAAM,+BAA+B;AACnC,SAAO,WAAW,WAAW,gBAAgB,GACzC,WAAW,kBACX,KAAK,MAAM,WAAW,gBAAgB;;CAG5C,MAAM,0BAA0B,SAA6B;AAC3D,MAAI,MAAM,KACR,QAAO,KAAK;AAEd,MAAI,OAAO,YAAY,WACrB,cAAa,SAAS;MAEtB,cAAa,YAAU,SAAS,KAAK;AAEvC,cAAY,IAAI,UAAU;GACxB,QAAQ;GACR,MAAM;GACP,CAAC;;CAGJ,MAAM,WAAW,OAAO,SAGlB;AACJ,MAAI,yBAAyB,CAC3B;EAEF,IAAI,iBAA6C,KAAA;AACjD,MAAI,MAAM;GACR,MAAM,WAAW,UAAU,KAAK,KAAK;AACrC,OAAI,aAAa,kBAAkB,EAAE,iBAAiB,MAAM,CAAC,EAAE;AAC7D,4BAAwB;AACxB;;AAEF,oBAAiB;IAAE,MAAM;IAAU,MAAM,KAAK;IAAO;;AAGvD,MAAI;AACF,SAAM,UAAU,IAAI,eAAe;AACnC,cAAW,uBAAuB,UAAU,oBAAoB;WACzD,GAAG;AACV,WAAQ,MAAM,EAAE;;;AAIpB,QAAO;EACL,MAAM;EACN,SAAS;EACT,MAAM,YAAY,IAAI,EAAE,SAAS;AAC/B,SAAM,SAAS;IACb,MAAM;IACN;IACD,CAAC;;EAEJ,MAAM,EACJ,MAAM,eAAe,QAAQ;AAC3B,0BAAuB,EAAE,MAAM,OAAO,MAAM,CAAC;AAC7C,SAAM,UAAU;KAEnB;EACD,OAAO,UAAU;AACf,2BAAwB;GAExB,IAAI,SAA2B;AAE/B,YAAS,MAAM,UAAU,WAAW,mBAAmB,UAAU,CAAC;AAElE,YAAS,MAAM,SAAS,WAAW,aAAa,YAAY;AAC1D,QAAI,OACF;IAIF,MAAM,sBAAsB,wBAAwB;AAEpD,cADiB,MAAM,OAAO,aAE3B,MAAM,qBAAqB,EAAE,eAAe,MAAM,CAAC,CACnD,GAAG,QAAQ,SAAS,SAAS;KAAE;KAAM,OAAO;KAAU,CAAC,CAAC;AAE3D,UAAM,UAAU;KAChB;AAEF,YAAS,MAAM,WAAW,IAAI,aAAa,YAAY;AACrD,QAAI,OACF,OAAM,OAAO,OAAO;KAEtB;;EAEJ,QAAQ,UAAU;AAChB,2BAAwB;GAExB,IAAI,SAA2B;AAE/B,YAAS,MAAM,UAAU,WAAW,mBAAmB,UAAU,CAAC;AAElE,YAAS,MAAM,SAAS,WAAW,aAAa,YAAY;AAC1D,QAAI,OACF;IAIF,MAAM,sBAAsB,wBAAwB;AAEpD,cADiB,MAAM,OAAO,aAE3B,MAAM,qBAAqB,EAAE,eAAe,MAAM,CAAC,CACnD,GAAG,QAAQ,SAAS,SAAS;KAAE;KAAM,OAAO;KAAU,CAAC,CAAC;AAE3D,UAAM,UAAU;KAChB;AAEF,YAAS,MAAM,WAAW,IAAI,aAAa,YAAY;AACrD,QAAI,OACF,OAAM,OAAO,OAAO;KAEtB;AAEF,YAAS,MAAM,KAAK,IAAI,mBAAmB;AACzC,YAAQ,KAAK,OAAO,cAAc,+BAA+B;KACjE;;EAEJ,SAAS,EACP,SAAS;AACP,2BAAwB;KAE3B;EACF"}
1
+ {"version":3,"file":"router-generator-plugin.js","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,EAAE,EAC1D,qBAC2E;CAC3E,IAAI,OAAe,QAAQ,KAAK;CAChC,IAAI;CACJ,IAAI;CAEJ,MAAM,gCACJ,WAAW,0BAA0B;CACvC,MAAM,+BAA+B;AACnC,SAAO,WAAW,WAAW,gBAAgB,GACzC,WAAW,kBACX,KAAK,MAAM,WAAW,gBAAgB;;CAG5C,MAAM,0BAA0B,SAA6B;AAC3D,MAAI,MAAM,KACR,QAAO,KAAK;AAEd,MAAI,OAAO,YAAY,WACrB,cAAa,SAAS;MAEtB,cAAa,YAAU,SAAS,KAAK;AAEvC,cAAY,IAAI,UAAU;GACxB,QAAQ;GACR,MAAM;GACP,CAAC;;CAGJ,MAAM,WAAW,OAAO,SAGlB;AACJ,MAAI,yBAAyB,CAC3B;EAEF,IAAI,iBAA6C,KAAA;AACjD,MAAI,MAAM;GACR,MAAM,WAAW,UAAU,KAAK,KAAK;AACrC,OAAI,aAAa,kBAAkB,EAAE,iBAAiB,MAAM,CAAC,EAAE;AAC7D,4BAAwB;AACxB;;AAEF,oBAAiB;IAAE,MAAM;IAAU,MAAM,KAAK;IAAO;;AAGvD,MAAI;AACF,SAAM,UAAU,IAAI,eAAe;AACnC,uBAAoB,eAAe,UAAU,oBAAoB;WAC1D,GAAG;AACV,WAAQ,MAAM,EAAE;;;AAIpB,QAAO;EACL,MAAM;EACN,SAAS;EACT,MAAM,YAAY,IAAI,EAAE,SAAS;AAC/B,SAAM,SAAS;IACb,MAAM;IACN;IACD,CAAC;;EAEJ,MAAM,EACJ,MAAM,eAAe,QAAQ;AAC3B,0BAAuB,EAAE,MAAM,OAAO,MAAM,CAAC;AAC7C,SAAM,UAAU;KAEnB;EACD,OAAO,UAAU;AACf,2BAAwB;GAExB,IAAI,SAA2B;AAE/B,YAAS,MAAM,UAAU,WAAW,mBAAmB,UAAU,CAAC;AAElE,YAAS,MAAM,SAAS,WAAW,aAAa,YAAY;AAC1D,QAAI,OACF;IAIF,MAAM,sBAAsB,wBAAwB;AAEpD,cADiB,MAAM,OAAO,aAE3B,MAAM,qBAAqB,EAAE,eAAe,MAAM,CAAC,CACnD,GAAG,QAAQ,SAAS,SAAS;KAAE;KAAM,OAAO;KAAU,CAAC,CAAC;AAE3D,UAAM,UAAU;KAChB;AAEF,YAAS,MAAM,WAAW,IAAI,aAAa,YAAY;AACrD,QAAI,OACF,OAAM,OAAO,OAAO;KAEtB;;EAEJ,QAAQ,UAAU;AAChB,2BAAwB;GAExB,IAAI,SAA2B;AAE/B,YAAS,MAAM,UAAU,WAAW,mBAAmB,UAAU,CAAC;AAElE,YAAS,MAAM,SAAS,WAAW,aAAa,YAAY;AAC1D,QAAI,OACF;IAIF,MAAM,sBAAsB,wBAAwB;AAEpD,cADiB,MAAM,OAAO,aAE3B,MAAM,qBAAqB,EAAE,eAAe,MAAM,CAAC,CACnD,GAAG,QAAQ,SAAS,SAAS;KAAE;KAAM,OAAO;KAAU,CAAC,CAAC;AAE3D,UAAM,UAAU;KAChB;AAEF,YAAS,MAAM,WAAW,IAAI,aAAa,YAAY;AACrD,QAAI,OACF,OAAM,OAAO,OAAO;KAEtB;AAEF,YAAS,MAAM,KAAK,IAAI,mBAAmB;AACzC,YAAQ,KAAK,OAAO,cAAc,+BAA+B;KACjE;;EAEJ,SAAS,EACP,SAAS;AACP,2BAAwB;KAE3B;EACF;;AAGH,IAAa,kCAER,UAAU,EAAE,KAAK;AACpB,QAAO,4BAA4B,SAAS,2BAA2B,CAAC"}
@@ -1,3 +1,5 @@
1
1
  import { UnpluginFactory } from 'unplugin';
2
2
  import { Config } from './config.js';
3
+ import { RouterPluginContext } from './router-plugin-context.js';
4
+ export declare function createRouterHmrPlugin(options: Partial<Config | (() => Config)> | undefined, routerPluginContext: RouterPluginContext): ReturnType<UnpluginFactory<Partial<Config> | undefined>>;
3
5
  export declare const unpluginRouterHmrFactory: UnpluginFactory<Partial<Config> | undefined>;
@@ -15,9 +15,12 @@ var includeCode = [
15
15
  "createRootRoute(",
16
16
  "createRootRouteWithContext("
17
17
  ];
18
- var unpluginRouterHmrFactory = (options = {}) => {
18
+ function createRouterHmrPlugin(options = {}, routerPluginContext) {
19
19
  let ROOT = process.cwd();
20
- let userConfig = options;
20
+ const resolveUserConfig = () => {
21
+ return getConfig(typeof options === "function" ? options() : options, ROOT);
22
+ };
23
+ let userConfig = resolveUserConfig();
21
24
  return {
22
25
  name: "tanstack-router:hmr",
23
26
  enforce: "pre",
@@ -28,7 +31,7 @@ var unpluginRouterHmrFactory = (options = {}) => {
28
31
  },
29
32
  handler(code, id) {
30
33
  const normalizedId = normalizePath(id);
31
- const routeEntry = globalThis.TSR_ROUTES_BY_ID_MAP?.get(normalizedId);
34
+ const routeEntry = routerPluginContext.routesByFile.get(normalizedId);
32
35
  if (!routeEntry) return null;
33
36
  if (debug) console.info("Adding HMR handling to route ", normalizedId);
34
37
  const hmrStyle = userConfig.plugin?.hmr?.style ?? "vite";
@@ -78,7 +81,7 @@ var unpluginRouterHmrFactory = (options = {}) => {
78
81
  vite: {
79
82
  configResolved(config) {
80
83
  ROOT = config.root;
81
- userConfig = getConfig(options, ROOT);
84
+ userConfig = resolveUserConfig();
82
85
  },
83
86
  applyToEnvironment(environment) {
84
87
  if (userConfig.plugin?.vite?.environmentName) return userConfig.plugin.vite.environmentName === environment.name;
@@ -86,8 +89,8 @@ var unpluginRouterHmrFactory = (options = {}) => {
86
89
  }
87
90
  }
88
91
  };
89
- };
92
+ }
90
93
  //#endregion
91
- export { unpluginRouterHmrFactory };
94
+ export { createRouterHmrPlugin };
92
95
 
93
96
  //# sourceMappingURL=router-hmr-plugin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"router-hmr-plugin.js","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 } from './utils'\nimport { getConfig } from './config'\nimport type { UnpluginFactory } from 'unplugin'\nimport type { Config } from './config'\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\nconst includeCode = [\n 'createFileRoute(',\n 'createRootRoute(',\n 'createRootRouteWithContext(',\n]\nexport const unpluginRouterHmrFactory: UnpluginFactory<\n Partial<Config> | undefined\n> = (options = {}) => {\n let ROOT: string = process.cwd()\n let userConfig = options as Config\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: includeCode,\n },\n },\n handler(code, id) {\n const normalizedId = normalizePath(id)\n const routeEntry = globalThis.TSR_ROUTES_BY_ID_MAP?.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 })\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 = getConfig(options, ROOT)\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"],"mappings":";;;;;;;;;;;;AAeA,IAAM,cAAc;CAClB;CACA;CACA;CACD;AACD,IAAa,4BAER,UAAU,EAAE,KAAK;CACpB,IAAI,OAAe,QAAQ,KAAK;CAChC,IAAI,aAAa;AAEjB,QAAO;EACL,MAAM;EACN,SAAS;EACT,WAAW;GACT,QAAQ;IAEN,IAAI;IACJ,MAAM,EACJ,SAAS,aACV;IACF;GACD,QAAQ,MAAM,IAAI;IAChB,MAAM,eAAe,cAAc,GAAG;IACtC,MAAM,aAAa,WAAW,sBAAsB,IAAI,aAAa;AACrE,QAAI,CAAC,WACH,QAAO;AAGT,QAAI,MAAO,SAAQ,KAAK,iCAAiC,aAAa;IAEtE,MAAM,WAAW,WAAW,QAAQ,KAAK,SAAS;AAElD,QAAI,WAAW,WAAW,SAAS;KACjC,MAAM,kBAAkB,iCAAiC;MACvD,iBAAiB;MACjB,QAAQ;MACR;MACD,CAAC;KACF,MAAM,WAAW,+BAA+B;MAC9C;MACA,UAAU;MACV,IAAI;MACJ,QAAQ;MACR;MACA,YAAY,WAAW;MACvB,oBAAoB,EAAE;MACtB,iBAAiB;MACjB;MACD,CAAC;AAEF,SAAI,UAAU;AACZ,UAAI,OAAO;AACT,eAAQ,MAAM,SAAS,KAAK;AAC5B,eAAQ,IAAI,aAAa,SAAS,OAAO,OAAO;;AAGlD,aAAO;;;IAIX,MAAM,MAAM,SAAS,EAAE,MAAM,CAAC;AAC9B,QAAI,QAAQ,KAAK,KACf,GAAG,wBAAwB,EAAE,EAAE;KAC7B;KACA,iBAAiB,WAAW;KAC5B,SAAS,WAAW;KACrB,CAAC,CACH;IACD,MAAM,SAAS,gBAAgB,KAAK;KAClC,YAAY;KACZ,UAAU;KACV,gBAAgB;KACjB,CAAC;AACF,QAAI,OAAO;AACT,aAAQ,MAAM,OAAO,KAAK;AAC1B,aAAQ,IAAI,aAAa,OAAO,OAAO,OAAO;;AAEhD,WAAO;;GAEV;EACD,MAAM;GACJ,eAAe,QAAQ;AACrB,WAAO,OAAO;AACd,iBAAa,UAAU,SAAS,KAAK;;GAEvC,mBAAmB,aAAa;AAC9B,QAAI,WAAW,QAAQ,MAAM,gBAC3B,QAAO,WAAW,OAAO,KAAK,oBAAoB,YAAY;AAEhE,WAAO;;GAEV;EACF"}
1
+ {"version":3,"file":"router-hmr-plugin.js","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 } 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\nconst includeCode = [\n 'createFileRoute(',\n 'createRootRoute(',\n 'createRootRouteWithContext(',\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: includeCode,\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 })\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,IAAM,cAAc;CAClB;CACA;CACA;CACD;AAED,SAAgB,sBACd,UAAwD,EAAE,EAC1D,qBAC0D;CAC1D,IAAI,OAAe,QAAQ,KAAK;CAEhC,MAAM,0BAA0B;AAC9B,SAAO,UAAU,OAAO,YAAY,aAAa,SAAS,GAAG,SAAS,KAAK;;CAG7E,IAAI,aAAa,mBAAmB;AAEpC,QAAO;EACL,MAAM;EACN,SAAS;EACT,WAAW;GACT,QAAQ;IAEN,IAAI;IACJ,MAAM,EACJ,SAAS,aACV;IACF;GACD,QAAQ,MAAM,IAAI;IAChB,MAAM,eAAe,cAAc,GAAG;IACtC,MAAM,aAAa,oBAAoB,aAAa,IAAI,aAAa;AACrE,QAAI,CAAC,WACH,QAAO;AAGT,QAAI,MAAO,SAAQ,KAAK,iCAAiC,aAAa;IAEtE,MAAM,WAAW,WAAW,QAAQ,KAAK,SAAS;AAElD,QAAI,WAAW,WAAW,SAAS;KACjC,MAAM,kBAAkB,iCAAiC;MACvD,iBAAiB;MACjB,QAAQ;MACR;MACD,CAAC;KACF,MAAM,WAAW,+BAA+B;MAC9C;MACA,UAAU;MACV,IAAI;MACJ,QAAQ;MACR;MACA,YAAY,WAAW;MACvB,oBAAoB,EAAE;MACtB,iBAAiB;MACjB;MACD,CAAC;AAEF,SAAI,UAAU;AACZ,UAAI,OAAO;AACT,eAAQ,MAAM,SAAS,KAAK;AAC5B,eAAQ,IAAI,aAAa,SAAS,OAAO,OAAO;;AAGlD,aAAO;;;IAIX,MAAM,MAAM,SAAS,EAAE,MAAM,CAAC;AAC9B,QAAI,QAAQ,KAAK,KACf,GAAG,wBAAwB,EAAE,EAAE;KAC7B;KACA,iBAAiB,WAAW;KAC5B,SAAS,WAAW;KACrB,CAAC,CACH;IACD,MAAM,SAAS,gBAAgB,KAAK;KAClC,YAAY;KACZ,UAAU;KACV,gBAAgB;KACjB,CAAC;AACF,QAAI,OAAO;AACT,aAAQ,MAAM,OAAO,KAAK;AAC1B,aAAQ,IAAI,aAAa,OAAO,OAAO,OAAO;;AAEhD,WAAO;;GAEV;EACD,MAAM;GACJ,eAAe,QAAQ;AACrB,WAAO,OAAO;AACd,iBAAa,mBAAmB;;GAElC,mBAAmB,aAAa;AAC9B,QAAI,WAAW,QAAQ,MAAM,gBAC3B,QAAO,WAAW,OAAO,KAAK,oBAAoB,YAAY;AAEhE,WAAO;;GAEV;EACF"}
@@ -0,0 +1,5 @@
1
+ import { GetRoutesByFileMapResult } from '@tanstack/router-generator';
2
+ export type RouterPluginContext = {
3
+ routesByFile: GetRoutesByFileMapResult;
4
+ };
5
+ export declare function createRouterPluginContext(): RouterPluginContext;
@@ -0,0 +1,8 @@
1
+ //#region src/core/router-plugin-context.ts
2
+ function createRouterPluginContext() {
3
+ return { routesByFile: /* @__PURE__ */ new Map() };
4
+ }
5
+ //#endregion
6
+ export { createRouterPluginContext };
7
+
8
+ //# sourceMappingURL=router-plugin-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router-plugin-context.js","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;AAC/D,QAAO,EACL,8BAAc,IAAI,KAAK,EACxB"}
@@ -1,4 +1,6 @@
1
1
  import { configSchema, CodeSplittingOptions, Config } from './core/config.js';
2
+ import { RouterPluginContext } from './core/router-plugin-context.js';
3
+ type RouterPluginOptions = Partial<Config | (() => Config)> | undefined;
2
4
  /**
3
5
  * @example
4
6
  * ```ts
@@ -8,53 +10,7 @@ import { configSchema, CodeSplittingOptions, Config } from './core/config.js';
8
10
  * }
9
11
  * ```
10
12
  */
11
- declare const TanStackRouterGeneratorEsbuild: (options?: Partial<{
12
- target: "react" | "solid" | "vue";
13
- routeFileIgnorePrefix: string;
14
- routesDirectory: string;
15
- quoteStyle: "single" | "double";
16
- semicolons: boolean;
17
- disableLogging: boolean;
18
- routeTreeFileHeader: string[];
19
- indexToken: string | RegExp | {
20
- regex: string;
21
- flags?: string | undefined;
22
- };
23
- routeToken: string | RegExp | {
24
- regex: string;
25
- flags?: string | undefined;
26
- };
27
- generatedRouteTree: string;
28
- disableTypes: boolean;
29
- addExtensions: string | boolean;
30
- enableRouteTreeFormatting: boolean;
31
- tmpDir: string;
32
- importRoutesUsingAbsolutePaths: boolean;
33
- enableRouteGeneration?: boolean | undefined;
34
- codeSplittingOptions?: CodeSplittingOptions | undefined;
35
- plugin?: {
36
- vite?: {
37
- environmentName?: string | undefined;
38
- } | undefined;
39
- hmr?: {
40
- style?: "vite" | "webpack" | undefined;
41
- } | undefined;
42
- } | undefined;
43
- virtualRouteConfig?: string | import('@tanstack/virtual-file-routes').VirtualRootRoute | undefined;
44
- routeFilePrefix?: string | undefined;
45
- routeFileIgnorePattern?: string | undefined;
46
- pathParamsAllowedCharacters?: (";" | ":" | "@" | "&" | "=" | "+" | "$" | ",")[] | undefined;
47
- routeTreeFileFooter?: string[] | ((...args: unknown[]) => string[]) | undefined;
48
- autoCodeSplitting?: boolean | undefined;
49
- customScaffolding?: {
50
- routeTemplate?: string | undefined;
51
- lazyRouteTemplate?: string | undefined;
52
- } | undefined;
53
- experimental?: {
54
- enableCodeSplitting?: boolean | undefined;
55
- } | undefined;
56
- plugins?: import('@tanstack/router-generator').GeneratorPlugin[] | undefined;
57
- } | (() => Config)> | undefined) => import('unplugin').EsbuildPlugin;
13
+ declare const TanStackRouterGeneratorEsbuild: (options?: RouterPluginOptions, routerPluginContext?: RouterPluginContext) => import('unplugin').EsbuildPlugin;
58
14
  /**
59
15
  * @example
60
16
  * ```ts
@@ -64,53 +20,7 @@ declare const TanStackRouterGeneratorEsbuild: (options?: Partial<{
64
20
  * }
65
21
  * ```
66
22
  */
67
- declare const TanStackRouterCodeSplitterEsbuild: (options?: Partial<{
68
- target: "react" | "solid" | "vue";
69
- routeFileIgnorePrefix: string;
70
- routesDirectory: string;
71
- quoteStyle: "single" | "double";
72
- semicolons: boolean;
73
- disableLogging: boolean;
74
- routeTreeFileHeader: string[];
75
- indexToken: string | RegExp | {
76
- regex: string;
77
- flags?: string | undefined;
78
- };
79
- routeToken: string | RegExp | {
80
- regex: string;
81
- flags?: string | undefined;
82
- };
83
- generatedRouteTree: string;
84
- disableTypes: boolean;
85
- addExtensions: string | boolean;
86
- enableRouteTreeFormatting: boolean;
87
- tmpDir: string;
88
- importRoutesUsingAbsolutePaths: boolean;
89
- enableRouteGeneration?: boolean | undefined;
90
- codeSplittingOptions?: CodeSplittingOptions | undefined;
91
- plugin?: {
92
- vite?: {
93
- environmentName?: string | undefined;
94
- } | undefined;
95
- hmr?: {
96
- style?: "vite" | "webpack" | undefined;
97
- } | undefined;
98
- } | undefined;
99
- virtualRouteConfig?: string | import('@tanstack/virtual-file-routes').VirtualRootRoute | undefined;
100
- routeFilePrefix?: string | undefined;
101
- routeFileIgnorePattern?: string | undefined;
102
- pathParamsAllowedCharacters?: (";" | ":" | "@" | "&" | "=" | "+" | "$" | ",")[] | undefined;
103
- routeTreeFileFooter?: string[] | ((...args: unknown[]) => string[]) | undefined;
104
- autoCodeSplitting?: boolean | undefined;
105
- customScaffolding?: {
106
- routeTemplate?: string | undefined;
107
- lazyRouteTemplate?: string | undefined;
108
- } | undefined;
109
- experimental?: {
110
- enableCodeSplitting?: boolean | undefined;
111
- } | undefined;
112
- plugins?: import('@tanstack/router-generator').GeneratorPlugin[] | undefined;
113
- } | (() => Config)> | undefined) => import('unplugin').EsbuildPlugin;
23
+ declare const TanStackRouterCodeSplitterEsbuild: (options?: RouterPluginOptions, routerPluginContext?: RouterPluginContext) => import('unplugin').EsbuildPlugin;
114
24
  /**
115
25
  * @example
116
26
  * ```ts
@@ -216,4 +126,4 @@ declare const tanstackRouter: (options?: Partial<{
216
126
  } | (() => Config)> | undefined) => import('unplugin').EsbuildPlugin;
217
127
  export default TanStackRouterEsbuild;
218
128
  export { configSchema, TanStackRouterGeneratorEsbuild, TanStackRouterCodeSplitterEsbuild, TanStackRouterEsbuild, tanstackRouter, };
219
- export type { Config, CodeSplittingOptions };
129
+ export type { Config, CodeSplittingOptions, RouterPluginContext };
@@ -1,9 +1,11 @@
1
1
  import { configSchema } from "./core/config.js";
2
- import { unpluginRouterCodeSplitterFactory } from "./core/router-code-splitter-plugin.js";
3
- import { unpluginRouterGeneratorFactory } from "./core/router-generator-plugin.js";
2
+ import { createRouterPluginContext } from "./core/router-plugin-context.js";
3
+ import { createRouterCodeSplitterPlugin } from "./core/router-code-splitter-plugin.js";
4
+ import { createRouterGeneratorPlugin } from "./core/router-generator-plugin.js";
4
5
  import { unpluginRouterComposedFactory } from "./core/router-composed-plugin.js";
5
6
  import { createEsbuildPlugin } from "unplugin";
6
7
  //#region src/esbuild.ts
8
+ var defaultRouterPluginContext = createRouterPluginContext();
7
9
  /**
8
10
  * @example
9
11
  * ```ts
@@ -13,7 +15,10 @@ import { createEsbuildPlugin } from "unplugin";
13
15
  * }
14
16
  * ```
15
17
  */
16
- var TanStackRouterGeneratorEsbuild = createEsbuildPlugin(unpluginRouterGeneratorFactory);
18
+ var TanStackRouterGeneratorEsbuild = (options, routerPluginContext) => {
19
+ const pluginContext = routerPluginContext ?? defaultRouterPluginContext;
20
+ return createEsbuildPlugin((pluginOptions) => createRouterGeneratorPlugin(pluginOptions, pluginContext))(options);
21
+ };
17
22
  /**
18
23
  * @example
19
24
  * ```ts
@@ -23,7 +28,10 @@ var TanStackRouterGeneratorEsbuild = createEsbuildPlugin(unpluginRouterGenerator
23
28
  * }
24
29
  * ```
25
30
  */
26
- var TanStackRouterCodeSplitterEsbuild = createEsbuildPlugin(unpluginRouterCodeSplitterFactory);
31
+ var TanStackRouterCodeSplitterEsbuild = (options, routerPluginContext) => {
32
+ const pluginContext = routerPluginContext ?? defaultRouterPluginContext;
33
+ return createEsbuildPlugin((pluginOptions) => createRouterCodeSplitterPlugin(pluginOptions, pluginContext))(options);
34
+ };
27
35
  /**
28
36
  * @example
29
37
  * ```ts
@@ -1 +1 @@
1
- {"version":3,"file":"esbuild.js","names":[],"sources":["../../src/esbuild.ts"],"sourcesContent":["import { createEsbuildPlugin } from 'unplugin'\n\nimport { configSchema } from './core/config'\nimport { unpluginRouterCodeSplitterFactory } from './core/router-code-splitter-plugin'\nimport { unpluginRouterGeneratorFactory } from './core/router-generator-plugin'\nimport { unpluginRouterComposedFactory } from './core/router-composed-plugin'\n\nimport type { CodeSplittingOptions, Config } from './core/config'\n\n/**\n * @example\n * ```ts\n * export default {\n * plugins: [TanStackRouterGeneratorEsbuild()],\n * // ...\n * }\n * ```\n */\nconst TanStackRouterGeneratorEsbuild = createEsbuildPlugin(\n unpluginRouterGeneratorFactory,\n)\n\n/**\n * @example\n * ```ts\n * export default {\n * plugins: [TanStackRouterCodeSplitterEsbuild()],\n * // ...\n * }\n * ```\n */\nconst TanStackRouterCodeSplitterEsbuild = createEsbuildPlugin(\n unpluginRouterCodeSplitterFactory,\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 }\n"],"mappings":";;;;;;;;;;;;;;;AAkBA,IAAM,iCAAiC,oBACrC,+BACD;;;;;;;;;;AAWD,IAAM,oCAAoC,oBACxC,kCACD;;;;;;;;;;AAWD,IAAM,wBAAwB,oBAAoB,8BAA8B;AAChF,IAAM,iBAAiB"}
1
+ {"version":3,"file":"esbuild.js","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,2BAA2B;;;;;;;;;;AAW9D,IAAM,kCACJ,SACA,wBACG;CACH,MAAM,gBAAgB,uBAAuB;AAC7C,QAAO,qBAAqB,kBAC1B,4BAA4B,eAAe,cAAc,CAC1D,CAAC,QAAQ;;;;;;;;;;;AAYZ,IAAM,qCACJ,SACA,wBACG;CACH,MAAM,gBAAgB,uBAAuB;AAC7C,QAAO,qBAAqB,kBAC1B,+BAA+B,eAAe,cAAc,CAC7D,CAAC,QAAQ;;;;;;;;;;;AAYZ,IAAM,wBAAwB,oBAAoB,8BAA8B;AAChF,IAAM,iBAAiB"}
@@ -1,5 +1,7 @@
1
1
  export { configSchema, getConfig } from './core/config.js';
2
2
  export { unpluginRouterCodeSplitterFactory } from './core/router-code-splitter-plugin.js';
3
3
  export { unpluginRouterGeneratorFactory } from './core/router-generator-plugin.js';
4
+ export { createRouterPluginContext } from './core/router-plugin-context.js';
4
5
  export type { Config, ConfigInput, ConfigOutput, CodeSplittingOptions, DeletableNodes, HmrOptions, } from './core/config.js';
6
+ export type { RouterPluginContext } from './core/router-plugin-context.js';
5
7
  export { tsrSplit, splitRouteIdentNodes, defaultCodeSplitGroupings, } from './core/constants.js';
package/dist/esm/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { configSchema, getConfig } from "./core/config.js";
2
2
  import { defaultCodeSplitGroupings, splitRouteIdentNodes, tsrSplit } from "./core/constants.js";
3
+ import { createRouterPluginContext } from "./core/router-plugin-context.js";
3
4
  import { unpluginRouterCodeSplitterFactory } from "./core/router-code-splitter-plugin.js";
4
5
  import { unpluginRouterGeneratorFactory } from "./core/router-generator-plugin.js";
5
- export { configSchema, defaultCodeSplitGroupings, getConfig, splitRouteIdentNodes, tsrSplit, unpluginRouterCodeSplitterFactory, unpluginRouterGeneratorFactory };
6
+ export { configSchema, createRouterPluginContext, defaultCodeSplitGroupings, getConfig, splitRouteIdentNodes, tsrSplit, unpluginRouterCodeSplitterFactory, unpluginRouterGeneratorFactory };
@@ -1,4 +1,6 @@
1
1
  import { configSchema, CodeSplittingOptions, Config } from './core/config.js';
2
+ import { RouterPluginContext } from './core/router-plugin-context.js';
3
+ type RspackRouterPluginOptions = Partial<Config> | (() => Partial<Config>);
2
4
  /**
3
5
  * @example
4
6
  * ```ts
@@ -12,53 +14,7 @@ import { configSchema, CodeSplittingOptions, Config } from './core/config.js';
12
14
  * })
13
15
  * ```
14
16
  */
15
- declare const TanStackRouterGeneratorRspack: (options?: Partial<{
16
- target: "react" | "solid" | "vue";
17
- routeFileIgnorePrefix: string;
18
- routesDirectory: string;
19
- quoteStyle: "single" | "double";
20
- semicolons: boolean;
21
- disableLogging: boolean;
22
- routeTreeFileHeader: string[];
23
- indexToken: string | RegExp | {
24
- regex: string;
25
- flags?: string | undefined;
26
- };
27
- routeToken: string | RegExp | {
28
- regex: string;
29
- flags?: string | undefined;
30
- };
31
- generatedRouteTree: string;
32
- disableTypes: boolean;
33
- addExtensions: string | boolean;
34
- enableRouteTreeFormatting: boolean;
35
- tmpDir: string;
36
- importRoutesUsingAbsolutePaths: boolean;
37
- enableRouteGeneration?: boolean | undefined;
38
- codeSplittingOptions?: CodeSplittingOptions | undefined;
39
- plugin?: {
40
- vite?: {
41
- environmentName?: string | undefined;
42
- } | undefined;
43
- hmr?: {
44
- style?: "vite" | "webpack" | undefined;
45
- } | undefined;
46
- } | undefined;
47
- virtualRouteConfig?: string | import('@tanstack/virtual-file-routes').VirtualRootRoute | undefined;
48
- routeFilePrefix?: string | undefined;
49
- routeFileIgnorePattern?: string | undefined;
50
- pathParamsAllowedCharacters?: (";" | ":" | "@" | "&" | "=" | "+" | "$" | ",")[] | undefined;
51
- routeTreeFileFooter?: string[] | ((...args: unknown[]) => string[]) | undefined;
52
- autoCodeSplitting?: boolean | undefined;
53
- customScaffolding?: {
54
- routeTemplate?: string | undefined;
55
- lazyRouteTemplate?: string | undefined;
56
- } | undefined;
57
- experimental?: {
58
- enableCodeSplitting?: boolean | undefined;
59
- } | undefined;
60
- plugins?: import('@tanstack/router-generator').GeneratorPlugin[] | undefined;
61
- } | (() => Config)> | undefined) => import('unplugin').RspackPluginInstance;
17
+ declare const TanStackRouterGeneratorRspack: (options?: RspackRouterPluginOptions, routerPluginContext?: RouterPluginContext) => import('unplugin').RspackPluginInstance;
62
18
  /**
63
19
  * @example
64
20
  * ```ts
@@ -72,7 +28,7 @@ declare const TanStackRouterGeneratorRspack: (options?: Partial<{
72
28
  * })
73
29
  * ```
74
30
  */
75
- declare const TanStackRouterCodeSplitterRspack: (options?: unknown) => import('unplugin').RspackPluginInstance;
31
+ declare const TanStackRouterCodeSplitterRspack: (options?: RspackRouterPluginOptions, routerPluginContext?: RouterPluginContext) => import('unplugin').RspackPluginInstance;
76
32
  /**
77
33
  * @example
78
34
  * ```ts
@@ -90,4 +46,4 @@ declare const TanStackRouterRspack: (options?: unknown) => import('unplugin').Rs
90
46
  declare const tanstackRouter: (options?: unknown) => import('unplugin').RspackPluginInstance;
91
47
  export default TanStackRouterRspack;
92
48
  export { configSchema, TanStackRouterRspack, TanStackRouterGeneratorRspack, TanStackRouterCodeSplitterRspack, tanstackRouter, };
93
- export type { Config, CodeSplittingOptions };
49
+ export type { Config, CodeSplittingOptions, RouterPluginContext };
@@ -1,9 +1,11 @@
1
1
  import { configSchema } from "./core/config.js";
2
- import { unpluginRouterCodeSplitterFactory } from "./core/router-code-splitter-plugin.js";
3
- import { unpluginRouterGeneratorFactory } from "./core/router-generator-plugin.js";
2
+ import { createRouterPluginContext } from "./core/router-plugin-context.js";
3
+ import { createRouterCodeSplitterPlugin } from "./core/router-code-splitter-plugin.js";
4
+ import { createRouterGeneratorPlugin } from "./core/router-generator-plugin.js";
4
5
  import { unpluginRouterComposedFactory } from "./core/router-composed-plugin.js";
5
6
  import { createRspackPlugin } from "unplugin";
6
7
  //#region src/rspack.ts
8
+ var defaultRouterPluginContext = createRouterPluginContext();
7
9
  /**
8
10
  * Rspack uses webpack-compatible `module.hot` / `import.meta.webpackHot` HMR.
9
11
  * Force `plugin.hmr.style = 'webpack'` so the router HMR adapter emits
@@ -37,7 +39,10 @@ function withWebpackHmrStyle(options) {
37
39
  * })
38
40
  * ```
39
41
  */
40
- var TanStackRouterGeneratorRspack = /* @__PURE__ */ createRspackPlugin(unpluginRouterGeneratorFactory);
42
+ var TanStackRouterGeneratorRspack = (options, routerPluginContext) => {
43
+ const pluginContext = routerPluginContext ?? defaultRouterPluginContext;
44
+ return createRspackPlugin((pluginOptions) => createRouterGeneratorPlugin(pluginOptions, pluginContext))(options);
45
+ };
41
46
  /**
42
47
  * @example
43
48
  * ```ts
@@ -51,7 +56,10 @@ var TanStackRouterGeneratorRspack = /* @__PURE__ */ createRspackPlugin(unpluginR
51
56
  * })
52
57
  * ```
53
58
  */
54
- var TanStackRouterCodeSplitterRspack = /* @__PURE__ */ createRspackPlugin((options, meta) => unpluginRouterCodeSplitterFactory(withWebpackHmrStyle(options), meta));
59
+ var TanStackRouterCodeSplitterRspack = (options, routerPluginContext) => {
60
+ const pluginContext = routerPluginContext ?? defaultRouterPluginContext;
61
+ return createRspackPlugin((pluginOptions) => createRouterCodeSplitterPlugin(withWebpackHmrStyle(pluginOptions), pluginContext))(options);
62
+ };
55
63
  /**
56
64
  * @example
57
65
  * ```ts
@@ -1 +1 @@
1
- {"version":3,"file":"rspack.js","names":[],"sources":["../../src/rspack.ts"],"sourcesContent":["import { createRspackPlugin } from 'unplugin'\n\nimport { configSchema } from './core/config'\nimport { unpluginRouterCodeSplitterFactory } from './core/router-code-splitter-plugin'\nimport { unpluginRouterGeneratorFactory } from './core/router-generator-plugin'\nimport { unpluginRouterComposedFactory } from './core/router-composed-plugin'\nimport type { CodeSplittingOptions, Config } from './core/config'\n\ntype RspackRouterPluginOptions = Partial<Config> | (() => Partial<Config>)\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 = /* #__PURE__ */ createRspackPlugin(\n unpluginRouterGeneratorFactory,\n)\n\n/**\n * @example\n * ```ts\n * export default defineConfig({\n * // ...\n * tools: {\n * rspack: {\n * plugins: [TanStackRouterCodeSplitterRspack()],\n * },\n * },\n * })\n * ```\n */\nconst TanStackRouterCodeSplitterRspack = /* #__PURE__ */ createRspackPlugin(\n (options, meta) =>\n unpluginRouterCodeSplitterFactory(\n withWebpackHmrStyle(\n options as RspackRouterPluginOptions | undefined,\n ) as Partial<Config | (() => Config)>,\n meta,\n ),\n)\n\n/**\n * @example\n * ```ts\n * export default defineConfig({\n * // ...\n * tools: {\n * rspack: {\n * plugins: [tanstackRouter()],\n * },\n * },\n * })\n * ```\n */\nconst TanStackRouterRspack = /* #__PURE__ */ createRspackPlugin(\n (options, meta) =>\n unpluginRouterComposedFactory(\n 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 }\n"],"mappings":";;;;;;;;;;;;AAgBA,SAAS,oBACP,SAC2B;CAC3B,MAAM,iBACJ,YACqB;EACrB,GAAG;EACH,QAAQ;GACN,GAAG,QAAQ;GACX,KAAK;IACH,GAAG,QAAQ,QAAQ;IACnB,OAAO;IACR;GACF;EACF;AAED,KAAI,OAAO,YAAY,WACrB,cAAa,cAAc,SAAS,CAAC;AAGvC,QAAO,cAAc,QAAQ;;;;;;;;;;;;;;;AAgB/B,IAAM,gCAAgD,mCACpD,+BACD;;;;;;;;;;;;;;AAeD,IAAM,mCAAmD,oCACtD,SAAS,SACR,kCACE,oBACE,QACD,EACD,KACD,CACJ;;;;;;;;;;;;;;AAeD,IAAM,uBAAuC,oCAC1C,SAAS,SACR,8BACE,oBACE,QACD,EACD,KACD,CACJ;AACD,IAAM,iBAAiB"}
1
+ {"version":3,"file":"rspack.js","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,2BAA2B;;;;;;;AAQ9D,SAAS,oBACP,SAC2B;CAC3B,MAAM,iBACJ,YACqB;EACrB,GAAG;EACH,QAAQ;GACN,GAAG,QAAQ;GACX,KAAK;IACH,GAAG,QAAQ,QAAQ;IACnB,OAAO;IACR;GACF;EACF;AAED,KAAI,OAAO,YAAY,WACrB,cAAa,cAAc,SAAS,CAAC;AAGvC,QAAO,cAAc,QAAQ;;;;;;;;;;;;;;;AAgB/B,IAAM,iCACJ,SACA,wBACG;CACH,MAAM,gBAAgB,uBAAuB;AAC7C,QAAO,oBAAoB,kBACzB,4BACE,eACA,cACD,CACF,CAAC,QAAQ;;;;;;;;;;;;;;;AAgBZ,IAAM,oCACJ,SACA,wBACG;CACH,MAAM,gBAAgB,uBAAuB;AAC7C,QAAO,oBAAoB,kBACzB,+BACE,oBACE,cACD,EACD,cACD,CACF,CAAC,QAAQ;;;;;;;;;;;;;;;AAgBZ,IAAM,uBAAuC,oCAC1C,SAAS,SACR,8BACE,oBACE,QACD,EACD,KACD,CACJ;AACD,IAAM,iBAAiB"}
@@ -1,4 +1,6 @@
1
- import { configSchema, CodeSplittingOptions, Config, getConfig } from './core/config.js';
1
+ import { configSchema, getConfig, CodeSplittingOptions, Config } from './core/config.js';
2
+ import { RouterPluginContext } from './core/router-plugin-context.js';
3
+ type RouterPluginOptions = Partial<Config | (() => Config)> | undefined;
2
4
  /**
3
5
  * @example
4
6
  * ```ts
@@ -8,53 +10,7 @@ import { configSchema, CodeSplittingOptions, Config, getConfig } from './core/co
8
10
  * })
9
11
  * ```
10
12
  */
11
- declare const tanstackRouterGenerator: (options?: Partial<{
12
- target: "react" | "solid" | "vue";
13
- routeFileIgnorePrefix: string;
14
- routesDirectory: string;
15
- quoteStyle: "single" | "double";
16
- semicolons: boolean;
17
- disableLogging: boolean;
18
- routeTreeFileHeader: string[];
19
- indexToken: string | RegExp | {
20
- regex: string;
21
- flags?: string | undefined;
22
- };
23
- routeToken: string | RegExp | {
24
- regex: string;
25
- flags?: string | undefined;
26
- };
27
- generatedRouteTree: string;
28
- disableTypes: boolean;
29
- addExtensions: string | boolean;
30
- enableRouteTreeFormatting: boolean;
31
- tmpDir: string;
32
- importRoutesUsingAbsolutePaths: boolean;
33
- enableRouteGeneration?: boolean | undefined;
34
- codeSplittingOptions?: CodeSplittingOptions | undefined;
35
- plugin?: {
36
- vite?: {
37
- environmentName?: string | undefined;
38
- } | undefined;
39
- hmr?: {
40
- style?: "vite" | "webpack" | undefined;
41
- } | undefined;
42
- } | undefined;
43
- virtualRouteConfig?: string | import('@tanstack/virtual-file-routes').VirtualRootRoute | undefined;
44
- routeFilePrefix?: string | undefined;
45
- routeFileIgnorePattern?: string | undefined;
46
- pathParamsAllowedCharacters?: (";" | ":" | "@" | "&" | "=" | "+" | "$" | ",")[] | undefined;
47
- routeTreeFileFooter?: string[] | ((...args: unknown[]) => string[]) | undefined;
48
- autoCodeSplitting?: boolean | undefined;
49
- customScaffolding?: {
50
- routeTemplate?: string | undefined;
51
- lazyRouteTemplate?: string | undefined;
52
- } | undefined;
53
- experimental?: {
54
- enableCodeSplitting?: boolean | undefined;
55
- } | undefined;
56
- plugins?: import('@tanstack/router-generator').GeneratorPlugin[] | undefined;
57
- } | (() => Config)> | undefined) => import('vite').Plugin<any> | import('vite').Plugin<any>[];
13
+ declare const tanstackRouterGenerator: (options?: RouterPluginOptions, routerPluginContext?: RouterPluginContext) => import('vite').Plugin<any> | import('vite').Plugin<any>[];
58
14
  /**
59
15
  * @example
60
16
  * ```ts
@@ -64,53 +20,7 @@ declare const tanstackRouterGenerator: (options?: Partial<{
64
20
  * })
65
21
  * ```
66
22
  */
67
- declare const tanStackRouterCodeSplitter: (options?: Partial<{
68
- target: "react" | "solid" | "vue";
69
- routeFileIgnorePrefix: string;
70
- routesDirectory: string;
71
- quoteStyle: "single" | "double";
72
- semicolons: boolean;
73
- disableLogging: boolean;
74
- routeTreeFileHeader: string[];
75
- indexToken: string | RegExp | {
76
- regex: string;
77
- flags?: string | undefined;
78
- };
79
- routeToken: string | RegExp | {
80
- regex: string;
81
- flags?: string | undefined;
82
- };
83
- generatedRouteTree: string;
84
- disableTypes: boolean;
85
- addExtensions: string | boolean;
86
- enableRouteTreeFormatting: boolean;
87
- tmpDir: string;
88
- importRoutesUsingAbsolutePaths: boolean;
89
- enableRouteGeneration?: boolean | undefined;
90
- codeSplittingOptions?: CodeSplittingOptions | undefined;
91
- plugin?: {
92
- vite?: {
93
- environmentName?: string | undefined;
94
- } | undefined;
95
- hmr?: {
96
- style?: "vite" | "webpack" | undefined;
97
- } | undefined;
98
- } | undefined;
99
- virtualRouteConfig?: string | import('@tanstack/virtual-file-routes').VirtualRootRoute | undefined;
100
- routeFilePrefix?: string | undefined;
101
- routeFileIgnorePattern?: string | undefined;
102
- pathParamsAllowedCharacters?: (";" | ":" | "@" | "&" | "=" | "+" | "$" | ",")[] | undefined;
103
- routeTreeFileFooter?: string[] | ((...args: unknown[]) => string[]) | undefined;
104
- autoCodeSplitting?: boolean | undefined;
105
- customScaffolding?: {
106
- routeTemplate?: string | undefined;
107
- lazyRouteTemplate?: string | undefined;
108
- } | undefined;
109
- experimental?: {
110
- enableCodeSplitting?: boolean | undefined;
111
- } | undefined;
112
- plugins?: import('@tanstack/router-generator').GeneratorPlugin[] | undefined;
113
- } | (() => Config)> | undefined) => import('vite').Plugin<any> | import('vite').Plugin<any>[];
23
+ declare const tanStackRouterCodeSplitter: (options?: RouterPluginOptions, routerPluginContext?: RouterPluginContext) => import('vite').Plugin<any> | import('vite').Plugin<any>[];
114
24
  /**
115
25
  * @example
116
26
  * ```ts
@@ -219,4 +129,4 @@ declare const TanStackRouterVite: (options?: Partial<{
219
129
  } | (() => Config)> | undefined) => import('vite').Plugin<any> | import('vite').Plugin<any>[];
220
130
  export default tanstackRouter;
221
131
  export { configSchema, getConfig, tanStackRouterCodeSplitter, tanstackRouterGenerator, TanStackRouterVite, tanstackRouter, };
222
- export type { Config, CodeSplittingOptions };
132
+ export type { Config, CodeSplittingOptions, RouterPluginContext };