@tanstack/router-plugin 1.121.1 → 1.121.4

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.
@@ -106,7 +106,7 @@ const unpluginRouterGeneratorFactory = (options = {}) => {
106
106
  });
107
107
  },
108
108
  webpack(compiler) {
109
- userConfig = config.getConfig(options, ROOT);
109
+ initConfigAndGenerator();
110
110
  let handle = null;
111
111
  compiler.hooks.beforeRun.tapPromise(PLUGIN_NAME, generate);
112
112
  compiler.hooks.watchRun.tapPromise(PLUGIN_NAME, async () => {
@@ -1 +1 @@
1
- {"version":3,"file":"router-generator-plugin.cjs","sources":["../../../src/core/router-generator-plugin.ts"],"sourcesContent":["import { isAbsolute, join, normalize } from 'node:path'\nimport { Generator, resolveConfigPath } from '@tanstack/router-generator'\n\nimport { getConfig } from './config'\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> | undefined\n> = (options = {}) => {\n const ROOT: string = process.cwd()\n let userConfig = options as 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 = () => {\n userConfig = getConfig(options, ROOT)\n generator = new Generator({\n config: userConfig,\n root: ROOT,\n })\n }\n\n const generate = async () => {\n if (routeGenerationDisabled()) {\n return\n }\n try {\n await generator.run()\n } catch (e) {\n console.error(e)\n }\n }\n\n const handleFile = async (\n file: string,\n event: 'create' | 'update' | 'delete',\n ) => {\n const filePath = normalize(file)\n\n if (filePath === resolveConfigPath({ configDirectory: ROOT })) {\n initConfigAndGenerator()\n return\n }\n try {\n await generator.run({ path: filePath, type: event })\n } catch (e) {\n console.error(e)\n }\n }\n\n return {\n name: 'router-generator-plugin',\n enforce: 'pre',\n async watchChange(id, { event }) {\n if (!routeGenerationDisabled()) {\n await handleFile(id, event)\n }\n },\n async buildStart() {\n await generate()\n },\n vite: {\n configResolved() {\n initConfigAndGenerator()\n },\n async buildStart() {\n if (this.environment.config.consumer === 'server') {\n // When building in environment mode, we only need to generate routes\n // for the client environment\n return\n }\n await generate()\n },\n sharedDuringBuild: true,\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', generate)\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 userConfig = getConfig(options, ROOT)\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', generate)\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 }\n}\n"],"names":["isAbsolute","join","getConfig","Generator","normalize","resolveConfigPath"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,MAAM,cAAc;AAEb,MAAM,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../src/core/router-generator-plugin.ts"],"sourcesContent":["import { isAbsolute, join, normalize } from 'node:path'\nimport { Generator, resolveConfigPath } from '@tanstack/router-generator'\n\nimport { getConfig } from './config'\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> | undefined\n> = (options = {}) => {\n const ROOT: string = process.cwd()\n let userConfig = options as 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 = () => {\n userConfig = getConfig(options, ROOT)\n generator = new Generator({\n config: userConfig,\n root: ROOT,\n })\n }\n\n const generate = async () => {\n if (routeGenerationDisabled()) {\n return\n }\n try {\n await generator.run()\n } catch (e) {\n console.error(e)\n }\n }\n\n const handleFile = async (\n file: string,\n event: 'create' | 'update' | 'delete',\n ) => {\n const filePath = normalize(file)\n\n if (filePath === resolveConfigPath({ configDirectory: ROOT })) {\n initConfigAndGenerator()\n return\n }\n try {\n await generator.run({ path: filePath, type: event })\n } catch (e) {\n console.error(e)\n }\n }\n\n return {\n name: 'router-generator-plugin',\n enforce: 'pre',\n async watchChange(id, { event }) {\n if (!routeGenerationDisabled()) {\n await handleFile(id, event)\n }\n },\n async buildStart() {\n await generate()\n },\n vite: {\n configResolved() {\n initConfigAndGenerator()\n },\n async buildStart() {\n if (this.environment.config.consumer === 'server') {\n // When building in environment mode, we only need to generate routes\n // for the client environment\n return\n }\n await generate()\n },\n sharedDuringBuild: true,\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', generate)\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', generate)\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 }\n}\n"],"names":["isAbsolute","join","getConfig","Generator","normalize","resolveConfigPath"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,MAAM,cAAc;AAEb,MAAM,iCAET,CAAC,UAAU,OAAO;AACd,QAAA,OAAe,QAAQ,IAAI;AACjC,MAAI,aAAa;AACb,MAAA;AAEE,QAAA,0BAA0B,MAC9B,WAAW,0BAA0B;AACvC,QAAM,yBAAyB,MAAM;AAC5B,WAAAA,UAAA,WAAW,WAAW,eAAe,IACxC,WAAW,kBACXC,eAAK,MAAM,WAAW,eAAe;AAAA,EAC3C;AAEA,QAAM,yBAAyB,MAAM;AACtB,iBAAAC,OAAAA,UAAU,SAAS,IAAI;AACpC,gBAAY,IAAIC,gBAAAA,UAAU;AAAA,MACxB,QAAQ;AAAA,MACR,MAAM;AAAA,IAAA,CACP;AAAA,EACH;AAEA,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AAAA,MAAA,CAChB;AAED,eAAS,MAAM,WAAW,IAAI,aAAa,YAAY;AACrD,YAAI,QAAQ;AACV,gBAAM,OAAO,MAAM;AAAA,QAAA;AAAA,MACrB,CACD;AAAA,IACH;AAAA,IACA,QAAQ,UAAU;AACO,6BAAA;AAEvB,UAAI,SAA2B;AAE/B,eAAS,MAAM,UAAU,WAAW,aAAa,QAAQ;AAEzD,eAAS,MAAM,SAAS,WAAW,aAAa,YAAY;AAC1D,YAAI,QAAQ;AACV;AAAA,QAAA;AAIF,cAAM,sBAAsB,uBAAuB;AAC7C,cAAA,WAAW,MAAM,OAAO,UAAU;AAC/B,iBAAA,SACN,MAAM,qBAAqB,EAAE,eAAe,MAAM,EAClD,GAAG,OAAO,QAAQ;AAErB,cAAM,SAAS;AAAA,MAAA,CAChB;AAED,eAAS,MAAM,WAAW,IAAI,aAAa,YAAY;AACrD,YAAI,QAAQ;AACV,gBAAM,OAAO,MAAM;AAAA,QAAA;AAAA,MACrB,CACD;AAED,eAAS,MAAM,KAAK,IAAI,aAAa,MAAM;AACjC,gBAAA,KAAK,OAAO,cAAc,8BAA8B;AAAA,MAAA,CACjE;AAAA,IAAA;AAAA,EAEL;AACF;;"}
@@ -82,7 +82,7 @@ const unpluginRouterGeneratorFactory = (options = {}) => {
82
82
  });
83
83
  },
84
84
  webpack(compiler) {
85
- userConfig = getConfig(options, ROOT);
85
+ initConfigAndGenerator();
86
86
  let handle = null;
87
87
  compiler.hooks.beforeRun.tapPromise(PLUGIN_NAME, generate);
88
88
  compiler.hooks.watchRun.tapPromise(PLUGIN_NAME, async () => {
@@ -1 +1 @@
1
- {"version":3,"file":"router-generator-plugin.js","sources":["../../../src/core/router-generator-plugin.ts"],"sourcesContent":["import { isAbsolute, join, normalize } from 'node:path'\nimport { Generator, resolveConfigPath } from '@tanstack/router-generator'\n\nimport { getConfig } from './config'\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> | undefined\n> = (options = {}) => {\n const ROOT: string = process.cwd()\n let userConfig = options as 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 = () => {\n userConfig = getConfig(options, ROOT)\n generator = new Generator({\n config: userConfig,\n root: ROOT,\n })\n }\n\n const generate = async () => {\n if (routeGenerationDisabled()) {\n return\n }\n try {\n await generator.run()\n } catch (e) {\n console.error(e)\n }\n }\n\n const handleFile = async (\n file: string,\n event: 'create' | 'update' | 'delete',\n ) => {\n const filePath = normalize(file)\n\n if (filePath === resolveConfigPath({ configDirectory: ROOT })) {\n initConfigAndGenerator()\n return\n }\n try {\n await generator.run({ path: filePath, type: event })\n } catch (e) {\n console.error(e)\n }\n }\n\n return {\n name: 'router-generator-plugin',\n enforce: 'pre',\n async watchChange(id, { event }) {\n if (!routeGenerationDisabled()) {\n await handleFile(id, event)\n }\n },\n async buildStart() {\n await generate()\n },\n vite: {\n configResolved() {\n initConfigAndGenerator()\n },\n async buildStart() {\n if (this.environment.config.consumer === 'server') {\n // When building in environment mode, we only need to generate routes\n // for the client environment\n return\n }\n await generate()\n },\n sharedDuringBuild: true,\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', generate)\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 userConfig = getConfig(options, ROOT)\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', generate)\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 }\n}\n"],"names":[],"mappings":";;;AAQA,MAAM,cAAc;AAEb,MAAM,iCAET,CAAC,UAAU,OAAO;AACd,QAAA,OAAe,QAAQ,IAAI;AACjC,MAAI,aAAa;AACb,MAAA;AAEE,QAAA,0BAA0B,MAC9B,WAAW,0BAA0B;AACvC,QAAM,yBAAyB,MAAM;AAC5B,WAAA,WAAW,WAAW,eAAe,IACxC,WAAW,kBACX,KAAK,MAAM,WAAW,eAAe;AAAA,EAC3C;AAEA,QAAM,yBAAyB,MAAM;AACtB,iBAAA,UAAU,SAAS,IAAI;AACpC,gBAAY,IAAI,UAAU;AAAA,MACxB,QAAQ;AAAA,MACR,MAAM;AAAA,IAAA,CACP;AAAA,EACH;AAEA,QAAM,WAAW,YAAY;AAC3B,QAAI,2BAA2B;AAC7B;AAAA,IAAA;AAEE,QAAA;AACF,YAAM,UAAU,IAAI;AAAA,aACb,GAAG;AACV,cAAQ,MAAM,CAAC;AAAA,IAAA;AAAA,EAEnB;AAEM,QAAA,aAAa,OACjB,MACA,UACG;AACG,UAAA,WAAW,UAAU,IAAI;AAE/B,QAAI,aAAa,kBAAkB,EAAE,iBAAiB,KAAM,CAAA,G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AW,aAAa,YAAY;AAC1D,YAAI,QAAQ;AACV;AAAA,QAAA;AAIF,cAAM,sBAAsB,uBAAuB;AAC7C,cAAA,WAAW,MAAM,OAAO,UAAU;AAC/B,iBAAA,SACN,MAAM,qBAAqB,EAAE,eAAe,MAAM,EAClD,GAAG,OAAO,QAAQ;AAErB,cAAM,SAAS;AAAA,MAAA,CAChB;AAED,eAAS,MAAM,WAAW,IAAI,aAAa,YAAY;AACrD,YAAI,QAAQ;AACV,gBAAM,OAAO,MAAM;AAAA,QAAA;AAAA,MACrB,CACD;AAED,eAAS,MAAM,KAAK,IAAI,aAAa,MAAM;AACjC,gBAAA,KAAK,OAAO,cAAc,8BAA8B;AAAA,MAAA,CACjE;AAAA,IAAA;AAAA,EAEL;AACF;"}
1
+ {"version":3,"file":"router-generator-plugin.js","sources":["../../../src/core/router-generator-plugin.ts"],"sourcesContent":["import { isAbsolute, join, normalize } from 'node:path'\nimport { Generator, resolveConfigPath } from '@tanstack/router-generator'\n\nimport { getConfig } from './config'\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> | undefined\n> = (options = {}) => {\n const ROOT: string = process.cwd()\n let userConfig = options as 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 = () => {\n userConfig = getConfig(options, ROOT)\n generator = new Generator({\n config: userConfig,\n root: ROOT,\n })\n }\n\n const generate = async () => {\n if (routeGenerationDisabled()) {\n return\n }\n try {\n await generator.run()\n } catch (e) {\n console.error(e)\n }\n }\n\n const handleFile = async (\n file: string,\n event: 'create' | 'update' | 'delete',\n ) => {\n const filePath = normalize(file)\n\n if (filePath === resolveConfigPath({ configDirectory: ROOT })) {\n initConfigAndGenerator()\n return\n }\n try {\n await generator.run({ path: filePath, type: event })\n } catch (e) {\n console.error(e)\n }\n }\n\n return {\n name: 'router-generator-plugin',\n enforce: 'pre',\n async watchChange(id, { event }) {\n if (!routeGenerationDisabled()) {\n await handleFile(id, event)\n }\n },\n async buildStart() {\n await generate()\n },\n vite: {\n configResolved() {\n initConfigAndGenerator()\n },\n async buildStart() {\n if (this.environment.config.consumer === 'server') {\n // When building in environment mode, we only need to generate routes\n // for the client environment\n return\n }\n await generate()\n },\n sharedDuringBuild: true,\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', generate)\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', generate)\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 }\n}\n"],"names":[],"mappings":";;;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"1.121.1",
3
+ "version": "1.121.4",
4
4
  "description": "Modern and scalable routing for React applications",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
@@ -97,8 +97,8 @@
97
97
  "chokidar": "^3.6.0",
98
98
  "unplugin": "^2.1.2",
99
99
  "zod": "^3.24.2",
100
- "@tanstack/router-core": "^1.121.0",
101
- "@tanstack/router-generator": "^1.121.1",
100
+ "@tanstack/router-core": "^1.121.2",
101
+ "@tanstack/router-generator": "^1.121.2",
102
102
  "@tanstack/router-utils": "^1.121.0",
103
103
  "@tanstack/virtual-file-routes": "^1.120.17"
104
104
  },
@@ -112,7 +112,7 @@
112
112
  "vite": ">=5.0.0 || >=6.0.0",
113
113
  "vite-plugin-solid": "^2.11.2",
114
114
  "webpack": ">=5.92.0",
115
- "@tanstack/react-router": "^1.121.0"
115
+ "@tanstack/react-router": "^1.121.2"
116
116
  },
117
117
  "peerDependenciesMeta": {
118
118
  "@rsbuild/core": {
@@ -113,7 +113,7 @@ export const unpluginRouterGeneratorFactory: UnpluginFactory<
113
113
  })
114
114
  },
115
115
  webpack(compiler) {
116
- userConfig = getConfig(options, ROOT)
116
+ initConfigAndGenerator()
117
117
 
118
118
  let handle: FSWatcher | null = null
119
119