@tanstack/router-vite-plugin 1.23.0 → 1.24.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +14 -9
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.js +14 -9
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +17 -11
package/dist/cjs/index.cjs
CHANGED
|
@@ -14,21 +14,26 @@ function TanStackRouterVite(inlineConfig = {}) {
|
|
|
14
14
|
console.info();
|
|
15
15
|
}
|
|
16
16
|
};
|
|
17
|
+
const handleFile = async (file) => {
|
|
18
|
+
const filePath = path.normalize(file);
|
|
19
|
+
if (filePath === path.join(ROOT, CONFIG_FILE_NAME)) {
|
|
20
|
+
userConfig = await routerGenerator.getConfig(inlineConfig, ROOT);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const routesDirectoryPath = path.isAbsolute(userConfig.routesDirectory) ? userConfig.routesDirectory : path.join(ROOT, userConfig.routesDirectory);
|
|
24
|
+
if (filePath.startsWith(routesDirectoryPath)) {
|
|
25
|
+
await generate();
|
|
26
|
+
}
|
|
27
|
+
};
|
|
17
28
|
return {
|
|
18
29
|
name: "vite-plugin-tanstack-router",
|
|
19
30
|
configResolved: async () => {
|
|
20
31
|
userConfig = await routerGenerator.getConfig(inlineConfig, ROOT);
|
|
21
32
|
await generate();
|
|
22
33
|
},
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
userConfig = await routerGenerator.getConfig(inlineConfig, ROOT);
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
const routesDirectoryPath = path.isAbsolute(userConfig.routesDirectory) ? userConfig.routesDirectory : path.join(ROOT, userConfig.routesDirectory);
|
|
30
|
-
if (filePath.startsWith(routesDirectoryPath)) {
|
|
31
|
-
await generate();
|
|
34
|
+
watchChange: async (file, context) => {
|
|
35
|
+
if (["create", "update", "delete"].includes(context.event)) {
|
|
36
|
+
await handleFile(file);
|
|
32
37
|
}
|
|
33
38
|
}
|
|
34
39
|
};
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/index.ts"],"sourcesContent":["import { isAbsolute, join, normalize } from 'path'\nimport { type Config, generator, getConfig } from '@tanstack/router-generator'\nimport type { Plugin } from 'vite'\n\nconst CONFIG_FILE_NAME = 'tsr.config.json'\n\nexport function TanStackRouterVite(inlineConfig: Partial<Config> = {}): Plugin {\n const ROOT: string = process.cwd()\n let userConfig: Config\n\n const generate = async () => {\n try {\n await generator(userConfig)\n } catch (err) {\n console.error(err)\n console.info()\n }\n }\n\n
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/index.ts"],"sourcesContent":["import { isAbsolute, join, normalize } from 'path'\nimport { type Config, generator, getConfig } from '@tanstack/router-generator'\nimport type { Plugin } from 'vite'\n\nconst CONFIG_FILE_NAME = 'tsr.config.json'\n\nexport function TanStackRouterVite(inlineConfig: Partial<Config> = {}): Plugin {\n const ROOT: string = process.cwd()\n let userConfig: Config\n\n const generate = async () => {\n try {\n await generator(userConfig)\n } catch (err) {\n console.error(err)\n console.info()\n }\n }\n\n const handleFile = async (file: string) => {\n const filePath = normalize(file)\n if (filePath === join(ROOT, CONFIG_FILE_NAME)) {\n userConfig = await getConfig(inlineConfig, ROOT)\n return\n }\n const routesDirectoryPath = isAbsolute(userConfig.routesDirectory)\n ? userConfig.routesDirectory\n : join(ROOT, userConfig.routesDirectory)\n if (filePath.startsWith(routesDirectoryPath)) {\n await generate()\n }\n }\n\n return {\n name: 'vite-plugin-tanstack-router',\n configResolved: async () => {\n userConfig = await getConfig(inlineConfig, ROOT)\n await generate()\n },\n watchChange: async (file, context) => {\n if (['create', 'update', 'delete'].includes(context.event)) {\n await handleFile(file)\n }\n },\n }\n}\n"],"names":["generator","normalize","join","getConfig","isAbsolute"],"mappings":";;;;AAIA,MAAM,mBAAmB;AAET,SAAA,mBAAmB,eAAgC,IAAY;AACvE,QAAA,OAAe,QAAQ;AACzB,MAAA;AAEJ,QAAM,WAAW,YAAY;AACvB,QAAA;AACF,YAAMA,gBAAAA,UAAU,UAAU;AAAA,aACnB,KAAK;AACZ,cAAQ,MAAM,GAAG;AACjB,cAAQ,KAAK;AAAA,IACf;AAAA,EAAA;AAGI,QAAA,aAAa,OAAO,SAAiB;AACnC,UAAA,WAAWC,eAAU,IAAI;AAC/B,QAAI,aAAaC,KAAAA,KAAK,MAAM,gBAAgB,GAAG;AAChC,mBAAA,MAAMC,gBAAAA,UAAU,cAAc,IAAI;AAC/C;AAAA,IACF;AACM,UAAA,sBAAsBC,KAAAA,WAAW,WAAW,eAAe,IAC7D,WAAW,kBACXF,UAAK,MAAM,WAAW,eAAe;AACrC,QAAA,SAAS,WAAW,mBAAmB,GAAG;AAC5C,YAAM,SAAS;AAAA,IACjB;AAAA,EAAA;AAGK,SAAA;AAAA,IACL,MAAM;AAAA,IACN,gBAAgB,YAAY;AACb,mBAAA,MAAMC,gBAAAA,UAAU,cAAc,IAAI;AAC/C,YAAM,SAAS;AAAA,IACjB;AAAA,IACA,aAAa,OAAO,MAAM,YAAY;AAChC,UAAA,CAAC,UAAU,UAAU,QAAQ,EAAE,SAAS,QAAQ,KAAK,GAAG;AAC1D,cAAM,WAAW,IAAI;AAAA,MACvB;AAAA,IACF;AAAA,EAAA;AAEJ;;"}
|
package/dist/esm/index.js
CHANGED
|
@@ -12,21 +12,26 @@ function TanStackRouterVite(inlineConfig = {}) {
|
|
|
12
12
|
console.info();
|
|
13
13
|
}
|
|
14
14
|
};
|
|
15
|
+
const handleFile = async (file) => {
|
|
16
|
+
const filePath = normalize(file);
|
|
17
|
+
if (filePath === join(ROOT, CONFIG_FILE_NAME)) {
|
|
18
|
+
userConfig = await getConfig(inlineConfig, ROOT);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const routesDirectoryPath = isAbsolute(userConfig.routesDirectory) ? userConfig.routesDirectory : join(ROOT, userConfig.routesDirectory);
|
|
22
|
+
if (filePath.startsWith(routesDirectoryPath)) {
|
|
23
|
+
await generate();
|
|
24
|
+
}
|
|
25
|
+
};
|
|
15
26
|
return {
|
|
16
27
|
name: "vite-plugin-tanstack-router",
|
|
17
28
|
configResolved: async () => {
|
|
18
29
|
userConfig = await getConfig(inlineConfig, ROOT);
|
|
19
30
|
await generate();
|
|
20
31
|
},
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
userConfig = await getConfig(inlineConfig, ROOT);
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
const routesDirectoryPath = isAbsolute(userConfig.routesDirectory) ? userConfig.routesDirectory : join(ROOT, userConfig.routesDirectory);
|
|
28
|
-
if (filePath.startsWith(routesDirectoryPath)) {
|
|
29
|
-
await generate();
|
|
32
|
+
watchChange: async (file, context) => {
|
|
33
|
+
if (["create", "update", "delete"].includes(context.event)) {
|
|
34
|
+
await handleFile(file);
|
|
30
35
|
}
|
|
31
36
|
}
|
|
32
37
|
};
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/index.ts"],"sourcesContent":["import { isAbsolute, join, normalize } from 'path'\nimport { type Config, generator, getConfig } from '@tanstack/router-generator'\nimport type { Plugin } from 'vite'\n\nconst CONFIG_FILE_NAME = 'tsr.config.json'\n\nexport function TanStackRouterVite(inlineConfig: Partial<Config> = {}): Plugin {\n const ROOT: string = process.cwd()\n let userConfig: Config\n\n const generate = async () => {\n try {\n await generator(userConfig)\n } catch (err) {\n console.error(err)\n console.info()\n }\n }\n\n
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/index.ts"],"sourcesContent":["import { isAbsolute, join, normalize } from 'path'\nimport { type Config, generator, getConfig } from '@tanstack/router-generator'\nimport type { Plugin } from 'vite'\n\nconst CONFIG_FILE_NAME = 'tsr.config.json'\n\nexport function TanStackRouterVite(inlineConfig: Partial<Config> = {}): Plugin {\n const ROOT: string = process.cwd()\n let userConfig: Config\n\n const generate = async () => {\n try {\n await generator(userConfig)\n } catch (err) {\n console.error(err)\n console.info()\n }\n }\n\n const handleFile = async (file: string) => {\n const filePath = normalize(file)\n if (filePath === join(ROOT, CONFIG_FILE_NAME)) {\n userConfig = await getConfig(inlineConfig, ROOT)\n return\n }\n const routesDirectoryPath = isAbsolute(userConfig.routesDirectory)\n ? userConfig.routesDirectory\n : join(ROOT, userConfig.routesDirectory)\n if (filePath.startsWith(routesDirectoryPath)) {\n await generate()\n }\n }\n\n return {\n name: 'vite-plugin-tanstack-router',\n configResolved: async () => {\n userConfig = await getConfig(inlineConfig, ROOT)\n await generate()\n },\n watchChange: async (file, context) => {\n if (['create', 'update', 'delete'].includes(context.event)) {\n await handleFile(file)\n }\n },\n }\n}\n"],"names":[],"mappings":";;AAIA,MAAM,mBAAmB;AAET,SAAA,mBAAmB,eAAgC,IAAY;AACvE,QAAA,OAAe,QAAQ;AACzB,MAAA;AAEJ,QAAM,WAAW,YAAY;AACvB,QAAA;AACF,YAAM,UAAU,UAAU;AAAA,aACnB,KAAK;AACZ,cAAQ,MAAM,GAAG;AACjB,cAAQ,KAAK;AAAA,IACf;AAAA,EAAA;AAGI,QAAA,aAAa,OAAO,SAAiB;AACnC,UAAA,WAAW,UAAU,IAAI;AAC/B,QAAI,aAAa,KAAK,MAAM,gBAAgB,GAAG;AAChC,mBAAA,MAAM,UAAU,cAAc,IAAI;AAC/C;AAAA,IACF;AACM,UAAA,sBAAsB,WAAW,WAAW,eAAe,IAC7D,WAAW,kBACX,KAAK,MAAM,WAAW,eAAe;AACrC,QAAA,SAAS,WAAW,mBAAmB,GAAG;AAC5C,YAAM,SAAS;AAAA,IACjB;AAAA,EAAA;AAGK,SAAA;AAAA,IACL,MAAM;AAAA,IACN,gBAAgB,YAAY;AACb,mBAAA,MAAM,UAAU,cAAc,IAAI;AAC/C,YAAM,SAAS;AAAA,IACjB;AAAA,IACA,aAAa,OAAO,MAAM,YAAY;AAChC,UAAA,CAAC,UAAU,UAAU,QAAQ,EAAE,SAAS,QAAQ,KAAK,GAAG;AAC1D,cAAM,WAAW,IAAI;AAAA,MACvB;AAAA,IACF;AAAA,EAAA;AAEJ;"}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -17,23 +17,29 @@ export function TanStackRouterVite(inlineConfig: Partial<Config> = {}): Plugin {
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
const handleFile = async (file: string) => {
|
|
21
|
+
const filePath = normalize(file)
|
|
22
|
+
if (filePath === join(ROOT, CONFIG_FILE_NAME)) {
|
|
23
|
+
userConfig = await getConfig(inlineConfig, ROOT)
|
|
24
|
+
return
|
|
25
|
+
}
|
|
26
|
+
const routesDirectoryPath = isAbsolute(userConfig.routesDirectory)
|
|
27
|
+
? userConfig.routesDirectory
|
|
28
|
+
: join(ROOT, userConfig.routesDirectory)
|
|
29
|
+
if (filePath.startsWith(routesDirectoryPath)) {
|
|
30
|
+
await generate()
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
20
34
|
return {
|
|
21
35
|
name: 'vite-plugin-tanstack-router',
|
|
22
36
|
configResolved: async () => {
|
|
23
37
|
userConfig = await getConfig(inlineConfig, ROOT)
|
|
24
38
|
await generate()
|
|
25
39
|
},
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
userConfig = await getConfig(inlineConfig, ROOT)
|
|
30
|
-
return
|
|
31
|
-
}
|
|
32
|
-
const routesDirectoryPath = isAbsolute(userConfig.routesDirectory)
|
|
33
|
-
? userConfig.routesDirectory
|
|
34
|
-
: join(ROOT, userConfig.routesDirectory)
|
|
35
|
-
if (filePath.startsWith(routesDirectoryPath)) {
|
|
36
|
-
await generate()
|
|
40
|
+
watchChange: async (file, context) => {
|
|
41
|
+
if (['create', 'update', 'delete'].includes(context.event)) {
|
|
42
|
+
await handleFile(file)
|
|
37
43
|
}
|
|
38
44
|
},
|
|
39
45
|
}
|