@tanstack/router-vite-plugin 1.8.2 → 1.10.0
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 +2 -18
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +1 -3
- package/dist/esm/index.d.ts +1 -3
- package/dist/esm/index.js +3 -19
- package/dist/esm/index.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +4 -27
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,24 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const path = require("path");
|
|
4
|
-
const promises = require("fs/promises");
|
|
5
4
|
const routerGenerator = require("@tanstack/router-generator");
|
|
6
5
|
const CONFIG_FILE_NAME = "tsr.config.json";
|
|
7
|
-
async function readConfigFile(path2) {
|
|
8
|
-
try {
|
|
9
|
-
const raw = await promises.readFile(path2, "utf-8");
|
|
10
|
-
return JSON.parse(raw);
|
|
11
|
-
} catch {
|
|
12
|
-
return {};
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
async function buildConfig(config, root) {
|
|
16
|
-
const fileConfig = await readConfigFile(path.join(root, CONFIG_FILE_NAME));
|
|
17
|
-
return routerGenerator.configSchema.parse({
|
|
18
|
-
...fileConfig,
|
|
19
|
-
...config
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
6
|
function TanStackRouterVite(inlineConfig = {}) {
|
|
23
7
|
let ROOT;
|
|
24
8
|
let userConfig;
|
|
@@ -34,13 +18,13 @@ function TanStackRouterVite(inlineConfig = {}) {
|
|
|
34
18
|
name: "vite-plugin-tanstack-router",
|
|
35
19
|
configResolved: async (vite) => {
|
|
36
20
|
ROOT = vite.root;
|
|
37
|
-
userConfig = await
|
|
21
|
+
userConfig = await routerGenerator.getConfig(inlineConfig, ROOT);
|
|
38
22
|
await generate();
|
|
39
23
|
},
|
|
40
24
|
handleHotUpdate: async ({ file }) => {
|
|
41
25
|
const filePath = path.normalize(file);
|
|
42
26
|
if (filePath === path.join(ROOT, CONFIG_FILE_NAME)) {
|
|
43
|
-
userConfig = await
|
|
27
|
+
userConfig = await routerGenerator.getConfig(inlineConfig, ROOT);
|
|
44
28
|
return;
|
|
45
29
|
}
|
|
46
30
|
if (filePath.startsWith(path.join(ROOT, userConfig.routesDirectory))) {
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/index.ts"],"sourcesContent":["import { Plugin } from 'vite'\nimport { join, normalize } from 'path'\nimport { readFile } from 'fs/promises'\nimport {
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/index.ts"],"sourcesContent":["import { Plugin } from 'vite'\nimport { join, normalize } from 'path'\nimport { readFile } from 'fs/promises'\nimport { type Config, getConfig, generator } from '@tanstack/router-generator'\n\nconst CONFIG_FILE_NAME = 'tsr.config.json'\n\nexport function TanStackRouterVite(inlineConfig: Partial<Config> = {}): Plugin {\n let ROOT: string\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 return {\n name: 'vite-plugin-tanstack-router',\n configResolved: async (vite) => {\n ROOT = vite.root\n userConfig = await getConfig(inlineConfig, ROOT)\n await generate()\n },\n handleHotUpdate: async ({ file }) => {\n const filePath = normalize(file)\n if (filePath === join(ROOT, CONFIG_FILE_NAME)) {\n userConfig = await getConfig(inlineConfig, ROOT)\n return\n }\n if (filePath.startsWith(join(ROOT, userConfig.routesDirectory))) {\n await generate()\n }\n },\n }\n}\n"],"names":["generator","getConfig","normalize","join"],"mappings":";;;;AAKA,MAAM,mBAAmB;AAET,SAAA,mBAAmB,eAAgC,IAAY;AACzE,MAAA;AACA,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;AAGK,SAAA;AAAA,IACL,MAAM;AAAA,IACN,gBAAgB,OAAO,SAAS;AAC9B,aAAO,KAAK;AACC,mBAAA,MAAMC,gBAAAA,UAAU,cAAc,IAAI;AAC/C,YAAM,SAAS;AAAA,IACjB;AAAA,IACA,iBAAiB,OAAO,EAAE,WAAW;AAC7B,YAAA,WAAWC,eAAU,IAAI;AAC/B,UAAI,aAAaC,KAAAA,KAAK,MAAM,gBAAgB,GAAG;AAChC,qBAAA,MAAMF,gBAAAA,UAAU,cAAc,IAAI;AAC/C;AAAA,MACF;AACA,UAAI,SAAS,WAAWE,KAAA,KAAK,MAAM,WAAW,eAAe,CAAC,GAAG;AAC/D,cAAM,SAAS;AAAA,MACjB;AAAA,IACF;AAAA,EAAA;AAEJ;;"}
|
package/dist/cjs/index.d.cts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
import { Plugin } from 'vite';
|
|
2
2
|
import { type Config } from '@tanstack/router-generator';
|
|
3
|
-
|
|
4
|
-
export declare function TanStackRouterVite(inlineConfig?: UserConfig): Plugin;
|
|
5
|
-
export {};
|
|
3
|
+
export declare function TanStackRouterVite(inlineConfig?: Partial<Config>): Plugin;
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
import { Plugin } from 'vite';
|
|
2
2
|
import { type Config } from '@tanstack/router-generator';
|
|
3
|
-
|
|
4
|
-
export declare function TanStackRouterVite(inlineConfig?: UserConfig): Plugin;
|
|
5
|
-
export {};
|
|
3
|
+
export declare function TanStackRouterVite(inlineConfig?: Partial<Config>): Plugin;
|
package/dist/esm/index.js
CHANGED
|
@@ -1,22 +1,6 @@
|
|
|
1
1
|
import { normalize, join } from "path";
|
|
2
|
-
import {
|
|
3
|
-
import { configSchema, generator } from "@tanstack/router-generator";
|
|
2
|
+
import { getConfig, generator } from "@tanstack/router-generator";
|
|
4
3
|
const CONFIG_FILE_NAME = "tsr.config.json";
|
|
5
|
-
async function readConfigFile(path) {
|
|
6
|
-
try {
|
|
7
|
-
const raw = await readFile(path, "utf-8");
|
|
8
|
-
return JSON.parse(raw);
|
|
9
|
-
} catch {
|
|
10
|
-
return {};
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
async function buildConfig(config, root) {
|
|
14
|
-
const fileConfig = await readConfigFile(join(root, CONFIG_FILE_NAME));
|
|
15
|
-
return configSchema.parse({
|
|
16
|
-
...fileConfig,
|
|
17
|
-
...config
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
4
|
function TanStackRouterVite(inlineConfig = {}) {
|
|
21
5
|
let ROOT;
|
|
22
6
|
let userConfig;
|
|
@@ -32,13 +16,13 @@ function TanStackRouterVite(inlineConfig = {}) {
|
|
|
32
16
|
name: "vite-plugin-tanstack-router",
|
|
33
17
|
configResolved: async (vite) => {
|
|
34
18
|
ROOT = vite.root;
|
|
35
|
-
userConfig = await
|
|
19
|
+
userConfig = await getConfig(inlineConfig, ROOT);
|
|
36
20
|
await generate();
|
|
37
21
|
},
|
|
38
22
|
handleHotUpdate: async ({ file }) => {
|
|
39
23
|
const filePath = normalize(file);
|
|
40
24
|
if (filePath === join(ROOT, CONFIG_FILE_NAME)) {
|
|
41
|
-
userConfig = await
|
|
25
|
+
userConfig = await getConfig(inlineConfig, ROOT);
|
|
42
26
|
return;
|
|
43
27
|
}
|
|
44
28
|
if (filePath.startsWith(join(ROOT, userConfig.routesDirectory))) {
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/index.ts"],"sourcesContent":["import { Plugin } from 'vite'\nimport { join, normalize } from 'path'\nimport { readFile } from 'fs/promises'\nimport {
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/index.ts"],"sourcesContent":["import { Plugin } from 'vite'\nimport { join, normalize } from 'path'\nimport { readFile } from 'fs/promises'\nimport { type Config, getConfig, generator } from '@tanstack/router-generator'\n\nconst CONFIG_FILE_NAME = 'tsr.config.json'\n\nexport function TanStackRouterVite(inlineConfig: Partial<Config> = {}): Plugin {\n let ROOT: string\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 return {\n name: 'vite-plugin-tanstack-router',\n configResolved: async (vite) => {\n ROOT = vite.root\n userConfig = await getConfig(inlineConfig, ROOT)\n await generate()\n },\n handleHotUpdate: async ({ file }) => {\n const filePath = normalize(file)\n if (filePath === join(ROOT, CONFIG_FILE_NAME)) {\n userConfig = await getConfig(inlineConfig, ROOT)\n return\n }\n if (filePath.startsWith(join(ROOT, userConfig.routesDirectory))) {\n await generate()\n }\n },\n }\n}\n"],"names":[],"mappings":";;AAKA,MAAM,mBAAmB;AAET,SAAA,mBAAmB,eAAgC,IAAY;AACzE,MAAA;AACA,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;AAGK,SAAA;AAAA,IACL,MAAM;AAAA,IACN,gBAAgB,OAAO,SAAS;AAC9B,aAAO,KAAK;AACC,mBAAA,MAAM,UAAU,cAAc,IAAI;AAC/C,YAAM,SAAS;AAAA,IACjB;AAAA,IACA,iBAAiB,OAAO,EAAE,WAAW;AAC7B,YAAA,WAAW,UAAU,IAAI;AAC/B,UAAI,aAAa,KAAK,MAAM,gBAAgB,GAAG;AAChC,qBAAA,MAAM,UAAU,cAAc,IAAI;AAC/C;AAAA,MACF;AACA,UAAI,SAAS,WAAW,KAAK,MAAM,WAAW,eAAe,CAAC,GAAG;AAC/D,cAAM,SAAS;AAAA,MACjB;AAAA,IACF;AAAA,EAAA;AAEJ;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/router-vite-plugin",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"src/**"
|
|
50
50
|
],
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@tanstack/router-generator": "1.
|
|
52
|
+
"@tanstack/router-generator": "1.10.0"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
|
55
55
|
"clean": "rimraf ./dist && rimraf ./coverage",
|
package/src/index.ts
CHANGED
|
@@ -1,34 +1,11 @@
|
|
|
1
1
|
import { Plugin } from 'vite'
|
|
2
2
|
import { join, normalize } from 'path'
|
|
3
3
|
import { readFile } from 'fs/promises'
|
|
4
|
-
import {
|
|
5
|
-
type Config,
|
|
6
|
-
configSchema,
|
|
7
|
-
generator,
|
|
8
|
-
} from '@tanstack/router-generator'
|
|
4
|
+
import { type Config, getConfig, generator } from '@tanstack/router-generator'
|
|
9
5
|
|
|
10
6
|
const CONFIG_FILE_NAME = 'tsr.config.json'
|
|
11
7
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
async function readConfigFile(path: string): Promise<UserConfig> {
|
|
15
|
-
try {
|
|
16
|
-
const raw = await readFile(path, 'utf-8')
|
|
17
|
-
return JSON.parse(raw) as UserConfig
|
|
18
|
-
} catch {
|
|
19
|
-
return {} as UserConfig
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
async function buildConfig(config: UserConfig, root: string): Promise<Config> {
|
|
24
|
-
const fileConfig = await readConfigFile(join(root, CONFIG_FILE_NAME))
|
|
25
|
-
return configSchema.parse({
|
|
26
|
-
...fileConfig,
|
|
27
|
-
...config,
|
|
28
|
-
})
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function TanStackRouterVite(inlineConfig: UserConfig = {}): Plugin {
|
|
8
|
+
export function TanStackRouterVite(inlineConfig: Partial<Config> = {}): Plugin {
|
|
32
9
|
let ROOT: string
|
|
33
10
|
let userConfig: Config
|
|
34
11
|
|
|
@@ -45,13 +22,13 @@ export function TanStackRouterVite(inlineConfig: UserConfig = {}): Plugin {
|
|
|
45
22
|
name: 'vite-plugin-tanstack-router',
|
|
46
23
|
configResolved: async (vite) => {
|
|
47
24
|
ROOT = vite.root
|
|
48
|
-
userConfig = await
|
|
25
|
+
userConfig = await getConfig(inlineConfig, ROOT)
|
|
49
26
|
await generate()
|
|
50
27
|
},
|
|
51
28
|
handleHotUpdate: async ({ file }) => {
|
|
52
29
|
const filePath = normalize(file)
|
|
53
30
|
if (filePath === join(ROOT, CONFIG_FILE_NAME)) {
|
|
54
|
-
userConfig = await
|
|
31
|
+
userConfig = await getConfig(inlineConfig, ROOT)
|
|
55
32
|
return
|
|
56
33
|
}
|
|
57
34
|
if (filePath.startsWith(join(ROOT, userConfig.routesDirectory))) {
|