ts-file-router 6.0.2 → 7.0.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/README.md CHANGED
@@ -6,10 +6,10 @@ A lightweight **filesystem router generator** for TypeScript projects. Automatic
6
6
 
7
7
  ## âœĻ Features
8
8
 
9
- - 🔍 **Automatic folder scanning** - Recursively scans your pages/screens directory
9
+ - 🔍 **Automatic folder scanning** - Automatically scans your configured directory to build a complete route tree manifest.
10
10
  - 📄 **Generated TypeScript routes** - Fully typed `routes.ts` file with `as const` assertions
11
11
  - ⚛ïļ **Framework agnostic** - Works with React.lazy, Vue, Solid, or any framework with dynamic imports
12
- - ðŸŠķ **Zero runtime dependencies** - Only used at build/dev time
12
+ - ðŸŠķ **Zero runtime dependencies** - The generated routes file is plain TypeScript/JavaScript; your final bundle won't include any extra library code.
13
13
  - 🔄 **File watcher support** - Auto-regenerate routes when files change (powered by Chokidar)
14
14
  - ðŸŽĻ **Biome formatting** - Output files are automatically formatted with Biome
15
15
  - ðŸ§Đ **Vite plugin** - Seamless integration with Vite dev server
@@ -43,10 +43,10 @@ Create a script to generate your routes:
43
43
 
44
44
  ```js
45
45
  // scripts/generate-routes.mjs
46
- import { generateRoutes } from 'ts-file-router';
46
+ import { generateFileRouter } from 'ts-file-router';
47
47
 
48
- generateRoutes({
49
- baseFolder: 'src/screens',
48
+ generateFileRouter({
49
+ baseFolder: './src/screens',
50
50
  outputFile: 'routes.ts',
51
51
  });
52
52
  ```
@@ -61,11 +61,11 @@ node scripts/generate-routes.mjs
61
61
 
62
62
  ```js
63
63
  // scripts/generate-routes.mjs
64
- import { generateRoutes } from 'ts-file-router';
64
+ import { generateFileRouter } from 'ts-file-router';
65
65
 
66
- generateRoutes({
67
- baseFolder: 'src/screens',
68
- outputFile: 'routes.ts',
66
+ generateFileRouter({
67
+ dir: './src/screens',
68
+ outputFilename: 'routes.ts',
69
69
  options: {
70
70
  watcher: {
71
71
  watch: true,
@@ -83,13 +83,13 @@ This will keep running and regenerate routes whenever you add, remove, or modify
83
83
  ```ts
84
84
  // vite.config.ts
85
85
  import { defineConfig } from 'vite';
86
- import { generateRoutesPlugin } from 'ts-file-router';
86
+ import { generateViteFileRouter } from 'ts-file-router';
87
87
 
88
88
  export default defineConfig({
89
89
  plugins: [
90
- generateRoutesPlugin({
91
- baseFolder: 'src/screens',
92
- outputFile: 'src/screens/routes.ts',
90
+ generateViteFileRouter({
91
+ dir: './src/screens',
92
+ outputFilename: 'routes.ts',
93
93
  // Optional: customize watcher behavior
94
94
  options: {
95
95
  watcher: { watch: true, debounce: 500 },
@@ -147,13 +147,13 @@ export const routes = {
147
147
 
148
148
  ## 🔧 Configuration Options
149
149
 
150
- ### `generateRoutes()` Parameters
150
+ ### `generateFileRouter()` Parameters
151
151
 
152
- | Parameter | Type | Required | Description |
153
- | ------------ | ------------------------ | -------- | ---------------------------------- |
154
- | `baseFolder` | `string` | ✅ Yes | Root directory to scan for routes |
155
- | `outputFile` | `string` | ✅ Yes | Path for the generated routes file |
156
- | `options` | `TGenerateRoutesOptions` | ❌ No | Additional configuration |
152
+ | Parameter | Type | Required | Description |
153
+ | ---------------- | ------------------------ | -------- | ---------------------------------- |
154
+ | `dir` | `string` | ✅ Yes | Root directory to scan for routes |
155
+ | `outputFilename` | `string` | ✅ Yes | Path for the generated routes file |
156
+ | `options` | `TGenerateRoutesOptions` | ❌ No | Additional configuration |
157
157
 
158
158
  ### Options Object
159
159
 
@@ -239,7 +239,6 @@ When using the watcher, routes regenerate on:
239
239
 
240
240
  - `add` - New file added
241
241
  - `addDir` - New directory added
242
- - `change` - File modified
243
242
  - `unlink` - File deleted
244
243
  - `unlinkDir` - Directory deleted
245
244
 
@@ -270,7 +269,7 @@ Both trigger proper watcher cleanup before exit.
270
269
  }
271
270
  ```
272
271
 
273
- 2. **Use relative paths in output**: The `outputFile` path is relative to `baseFolder`.
272
+ 2. **Use relative paths in output**: The `outputFilename` path is relative to `dir`.
274
273
 
275
274
  ---
276
275