@tanstack/router-cli 0.0.1-beta.29
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/bin/tsr.js +3 -0
- package/build/cjs/_virtual/_rollupPluginBabelHelpers.js +31 -0
- package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +1 -0
- package/build/cjs/config.js +29 -0
- package/build/cjs/config.js.map +1 -0
- package/build/cjs/generate.js +28 -0
- package/build/cjs/generate.js.map +1 -0
- package/build/cjs/generator.js +343 -0
- package/build/cjs/generator.js.map +1 -0
- package/build/cjs/index.js +51 -0
- package/build/cjs/index.js.map +1 -0
- package/build/cjs/transformCode.js +598 -0
- package/build/cjs/transformCode.js.map +1 -0
- package/build/cjs/watch.js +60 -0
- package/build/cjs/watch.js.map +1 -0
- package/build/esm/index.js +951 -0
- package/build/esm/index.js.map +1 -0
- package/build/types/index.d.ts +13 -0
- package/package.json +61 -0
- package/src/config.ts +15 -0
- package/src/generate.ts +12 -0
- package/src/generator.ts +509 -0
- package/src/index.ts +24 -0
- package/src/transformCode.ts +857 -0
- package/src/watch.ts +48 -0
package/src/watch.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import chokidar from 'chokidar'
|
|
2
|
+
import path from 'path'
|
|
3
|
+
import { getConfig } from './config'
|
|
4
|
+
import { generator } from './generator'
|
|
5
|
+
|
|
6
|
+
export async function watch() {
|
|
7
|
+
const configWatcher = chokidar.watch(
|
|
8
|
+
path.resolve(process.cwd(), 'tsr.config.js'),
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
let watcher = new chokidar.FSWatcher()
|
|
12
|
+
|
|
13
|
+
const generatorWatcher = async () => {
|
|
14
|
+
const config = await getConfig()
|
|
15
|
+
|
|
16
|
+
watcher.close()
|
|
17
|
+
|
|
18
|
+
console.log(`TSR: Watching routes (${config.routesDirectory})...`)
|
|
19
|
+
watcher = chokidar.watch(config.routesDirectory)
|
|
20
|
+
|
|
21
|
+
watcher.on('ready', async () => {
|
|
22
|
+
try {
|
|
23
|
+
await generator(config)
|
|
24
|
+
} catch (err) {
|
|
25
|
+
console.error(err)
|
|
26
|
+
console.log()
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const handle = async () => {
|
|
30
|
+
try {
|
|
31
|
+
await generator(config)
|
|
32
|
+
} catch (err) {
|
|
33
|
+
console.error(err)
|
|
34
|
+
console.log()
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
watcher.on('change', handle)
|
|
39
|
+
watcher.on('add', handle)
|
|
40
|
+
watcher.on('addDir', handle)
|
|
41
|
+
watcher.on('unlink', handle)
|
|
42
|
+
watcher.on('unlinkDir', handle)
|
|
43
|
+
})
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
configWatcher.on('ready', generatorWatcher)
|
|
47
|
+
configWatcher.on('change', generatorWatcher)
|
|
48
|
+
}
|