@tanstack/router-plugin 1.43.8 → 1.43.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.
@@ -87,19 +87,27 @@ const unpluginRouterGeneratorFactory = (options = {}) => {
87
87
  },
88
88
  async rspack(compiler) {
89
89
  userConfig = await config.getConfig(options, ROOT);
90
- await run(generate);
91
- compiler.hooks.watchRun.tap(PLUGIN_NAME, async () => {
90
+ if (compiler.options.mode === "production") {
92
91
  await run(generate);
93
- });
92
+ } else {
93
+ const routesDirectoryPath = getRoutesDirectoryPath();
94
+ const chokidar = await import("chokidar");
95
+ chokidar.watch(routesDirectoryPath).on("add", async () => {
96
+ await run(generate);
97
+ });
98
+ }
94
99
  },
95
100
  async webpack(compiler) {
96
101
  userConfig = await config.getConfig(options, ROOT);
97
- await run(generate);
98
- const routesDirectoryPath = getRoutesDirectoryPath();
99
- const chokidar = await import("chokidar");
100
- chokidar.watch(routesDirectoryPath).on("add", async () => {
102
+ if (compiler.options.mode === "production") {
101
103
  await run(generate);
102
- });
104
+ } else {
105
+ const routesDirectoryPath = getRoutesDirectoryPath();
106
+ const chokidar = await import("chokidar");
107
+ chokidar.watch(routesDirectoryPath).on("add", async () => {
108
+ await run(generate);
109
+ });
110
+ }
103
111
  if (compiler.options.mode === "production") {
104
112
  compiler.hooks.done.tap(PLUGIN_NAME, (stats) => {
105
113
  console.log("✅ " + PLUGIN_NAME + ": route-tree generation done");
@@ -1 +1 @@
1
- {"version":3,"file":"router-generator.cjs","sources":["../../src/router-generator.ts"],"sourcesContent":["import { isAbsolute, join, normalize, resolve } from 'node:path'\nimport { generator } from '@tanstack/router-generator'\n\nimport { getConfig } from './config'\nimport { CONFIG_FILE_NAME } from './constants'\nimport type { UnpluginFactory } from 'unplugin'\nimport type { Config } from './config'\n\nlet lock = false\nconst checkLock = () => lock\nconst setLock = (bool: boolean) => {\n lock = bool\n}\n\nconst PLUGIN_NAME = 'unplugin:router-generator'\n\nexport const unpluginRouterGeneratorFactory: UnpluginFactory<\n Partial<Config> | undefined\n> = (options = {}) => {\n let ROOT: string = process.cwd()\n let userConfig = options as Config\n\n const getRoutesDirectoryPath = () => {\n return isAbsolute(userConfig.routesDirectory)\n ? userConfig.routesDirectory\n : join(ROOT, userConfig.routesDirectory)\n }\n\n const generate = async () => {\n if (checkLock()) {\n return\n }\n\n setLock(true)\n\n try {\n await generator(userConfig)\n } catch (err) {\n console.error(err)\n console.info()\n } finally {\n setLock(false)\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 === join(ROOT, CONFIG_FILE_NAME)) {\n userConfig = await getConfig(options, ROOT)\n return\n }\n\n if (\n event === 'update' &&\n filePath === resolve(userConfig.generatedRouteTree)\n ) {\n // skip generating routes if the generated route tree is updated\n return\n }\n\n const routesDirectoryPath = getRoutesDirectoryPath()\n if (filePath.startsWith(routesDirectoryPath)) {\n await generate()\n }\n }\n\n const run: (cb: () => Promise<void> | void) => Promise<void> = async (cb) => {\n if (userConfig.enableRouteGeneration ?? true) {\n await cb()\n }\n }\n\n return {\n name: 'router-generator-plugin',\n async watchChange(id, { event }) {\n await run(async () => {\n await handleFile(id, event)\n })\n },\n vite: {\n async configResolved(config) {\n ROOT = config.root\n userConfig = await getConfig(options, ROOT)\n\n await run(generate)\n },\n },\n async rspack(compiler) {\n userConfig = await getConfig(options, ROOT)\n\n await run(generate)\n\n compiler.hooks.watchRun.tap(PLUGIN_NAME, async () => {\n await run(generate)\n })\n },\n async webpack(compiler) {\n userConfig = await getConfig(options, ROOT)\n\n await run(generate)\n\n // webpack watcher doesn't register newly created files\n const routesDirectoryPath = getRoutesDirectoryPath()\n const chokidar = await import('chokidar')\n chokidar.watch(routesDirectoryPath).on('add', async () => {\n await run(generate)\n })\n\n if (compiler.options.mode === 'production') {\n compiler.hooks.done.tap(PLUGIN_NAME, (stats) => {\n console.log('✅ ' + PLUGIN_NAME + ': route-tree generation done')\n setTimeout(() => {\n process.exit(0)\n })\n })\n }\n },\n }\n}\n"],"names":["isAbsolute","join","generator","normalize","CONFIG_FILE_NAME","getConfig","resolve","config"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,IAAI,OAAO;AACX,MAAM,YAAY,MAAM;AACxB,MAAM,UAAU,CAAC,SAAkB;AAC1B,SAAA;AACT;AAEA,MAAM,cAAc;AAEb,MAAM,iCAET,CAAC,UAAU,OAAO;AAChB,MAAA,OAAe,QAAQ;AAC3B,MAAI,aAAa;AAEjB,QAAM,yBAAyB,MAAM;AAC5B,WAAAA,qBAAW,WAAW,eAAe,IACxC,WAAW,kBACXC,UAAAA,KAAK,MAAM,WAAW,eAAe;AAAA,EAAA;AAG3C,QAAM,WAAW,YAAY;AAC3B,QAAI,aAAa;AACf;AAAA,IACF;AAEA,YAAQ,IAAI;AAER,QAAA;AACF,YAAMC,gBAAAA,UAAU,UAAU;AAAA,aACnB,KAAK;AACZ,cAAQ,MAAM,GAAG;AACjB,cAAQ,KAAK;AAAA,IAAA,UACb;AACA,cAAQ,KAAK;AAAA,IACf;AAAA,EAAA;AAGI,QAAA,aAAa,OACjB,MACA,UACG;AACG,UAAA,WAAWC,oBAAU,IAAI;AAE/B,QAAI,aAAaF,UAAAA,KAAK,MAAMG,UAAgB,gBAAA,GAAG;AAChC,mBAAA,MAAMC,OAAAA,UAAU,SAAS,IAAI;AAC1C;AAAA,IACF;AAEA,QACE,UAAU,YACV,aAAaC,UAAAA,QAAQ,WAAW,kBAAkB,GAClD;AAEA;AAAA,IACF;AAEA,UAAM,sBAAsB;AACxB,QAAA,SAAS,WAAW,mBAAmB,GAAG;AAC5C,YAAM,SAAS;AAAA,IACjB;AAAA,EAAA;AAGI,QAAA,MAAyD,OAAO,OAAO;AACvE,QAAA,WAAW,yBAAyB,MAAM;AAC5C,YAAM,GAAG;AAAA,IACX;AAAA,EAAA;AAGK,SAAA;AAAA,IACL,MAAM;AAAA,IACN,MAAM,YAAY,IAAI,EAAE,SAAS;AAC/B,YAAM,IAAI,YAAY;AACd,cAAA,WAAW,IAAI,KAAK;AAAA,MAAA,CAC3B;AAAA,IACH;AAAA,IACA,MAAM;AAAA,MACJ,MAAM,eAAeC,UAAQ;AAC3B,eAAOA,SAAO;AACD,qBAAA,MAAMF,OAAAA,UAAU,SAAS,IAAI;AAE1C,cAAM,IAAI,QAAQ;AAAA,MACpB;AAAA,IACF;AAAA,IACA,MAAM,OAAO,UAAU;AACR,mBAAA,MAAMA,OAAAA,UAAU,SAAS,IAAI;AAE1C,YAAM,IAAI,QAAQ;AAElB,eAAS,MAAM,SAAS,IAAI,aAAa,YAAY;AACnD,cAAM,IAAI,QAAQ;AAAA,MAAA,CACnB;AAAA,IACH;AAAA,IACA,MAAM,QAAQ,UAAU;AACT,mBAAA,MAAMA,OAAAA,UAAU,SAAS,IAAI;AAE1C,YAAM,IAAI,QAAQ;AAGlB,YAAM,sBAAsB;AACtB,YAAA,WAAW,MAAM,OAAO,UAAU;AACxC,eAAS,MAAM,mBAAmB,EAAE,GAAG,OAAO,YAAY;AACxD,cAAM,IAAI,QAAQ;AAAA,MAAA,CACnB;AAEG,UAAA,SAAS,QAAQ,SAAS,cAAc;AAC1C,iBAAS,MAAM,KAAK,IAAI,aAAa,CAAC,UAAU;AACtC,kBAAA,IAAI,OAAO,cAAc,8BAA8B;AAC/D,qBAAW,MAAM;AACf,oBAAQ,KAAK,CAAC;AAAA,UAAA,CACf;AAAA,QAAA,CACF;AAAA,MACH;AAAA,IACF;AAAA,EAAA;AAEJ;;"}
1
+ {"version":3,"file":"router-generator.cjs","sources":["../../src/router-generator.ts"],"sourcesContent":["import { isAbsolute, join, normalize, resolve } from 'node:path'\nimport { generator } from '@tanstack/router-generator'\n\nimport { getConfig } from './config'\nimport { CONFIG_FILE_NAME } from './constants'\nimport type { UnpluginFactory } from 'unplugin'\nimport type { Config } from './config'\n\nlet lock = false\nconst checkLock = () => lock\nconst setLock = (bool: boolean) => {\n lock = bool\n}\n\nconst PLUGIN_NAME = 'unplugin:router-generator'\n\nexport const unpluginRouterGeneratorFactory: UnpluginFactory<\n Partial<Config> | undefined\n> = (options = {}) => {\n let ROOT: string = process.cwd()\n let userConfig = options as Config\n\n const getRoutesDirectoryPath = () => {\n return isAbsolute(userConfig.routesDirectory)\n ? userConfig.routesDirectory\n : join(ROOT, userConfig.routesDirectory)\n }\n\n const generate = async () => {\n if (checkLock()) {\n return\n }\n\n setLock(true)\n\n try {\n await generator(userConfig)\n } catch (err) {\n console.error(err)\n console.info()\n } finally {\n setLock(false)\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 === join(ROOT, CONFIG_FILE_NAME)) {\n userConfig = await getConfig(options, ROOT)\n return\n }\n\n if (\n event === 'update' &&\n filePath === resolve(userConfig.generatedRouteTree)\n ) {\n // skip generating routes if the generated route tree is updated\n return\n }\n\n const routesDirectoryPath = getRoutesDirectoryPath()\n if (filePath.startsWith(routesDirectoryPath)) {\n await generate()\n }\n }\n\n const run: (cb: () => Promise<void> | void) => Promise<void> = async (cb) => {\n if (userConfig.enableRouteGeneration ?? true) {\n await cb()\n }\n }\n\n return {\n name: 'router-generator-plugin',\n async watchChange(id, { event }) {\n await run(async () => {\n await handleFile(id, event)\n })\n },\n vite: {\n async configResolved(config) {\n ROOT = config.root\n userConfig = await getConfig(options, ROOT)\n\n await run(generate)\n },\n },\n async rspack(compiler) {\n userConfig = await getConfig(options, ROOT)\n\n // rspack watcher doesn't register newly created files\n if (compiler.options.mode === 'production') {\n await run(generate)\n } else {\n const routesDirectoryPath = getRoutesDirectoryPath()\n const chokidar = await import('chokidar')\n chokidar.watch(routesDirectoryPath).on('add', async () => {\n await run(generate)\n })\n }\n },\n async webpack(compiler) {\n userConfig = await getConfig(options, ROOT)\n\n // webpack watcher doesn't register newly created files\n if (compiler.options.mode === 'production') {\n await run(generate)\n } else {\n const routesDirectoryPath = getRoutesDirectoryPath()\n const chokidar = await import('chokidar')\n chokidar.watch(routesDirectoryPath).on('add', async () => {\n await run(generate)\n })\n }\n\n if (compiler.options.mode === 'production') {\n compiler.hooks.done.tap(PLUGIN_NAME, (stats) => {\n console.log('✅ ' + PLUGIN_NAME + ': route-tree generation done')\n setTimeout(() => {\n process.exit(0)\n })\n })\n }\n },\n }\n}\n"],"names":["isAbsolute","join","generator","normalize","CONFIG_FILE_NAME","getConfig","resolve","config"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,IAAI,OAAO;AACX,MAAM,YAAY,MAAM;AACxB,MAAM,UAAU,CAAC,SAAkB;AAC1B,SAAA;AACT;AAEA,MAAM,cAAc;AAEb,MAAM,iCAET,CAAC,UAAU,OAAO;AAChB,MAAA,OAAe,QAAQ;AAC3B,MAAI,aAAa;AAEjB,QAAM,yBAAyB,MAAM;AAC5B,WAAAA,qBAAW,WAAW,eAAe,IACxC,WAAW,kBACXC,UAAAA,KAAK,MAAM,WAAW,eAAe;AAAA,EAAA;AAG3C,QAAM,WAAW,YAAY;AAC3B,QAAI,aAAa;AACf;AAAA,IACF;AAEA,YAAQ,IAAI;AAER,QAAA;AACF,YAAMC,gBAAAA,UAAU,UAAU;AAAA,aACnB,KAAK;AACZ,cAAQ,MAAM,GAAG;AACjB,cAAQ,KAAK;AAAA,IAAA,UACb;AACA,cAAQ,KAAK;AAAA,IACf;AAAA,EAAA;AAGI,QAAA,aAAa,OACjB,MACA,UACG;AACG,UAAA,WAAWC,oBAAU,IAAI;AAE/B,QAAI,aAAaF,UAAAA,KAAK,MAAMG,UAAgB,gBAAA,GAAG;AAChC,mBAAA,MAAMC,OAAAA,UAAU,SAAS,IAAI;AAC1C;AAAA,IACF;AAEA,QACE,UAAU,YACV,aAAaC,UAAAA,QAAQ,WAAW,kBAAkB,GAClD;AAEA;AAAA,IACF;AAEA,UAAM,sBAAsB;AACxB,QAAA,SAAS,WAAW,mBAAmB,GAAG;AAC5C,YAAM,SAAS;AA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W,MAAM;AACf,oBAAQ,KAAK,CAAC;AAAA,UAAA,CACf;AAAA,QAAA,CACF;AAAA,MACH;AAAA,IACF;AAAA,EAAA;AAEJ;;"}
@@ -63,19 +63,27 @@ const unpluginRouterGeneratorFactory = (options = {}) => {
63
63
  },
64
64
  async rspack(compiler) {
65
65
  userConfig = await getConfig(options, ROOT);
66
- await run(generate);
67
- compiler.hooks.watchRun.tap(PLUGIN_NAME, async () => {
66
+ if (compiler.options.mode === "production") {
68
67
  await run(generate);
69
- });
68
+ } else {
69
+ const routesDirectoryPath = getRoutesDirectoryPath();
70
+ const chokidar = await import("chokidar");
71
+ chokidar.watch(routesDirectoryPath).on("add", async () => {
72
+ await run(generate);
73
+ });
74
+ }
70
75
  },
71
76
  async webpack(compiler) {
72
77
  userConfig = await getConfig(options, ROOT);
73
- await run(generate);
74
- const routesDirectoryPath = getRoutesDirectoryPath();
75
- const chokidar = await import("chokidar");
76
- chokidar.watch(routesDirectoryPath).on("add", async () => {
78
+ if (compiler.options.mode === "production") {
77
79
  await run(generate);
78
- });
80
+ } else {
81
+ const routesDirectoryPath = getRoutesDirectoryPath();
82
+ const chokidar = await import("chokidar");
83
+ chokidar.watch(routesDirectoryPath).on("add", async () => {
84
+ await run(generate);
85
+ });
86
+ }
79
87
  if (compiler.options.mode === "production") {
80
88
  compiler.hooks.done.tap(PLUGIN_NAME, (stats) => {
81
89
  console.log("✅ " + PLUGIN_NAME + ": route-tree generation done");
@@ -1 +1 @@
1
- {"version":3,"file":"router-generator.js","sources":["../../src/router-generator.ts"],"sourcesContent":["import { isAbsolute, join, normalize, resolve } from 'node:path'\nimport { generator } from '@tanstack/router-generator'\n\nimport { getConfig } from './config'\nimport { CONFIG_FILE_NAME } from './constants'\nimport type { UnpluginFactory } from 'unplugin'\nimport type { Config } from './config'\n\nlet lock = false\nconst checkLock = () => lock\nconst setLock = (bool: boolean) => {\n lock = bool\n}\n\nconst PLUGIN_NAME = 'unplugin:router-generator'\n\nexport const unpluginRouterGeneratorFactory: UnpluginFactory<\n Partial<Config> | undefined\n> = (options = {}) => {\n let ROOT: string = process.cwd()\n let userConfig = options as Config\n\n const getRoutesDirectoryPath = () => {\n return isAbsolute(userConfig.routesDirectory)\n ? userConfig.routesDirectory\n : join(ROOT, userConfig.routesDirectory)\n }\n\n const generate = async () => {\n if (checkLock()) {\n return\n }\n\n setLock(true)\n\n try {\n await generator(userConfig)\n } catch (err) {\n console.error(err)\n console.info()\n } finally {\n setLock(false)\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 === join(ROOT, CONFIG_FILE_NAME)) {\n userConfig = await getConfig(options, ROOT)\n return\n }\n\n if (\n event === 'update' &&\n filePath === resolve(userConfig.generatedRouteTree)\n ) {\n // skip generating routes if the generated route tree is updated\n return\n }\n\n const routesDirectoryPath = getRoutesDirectoryPath()\n if (filePath.startsWith(routesDirectoryPath)) {\n await generate()\n }\n }\n\n const run: (cb: () => Promise<void> | void) => Promise<void> = async (cb) => {\n if (userConfig.enableRouteGeneration ?? true) {\n await cb()\n }\n }\n\n return {\n name: 'router-generator-plugin',\n async watchChange(id, { event }) {\n await run(async () => {\n await handleFile(id, event)\n })\n },\n vite: {\n async configResolved(config) {\n ROOT = config.root\n userConfig = await getConfig(options, ROOT)\n\n await run(generate)\n },\n },\n async rspack(compiler) {\n userConfig = await getConfig(options, ROOT)\n\n await run(generate)\n\n compiler.hooks.watchRun.tap(PLUGIN_NAME, async () => {\n await run(generate)\n })\n },\n async webpack(compiler) {\n userConfig = await getConfig(options, ROOT)\n\n await run(generate)\n\n // webpack watcher doesn't register newly created files\n const routesDirectoryPath = getRoutesDirectoryPath()\n const chokidar = await import('chokidar')\n chokidar.watch(routesDirectoryPath).on('add', async () => {\n await run(generate)\n })\n\n if (compiler.options.mode === 'production') {\n compiler.hooks.done.tap(PLUGIN_NAME, (stats) => {\n console.log('✅ ' + PLUGIN_NAME + ': route-tree generation done')\n setT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AAe,QAAQ;AAC3B,eAAO,OAAO;AACD,qBAAA,MAAM,UAAU,SAAS,IAAI;AAE1C,cAAM,IAAI,QAAQ;AAAA,MACpB;AAAA,IACF;AAAA,IACA,MAAM,OAAO,UAAU;AACR,mBAAA,MAAM,UAAU,SAAS,IAAI;AAE1C,YAAM,IAAI,QAAQ;AAElB,eAAS,MAAM,SAAS,IAAI,aAAa,YAAY;AACnD,cAAM,IAAI,QAAQ;AAAA,MAAA,CACnB;AAAA,IACH;AAAA,IACA,MAAM,QAAQ,UAAU;AACT,mBAAA,MAAM,UAAU,SAAS,IAAI;AAE1C,YAAM,IAAI,QAAQ;AAGlB,YAAM,sBAAsB;AACtB,YAAA,WAAW,MAAM,OAAO,UAAU;AACxC,eAAS,MAAM,mBAAmB,EAAE,GAAG,OAAO,YAAY;AACxD,cAAM,IAAI,QAAQ;AAAA,MAAA,CACnB;AAEG,UAAA,SAAS,QAAQ,SAAS,cAAc;AAC1C,iBAAS,MAAM,KAAK,IAAI,aAAa,CAAC,UAAU;AACtC,kBAAA,IAAI,OAAO,cAAc,8BAA8B;AAC/D,qBAAW,MAAM;AACf,oBAAQ,KAAK,CAAC;AAAA,UAAA,CACf;AAAA,QAAA,CACF;AAAA,MACH;AAAA,IACF;AAAA,EAAA;AAEJ;"}
1
+ {"version":3,"file":"router-generator.js","sources":["../../src/router-generator.ts"],"sourcesContent":["import { isAbsolute, join, normalize, resolve } from 'node:path'\nimport { generator } from '@tanstack/router-generator'\n\nimport { getConfig } from './config'\nimport { CONFIG_FILE_NAME } from './constants'\nimport type { UnpluginFactory } from 'unplugin'\nimport type { Config } from './config'\n\nlet lock = false\nconst checkLock = () => lock\nconst setLock = (bool: boolean) => {\n lock = bool\n}\n\nconst PLUGIN_NAME = 'unplugin:router-generator'\n\nexport const unpluginRouterGeneratorFactory: UnpluginFactory<\n Partial<Config> | undefined\n> = (options = {}) => {\n let ROOT: string = process.cwd()\n let userConfig = options as Config\n\n const getRoutesDirectoryPath = () => {\n return isAbsolute(userConfig.routesDirectory)\n ? userConfig.routesDirectory\n : join(ROOT, userConfig.routesDirectory)\n }\n\n const generate = async () => {\n if (checkLock()) {\n return\n }\n\n setLock(true)\n\n try {\n await generator(userConfig)\n } catch (err) {\n console.error(err)\n console.info()\n } finally {\n setLock(false)\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 === join(ROOT, CONFIG_FILE_NAME)) {\n userConfig = await getConfig(options, ROOT)\n return\n }\n\n if (\n event === 'update' &&\n filePath === resolve(userConfig.generatedRouteTree)\n ) {\n // skip generating routes if the generated route tree is updated\n return\n }\n\n const routesDirectoryPath = getRoutesDirectoryPath()\n if (filePath.startsWith(routesDirectoryPath)) {\n await generate()\n }\n }\n\n const run: (cb: () => Promise<void> | void) => Promise<void> = async (cb) => {\n if (userConfig.enableRouteGeneration ?? true) {\n await cb()\n }\n }\n\n return {\n name: 'router-generator-plugin',\n async watchChange(id, { event }) {\n await run(async () => {\n await handleFile(id, event)\n })\n },\n vite: {\n async configResolved(config) {\n ROOT = config.root\n userConfig = await getConfig(options, ROOT)\n\n await run(generate)\n },\n },\n async rspack(compiler) {\n userConfig = await getConfig(options, ROOT)\n\n // rspack watcher doesn't register newly created files\n if (compiler.options.mode === 'production') {\n await run(generate)\n } else {\n const routesDirectoryPath = getRoutesDirectoryPath()\n const chokidar = await import('chokidar')\n chokidar.watch(routesDirectoryPath).on('add', async () => {\n await run(generate)\n })\n }\n },\n async webpack(compiler) {\n userConfig = await getConfig(options, ROOT)\n\n // webpack watcher doesn't register newly created files\n if (compiler.options.mode === 'production') {\n await run(generate)\n } else {\n const routesDirectoryPath = getRoutesDirectoryPath()\n const chokidar = await import('chokidar')\n chokidar.watch(routesDirectoryPath).on('add', async () => {\n await run(generate)\n })\n }\n\n if (compiler.options.mode === 'production') {\n compiler.hooks.done.tap(PLUGIN_NAME, (stats) => {\n console.log('✅ ' + PLUGIN_NAME + ': route-t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J,MAAM,eAAe,QAAQ;AAC3B,eAAO,OAAO;AACD,qBAAA,MAAM,UAAU,SAAS,IAAI;AAE1C,cAAM,IAAI,QAAQ;AAAA,MACpB;AAAA,IACF;AAAA,IACA,MAAM,OAAO,UAAU;AACR,mBAAA,MAAM,UAAU,SAAS,IAAI;AAGtC,UAAA,SAAS,QAAQ,SAAS,cAAc;AAC1C,cAAM,IAAI,QAAQ;AAAA,MAAA,OACb;AACL,cAAM,sBAAsB;AACtB,cAAA,WAAW,MAAM,OAAO,UAAU;AACxC,iBAAS,MAAM,mBAAmB,EAAE,GAAG,OAAO,YAAY;AACxD,gBAAM,IAAI,QAAQ;AAAA,QAAA,CACnB;AAAA,MACH;AAAA,IACF;AAAA,IACA,MAAM,QAAQ,UAAU;AACT,mBAAA,MAAM,UAAU,SAAS,IAAI;AAGtC,UAAA,SAAS,QAAQ,SAAS,cAAc;AAC1C,cAAM,IAAI,QAAQ;AAAA,MAAA,OACb;AACL,cAAM,sBAAsB;AACtB,cAAA,WAAW,MAAM,OAAO,UAAU;AACxC,iBAAS,MAAM,mBAAmB,EAAE,GAAG,OAAO,YAAY;AACxD,gBAAM,IAAI,QAAQ;AAAA,QAAA,CACnB;AAAA,MACH;AAEI,UAAA,SAAS,QAAQ,SAAS,cAAc;AAC1C,iBAAS,MAAM,KAAK,IAAI,aAAa,CAAC,UAAU;AACtC,kBAAA,IAAI,OAAO,cAAc,8BAA8B;AAC/D,qBAAW,MAAM;AACf,oBAAQ,KAAK,CAAC;AAAA,UAAA,CACf;AAAA,QAAA,CACF;AAAA,MACH;AAAA,IACF;AAAA,EAAA;AAEJ;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tanstack/router-plugin",
3
- "version": "1.43.8",
4
- "description": "",
3
+ "version": "1.43.12",
4
+ "description": "Modern and scalable routing for React applications",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -14,6 +14,15 @@
14
14
  "type": "github",
15
15
  "url": "https://github.com/sponsors/tannerlinsley"
16
16
  },
17
+ "keywords": [
18
+ "react",
19
+ "location",
20
+ "router",
21
+ "routing",
22
+ "async",
23
+ "async router",
24
+ "typescript"
25
+ ],
17
26
  "type": "module",
18
27
  "exports": {
19
28
  ".": {
@@ -59,37 +68,12 @@
59
68
  "./package.json": "./package.json"
60
69
  },
61
70
  "sideEffects": false,
62
- "keywords": [
63
- "react",
64
- "location",
65
- "router",
66
- "routing",
67
- "async",
68
- "async router",
69
- "typescript"
70
- ],
71
- "engines": {
72
- "node": ">=12"
73
- },
74
71
  "files": [
75
72
  "dist",
76
- "src/**"
73
+ "src"
77
74
  ],
78
- "peerDependencies": {
79
- "@rsbuild/core": ">=0.7.9",
80
- "vite": ">=5.0.13",
81
- "webpack": ">=5.92.0"
82
- },
83
- "peerDependenciesMeta": {
84
- "vite": {
85
- "optional": true
86
- },
87
- "@rsbuild/core": {
88
- "optional": true
89
- },
90
- "webpack": {
91
- "optional": true
92
- }
75
+ "engines": {
76
+ "node": ">=12"
93
77
  },
94
78
  "dependencies": {
95
79
  "@babel/core": "^7.24.7",
@@ -106,12 +90,28 @@
106
90
  "@types/babel__traverse": "^7.20.6",
107
91
  "babel-dead-code-elimination": "^1.0.6",
108
92
  "chokidar": "^3.5.3",
109
- "unplugin": "^1.10.2",
93
+ "unplugin": "^1.11.0",
110
94
  "zod": "^3.22.4",
111
- "@tanstack/router-generator": "^1.43.1"
95
+ "@tanstack/router-generator": "^1.43.12"
112
96
  },
113
97
  "devDependencies": {
114
98
  "vite": "^5.3.1"
115
99
  },
100
+ "peerDependencies": {
101
+ "@rsbuild/core": ">=0.7.9",
102
+ "vite": ">=5.0.13",
103
+ "webpack": ">=5.92.0"
104
+ },
105
+ "peerDependenciesMeta": {
106
+ "vite": {
107
+ "optional": true
108
+ },
109
+ "@rsbuild/core": {
110
+ "optional": true
111
+ },
112
+ "webpack": {
113
+ "optional": true
114
+ }
115
+ },
116
116
  "scripts": {}
117
117
  }
@@ -92,23 +92,30 @@ export const unpluginRouterGeneratorFactory: UnpluginFactory<
92
92
  async rspack(compiler) {
93
93
  userConfig = await getConfig(options, ROOT)
94
94
 
95
- await run(generate)
96
-
97
- compiler.hooks.watchRun.tap(PLUGIN_NAME, async () => {
95
+ // rspack watcher doesn't register newly created files
96
+ if (compiler.options.mode === 'production') {
98
97
  await run(generate)
99
- })
98
+ } else {
99
+ const routesDirectoryPath = getRoutesDirectoryPath()
100
+ const chokidar = await import('chokidar')
101
+ chokidar.watch(routesDirectoryPath).on('add', async () => {
102
+ await run(generate)
103
+ })
104
+ }
100
105
  },
101
106
  async webpack(compiler) {
102
107
  userConfig = await getConfig(options, ROOT)
103
108
 
104
- await run(generate)
105
-
106
109
  // webpack watcher doesn't register newly created files
107
- const routesDirectoryPath = getRoutesDirectoryPath()
108
- const chokidar = await import('chokidar')
109
- chokidar.watch(routesDirectoryPath).on('add', async () => {
110
+ if (compiler.options.mode === 'production') {
110
111
  await run(generate)
111
- })
112
+ } else {
113
+ const routesDirectoryPath = getRoutesDirectoryPath()
114
+ const chokidar = await import('chokidar')
115
+ chokidar.watch(routesDirectoryPath).on('add', async () => {
116
+ await run(generate)
117
+ })
118
+ }
112
119
 
113
120
  if (compiler.options.mode === 'production') {
114
121
  compiler.hooks.done.tap(PLUGIN_NAME, (stats) => {