@tanstack/create 0.49.3 → 0.60.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/CHANGELOG.md +732 -0
- package/dist/add-ons.js +42 -2
- package/dist/add-to-app.js +36 -7
- package/dist/custom-add-ons/add-on.js +2 -26
- package/dist/custom-add-ons/starter.js +1 -2
- package/dist/file-helpers.js +11 -10
- package/dist/frameworks/react/add-ons/ai/info.json +1 -1
- package/dist/frameworks/react/add-ons/apollo-client/info.json +1 -1
- package/dist/frameworks/react/add-ons/better-auth/info.json +0 -2
- package/dist/frameworks/react/add-ons/clerk/info.json +0 -1
- package/dist/frameworks/react/add-ons/db/info.json +1 -1
- package/dist/frameworks/react/add-ons/drizzle/info.json +1 -1
- package/dist/frameworks/react/add-ons/drizzle/package.json.ejs +4 -0
- package/dist/frameworks/react/add-ons/mcp/info.json +1 -2
- package/dist/frameworks/react/add-ons/neon/assets/neon-vite-plugin.ts +1 -1
- package/dist/frameworks/react/add-ons/neon/info.json +1 -2
- package/dist/frameworks/react/add-ons/oRPC/info.json +1 -1
- package/dist/frameworks/react/add-ons/paraglide/info.json +1 -1
- package/dist/frameworks/react/add-ons/prisma/info.json +1 -1
- package/dist/frameworks/react/add-ons/prisma/package.json.ejs +4 -0
- package/dist/frameworks/react/add-ons/sentry/info.json +1 -2
- package/dist/frameworks/react/add-ons/tRPC/info.json +1 -1
- package/dist/frameworks/react/add-ons/tanstack-query/assets/src/integrations/tanstack-query/root-provider.tsx.ejs +1 -29
- package/dist/frameworks/react/add-ons/workos/info.json +0 -1
- package/dist/frameworks/react/hosts/cloudflare/info.json +0 -1
- package/dist/frameworks/react/hosts/netlify/info.json +0 -1
- package/dist/frameworks/react/hosts/nitro/info.json +0 -1
- package/dist/frameworks/react/hosts/railway/info.json +0 -1
- package/dist/frameworks/react/index.js +1 -6
- package/dist/frameworks/react/project/base/README.md.ejs +86 -436
- package/dist/frameworks/react/project/base/_dot_gitignore +4 -0
- package/dist/frameworks/react/project/base/package.json +8 -5
- package/dist/frameworks/react/project/base/src/components/Header.tsx.ejs +2 -32
- package/dist/frameworks/react/project/base/src/routes/__root.tsx.ejs +4 -44
- package/dist/frameworks/react/project/base/src/routes/index.tsx.ejs +99 -61
- package/dist/frameworks/react/project/base/src/styles.css.ejs +3 -3
- package/dist/frameworks/react/project/base/tsconfig.json.ejs +1 -1
- package/dist/frameworks/react/project/base/vite.config.ts.ejs +33 -27
- package/dist/frameworks/react/project/packages.json +2 -2
- package/dist/frameworks/solid/add-ons/better-auth/info.json +1 -1
- package/dist/frameworks/solid/hosts/cloudflare/info.json +0 -1
- package/dist/frameworks/solid/hosts/netlify/info.json +0 -1
- package/dist/frameworks/solid/hosts/nitro/info.json +0 -1
- package/dist/frameworks/solid/hosts/railway/info.json +0 -1
- package/dist/frameworks/solid/index.js +1 -6
- package/dist/frameworks/solid/project/base/README.md.ejs +43 -117
- package/dist/frameworks/solid/project/base/_dot_gitignore +4 -0
- package/dist/frameworks/solid/project/base/package.json +8 -3
- package/dist/frameworks/solid/project/base/src/components/Header.tsx.ejs +2 -25
- package/dist/frameworks/solid/project/base/src/routes/__root.tsx.ejs +3 -30
- package/dist/frameworks/solid/project/base/src/routes/index.tsx.ejs +97 -35
- package/dist/frameworks/solid/project/base/tsconfig.json.ejs +1 -1
- package/dist/frameworks/solid/project/base/vite.config.ts.ejs +15 -20
- package/dist/frameworks/solid/project/packages.json +2 -2
- package/dist/frameworks.js +0 -1
- package/dist/package-json.js +6 -10
- package/dist/template-file.js +21 -7
- package/dist/types/custom-add-ons/add-on.d.ts +1 -1
- package/dist/types/file-helpers.d.ts +0 -1
- package/dist/types/types.d.ts +12 -12
- package/dist/types.js +1 -2
- package/package.json +1 -1
- package/src/add-ons.ts +54 -2
- package/src/add-to-app.ts +42 -7
- package/src/custom-add-ons/add-on.ts +2 -33
- package/src/custom-add-ons/starter.ts +1 -2
- package/src/file-helpers.ts +11 -10
- package/src/frameworks/react/add-ons/ai/info.json +1 -1
- package/src/frameworks/react/add-ons/apollo-client/info.json +1 -1
- package/src/frameworks/react/add-ons/better-auth/info.json +0 -2
- package/src/frameworks/react/add-ons/clerk/info.json +0 -1
- package/src/frameworks/react/add-ons/db/info.json +1 -1
- package/src/frameworks/react/add-ons/drizzle/info.json +1 -1
- package/src/frameworks/react/add-ons/drizzle/package.json.ejs +4 -0
- package/src/frameworks/react/add-ons/mcp/info.json +1 -2
- package/src/frameworks/react/add-ons/neon/assets/neon-vite-plugin.ts +1 -1
- package/src/frameworks/react/add-ons/neon/info.json +1 -2
- package/src/frameworks/react/add-ons/oRPC/info.json +1 -1
- package/src/frameworks/react/add-ons/paraglide/info.json +1 -1
- package/src/frameworks/react/add-ons/prisma/info.json +1 -1
- package/src/frameworks/react/add-ons/prisma/package.json.ejs +4 -0
- package/src/frameworks/react/add-ons/sentry/info.json +1 -2
- package/src/frameworks/react/add-ons/tRPC/info.json +1 -1
- package/src/frameworks/react/add-ons/tanstack-query/assets/src/integrations/tanstack-query/root-provider.tsx.ejs +1 -29
- package/src/frameworks/react/add-ons/workos/info.json +0 -1
- package/src/frameworks/react/hosts/cloudflare/info.json +0 -1
- package/src/frameworks/react/hosts/netlify/info.json +0 -1
- package/src/frameworks/react/hosts/nitro/info.json +0 -1
- package/src/frameworks/react/hosts/railway/info.json +0 -1
- package/src/frameworks/react/index.ts +1 -6
- package/src/frameworks/react/project/base/README.md.ejs +86 -436
- package/src/frameworks/react/project/base/_dot_gitignore +4 -0
- package/src/frameworks/react/project/base/package.json +8 -5
- package/src/frameworks/react/project/base/src/components/Header.tsx.ejs +2 -32
- package/src/frameworks/react/project/base/src/routes/__root.tsx.ejs +4 -44
- package/src/frameworks/react/project/base/src/routes/index.tsx.ejs +99 -61
- package/src/frameworks/react/project/base/src/styles.css.ejs +3 -3
- package/src/frameworks/react/project/base/tsconfig.json.ejs +1 -1
- package/src/frameworks/react/project/base/vite.config.ts.ejs +33 -27
- package/src/frameworks/react/project/packages.json +2 -2
- package/src/frameworks/solid/add-ons/better-auth/info.json +1 -1
- package/src/frameworks/solid/hosts/cloudflare/info.json +0 -1
- package/src/frameworks/solid/hosts/netlify/info.json +0 -1
- package/src/frameworks/solid/hosts/nitro/info.json +0 -1
- package/src/frameworks/solid/hosts/railway/info.json +0 -1
- package/src/frameworks/solid/index.ts +1 -6
- package/src/frameworks/solid/project/base/README.md.ejs +43 -117
- package/src/frameworks/solid/project/base/_dot_gitignore +4 -0
- package/src/frameworks/solid/project/base/package.json +8 -3
- package/src/frameworks/solid/project/base/src/components/Header.tsx.ejs +2 -25
- package/src/frameworks/solid/project/base/src/routes/__root.tsx.ejs +3 -30
- package/src/frameworks/solid/project/base/src/routes/index.tsx.ejs +97 -35
- package/src/frameworks/solid/project/base/tsconfig.json.ejs +1 -1
- package/src/frameworks/solid/project/base/vite.config.ts.ejs +15 -20
- package/src/frameworks/solid/project/packages.json +2 -2
- package/src/frameworks.ts +0 -1
- package/src/package-json.ts +6 -10
- package/src/template-file.ts +27 -8
- package/src/types.ts +1 -2
- package/tests/add-to-app.test.ts +37 -0
- package/tests/file-helper.test.ts +23 -2
- package/tests/package-json.test.ts +32 -0
- package/tests/template-file.test.ts +28 -0
- package/dist/frameworks/react/add-ons/module-federation/assets/module-federation.config.js.ejs +0 -31
- package/dist/frameworks/react/add-ons/module-federation/assets/src/demo-mf-component.tsx +0 -3
- package/dist/frameworks/react/add-ons/module-federation/assets/src/demo-mf-self-contained.tsx +0 -11
- package/dist/frameworks/react/add-ons/module-federation/info.json +0 -11
- package/dist/frameworks/react/add-ons/module-federation/package.json +0 -5
- package/dist/frameworks/react/add-ons/module-federation/small-logo.svg +0 -87
- package/dist/frameworks/react/add-ons/start/assets/_dot_gitignore.append +0 -3
- package/dist/frameworks/react/add-ons/start/assets/src/data/demo.punk-songs.ts +0 -13
- package/dist/frameworks/react/add-ons/start/assets/src/router.tsx.ejs +0 -77
- package/dist/frameworks/react/add-ons/start/assets/src/routes/demo/api.names.ts +0 -10
- package/dist/frameworks/react/add-ons/start/assets/src/routes/demo/api.tq-todos.ts.ejs +0 -35
- package/dist/frameworks/react/add-ons/start/assets/src/routes/demo/start.api-request.tsx.ejs +0 -68
- package/dist/frameworks/react/add-ons/start/assets/src/routes/demo/start.css.ejs +0 -43
- package/dist/frameworks/react/add-ons/start/assets/src/routes/demo/start.server-funcs.tsx.ejs +0 -183
- package/dist/frameworks/react/add-ons/start/assets/src/routes/demo/start.ssr.data-only.tsx.ejs +0 -55
- package/dist/frameworks/react/add-ons/start/assets/src/routes/demo/start.ssr.full-ssr.tsx.ejs +0 -55
- package/dist/frameworks/react/add-ons/start/assets/src/routes/demo/start.ssr.index.tsx.ejs +0 -62
- package/dist/frameworks/react/add-ons/start/assets/src/routes/demo/start.ssr.spa-mode.tsx.ejs +0 -62
- package/dist/frameworks/react/add-ons/start/assets/src/routes/index.tsx.ejs +0 -142
- package/dist/frameworks/react/add-ons/start/assets/src/server.ts.ejs +0 -9
- package/dist/frameworks/react/add-ons/start/assets/vite.config.ts.ejs +0 -40
- package/dist/frameworks/react/add-ons/start/info.json +0 -61
- package/dist/frameworks/react/add-ons/start/package.json +0 -12
- package/dist/frameworks/react/add-ons/start/small-logo.svg +0 -1
- package/dist/frameworks/react/project/base/index.html.ejs +0 -20
- package/dist/frameworks/react/project/base/src/App.css.ejs +0 -38
- package/dist/frameworks/react/project/base/src/App.tsx.ejs +0 -63
- package/dist/frameworks/react/project/base/src/components/Header.css.ejs +0 -18
- package/dist/frameworks/react/project/base/src/logo.svg +0 -12
- package/dist/frameworks/react/project/base/src/main.tsx.ejs +0 -166
- package/dist/frameworks/react/project/base/src/reportWebVitals.ts.ejs +0 -28
- package/dist/frameworks/solid/add-ons/module-federation/assets/module-federation.config.js.ejs +0 -27
- package/dist/frameworks/solid/add-ons/module-federation/assets/src/demo-mf-component.tsx +0 -3
- package/dist/frameworks/solid/add-ons/module-federation/assets/src/demo-mf-self-contained.tsx +0 -9
- package/dist/frameworks/solid/add-ons/module-federation/info.json +0 -10
- package/dist/frameworks/solid/add-ons/module-federation/package.json +0 -5
- package/dist/frameworks/solid/add-ons/module-federation/small-logo.svg +0 -87
- package/dist/frameworks/solid/add-ons/start/assets/public/tanstack-circle-logo.png +0 -0
- package/dist/frameworks/solid/add-ons/start/assets/public/tanstack-word-logo-white.svg +0 -1
- package/dist/frameworks/solid/add-ons/start/assets/src/router.tsx.ejs +0 -30
- package/dist/frameworks/solid/add-ons/start/assets/src/routes/demo.start.server-funcs.tsx +0 -49
- package/dist/frameworks/solid/add-ons/start/assets/src/routes/index.tsx.ejs +0 -138
- package/dist/frameworks/solid/add-ons/start/assets/vite.config.ts.ejs +0 -22
- package/dist/frameworks/solid/add-ons/start/info.json +0 -18
- package/dist/frameworks/solid/add-ons/start/package.json +0 -15
- package/dist/frameworks/solid/add-ons/start/small-logo.svg +0 -1
- package/dist/frameworks/solid/project/base/index.html.ejs +0 -20
- package/dist/frameworks/solid/project/base/src/App.css.ejs +0 -38
- package/dist/frameworks/solid/project/base/src/App.tsx.ejs +0 -34
- package/dist/frameworks/solid/project/base/src/logo.svg +0 -120
- package/dist/frameworks/solid/project/base/src/main.tsx.ejs +0 -126
- package/src/frameworks/react/add-ons/module-federation/assets/module-federation.config.js.ejs +0 -31
- package/src/frameworks/react/add-ons/module-federation/assets/src/demo-mf-component.tsx +0 -3
- package/src/frameworks/react/add-ons/module-federation/assets/src/demo-mf-self-contained.tsx +0 -11
- package/src/frameworks/react/add-ons/module-federation/info.json +0 -11
- package/src/frameworks/react/add-ons/module-federation/package.json +0 -5
- package/src/frameworks/react/add-ons/module-federation/small-logo.svg +0 -87
- package/src/frameworks/react/add-ons/start/assets/_dot_gitignore.append +0 -3
- package/src/frameworks/react/add-ons/start/assets/src/data/demo.punk-songs.ts +0 -13
- package/src/frameworks/react/add-ons/start/assets/src/router.tsx.ejs +0 -77
- package/src/frameworks/react/add-ons/start/assets/src/routes/demo/api.names.ts +0 -10
- package/src/frameworks/react/add-ons/start/assets/src/routes/demo/api.tq-todos.ts.ejs +0 -35
- package/src/frameworks/react/add-ons/start/assets/src/routes/demo/start.api-request.tsx.ejs +0 -68
- package/src/frameworks/react/add-ons/start/assets/src/routes/demo/start.css.ejs +0 -43
- package/src/frameworks/react/add-ons/start/assets/src/routes/demo/start.server-funcs.tsx.ejs +0 -183
- package/src/frameworks/react/add-ons/start/assets/src/routes/demo/start.ssr.data-only.tsx.ejs +0 -55
- package/src/frameworks/react/add-ons/start/assets/src/routes/demo/start.ssr.full-ssr.tsx.ejs +0 -55
- package/src/frameworks/react/add-ons/start/assets/src/routes/demo/start.ssr.index.tsx.ejs +0 -62
- package/src/frameworks/react/add-ons/start/assets/src/routes/demo/start.ssr.spa-mode.tsx.ejs +0 -62
- package/src/frameworks/react/add-ons/start/assets/src/routes/index.tsx.ejs +0 -142
- package/src/frameworks/react/add-ons/start/assets/src/server.ts.ejs +0 -9
- package/src/frameworks/react/add-ons/start/assets/vite.config.ts.ejs +0 -40
- package/src/frameworks/react/add-ons/start/info.json +0 -61
- package/src/frameworks/react/add-ons/start/package.json +0 -12
- package/src/frameworks/react/add-ons/start/small-logo.svg +0 -1
- package/src/frameworks/react/project/base/index.html.ejs +0 -20
- package/src/frameworks/react/project/base/src/App.css.ejs +0 -38
- package/src/frameworks/react/project/base/src/App.tsx.ejs +0 -63
- package/src/frameworks/react/project/base/src/components/Header.css.ejs +0 -18
- package/src/frameworks/react/project/base/src/logo.svg +0 -12
- package/src/frameworks/react/project/base/src/main.tsx.ejs +0 -166
- package/src/frameworks/react/project/base/src/reportWebVitals.ts.ejs +0 -28
- package/src/frameworks/solid/add-ons/module-federation/assets/module-federation.config.js.ejs +0 -27
- package/src/frameworks/solid/add-ons/module-federation/assets/src/demo-mf-component.tsx +0 -3
- package/src/frameworks/solid/add-ons/module-federation/assets/src/demo-mf-self-contained.tsx +0 -9
- package/src/frameworks/solid/add-ons/module-federation/info.json +0 -10
- package/src/frameworks/solid/add-ons/module-federation/package.json +0 -5
- package/src/frameworks/solid/add-ons/module-federation/small-logo.svg +0 -87
- package/src/frameworks/solid/add-ons/start/assets/public/tanstack-circle-logo.png +0 -0
- package/src/frameworks/solid/add-ons/start/assets/public/tanstack-word-logo-white.svg +0 -1
- package/src/frameworks/solid/add-ons/start/assets/src/router.tsx.ejs +0 -30
- package/src/frameworks/solid/add-ons/start/assets/src/routes/demo.start.server-funcs.tsx +0 -49
- package/src/frameworks/solid/add-ons/start/assets/src/routes/index.tsx.ejs +0 -138
- package/src/frameworks/solid/add-ons/start/assets/vite.config.ts.ejs +0 -22
- package/src/frameworks/solid/add-ons/start/info.json +0 -18
- package/src/frameworks/solid/add-ons/start/package.json +0 -15
- package/src/frameworks/solid/add-ons/start/small-logo.svg +0 -1
- package/src/frameworks/solid/project/base/index.html.ejs +0 -20
- package/src/frameworks/solid/project/base/src/App.css.ejs +0 -38
- package/src/frameworks/solid/project/base/src/App.tsx.ejs +0 -34
- package/src/frameworks/solid/project/base/src/logo.svg +0 -120
- package/src/frameworks/solid/project/base/src/main.tsx.ejs +0 -126
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Welcome to your new TanStack app!
|
|
1
|
+
Welcome to your new TanStack Start app!
|
|
2
2
|
|
|
3
3
|
# Getting Started
|
|
4
4
|
|
|
@@ -21,53 +21,29 @@ To build this application for production:
|
|
|
21
21
|
|
|
22
22
|
This project uses [Tailwind CSS](https://tailwindcss.com/) for styling.
|
|
23
23
|
|
|
24
|
+
### Removing Tailwind CSS
|
|
25
|
+
|
|
26
|
+
If you prefer not to use Tailwind CSS:
|
|
27
|
+
|
|
28
|
+
1. Remove the demo pages in `src/routes/demo/`
|
|
29
|
+
2. Replace the Tailwind import in `src/styles.css` with your own styles
|
|
30
|
+
3. Remove `tailwindcss()` from the plugins array in `vite.config.ts`
|
|
31
|
+
4. Uninstall the packages: `<%= getPackageManagerAddScript('@tailwindcss/vite tailwindcss', true) %>`
|
|
32
|
+
|
|
24
33
|
<% for(const addon of addOns.filter(addon => addon.readme)) { %>
|
|
25
34
|
<%- addon.readme %>
|
|
26
35
|
<% } %>
|
|
27
36
|
|
|
28
37
|
## Routing
|
|
29
|
-
<% if (fileRouter) { %>This project uses [TanStack Router](https://tanstack.com/router). The initial setup is a file based router. Which means that the routes are managed as files in `src/routes`.<% } else { %>This project uses [TanStack Router](https://tanstack.com/router). The initial setup is a code based router. Which means that the routes are defined in code (in the `./src/main.<%= jsx %>` file). If you like you can also use a file based routing setup by following the [File Based Routing](https://tanstack.com/router/latest/docs/framework/solid/guide/file-based-routing) guide.<% } %>
|
|
30
|
-
|
|
31
|
-
### Adding A Route
|
|
32
|
-
<% if (fileRouter) { %>
|
|
33
|
-
To add a new route to your application just add another a new file in the `./src/routes` directory.
|
|
34
|
-
|
|
35
|
-
TanStack will automatically generate the content of the route file for you.
|
|
36
|
-
<% } else { %>
|
|
37
|
-
To add a new route to your application just add another `createRoute` call to the `./src/main.<%= jsx %>` file. The example below adds a new `/about`route to the root route.
|
|
38
|
-
|
|
39
|
-
```tsx
|
|
40
|
-
const aboutRoute = createRoute({
|
|
41
|
-
getParentRoute: () => rootRoute,
|
|
42
|
-
path: "/about",
|
|
43
|
-
component: () => <h1>About</h1>,
|
|
44
|
-
});
|
|
45
|
-
```
|
|
46
38
|
|
|
47
|
-
|
|
39
|
+
This project uses [TanStack Router](https://tanstack.com/router) with file-based routing. Routes are managed as files in `src/routes`.
|
|
48
40
|
|
|
49
|
-
|
|
50
|
-
const routeTree = rootRoute.addChildren([indexRoute, aboutRoute]);
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
With this set up you should be able to navigate to `/about` and see the about page.
|
|
54
|
-
|
|
55
|
-
Of course you don't need to implement the About page in the `main.<%= jsx %>` file. You can create that component in another file and import it into the `main.<%= jsx %>` file, then use it in the `component` property of the `createRoute` call, like so:
|
|
56
|
-
|
|
57
|
-
```tsx
|
|
58
|
-
import About from "./components/About.<%= jsx %>";
|
|
41
|
+
### Adding A Route
|
|
59
42
|
|
|
60
|
-
|
|
61
|
-
getParentRoute: () => rootRoute,
|
|
62
|
-
path: "/about",
|
|
63
|
-
component: About,
|
|
64
|
-
});
|
|
65
|
-
```
|
|
43
|
+
To add a new route to your application just add a new file in the `./src/routes` directory.
|
|
66
44
|
|
|
67
|
-
|
|
45
|
+
TanStack will automatically generate the content of the route file for you.
|
|
68
46
|
|
|
69
|
-
For more information on the options you have when you are creating code based routes check out the [Code Based Routing](https://tanstack.com/router/latest/docs/framework/solid/guide/code-based-routing) documentation.
|
|
70
|
-
<% } %>
|
|
71
47
|
Now that you have two routes you can use a `Link` component to navigate between them.
|
|
72
48
|
|
|
73
49
|
### Adding Links
|
|
@@ -90,71 +66,23 @@ More information on the `Link` component can be found in the [Link documentation
|
|
|
90
66
|
|
|
91
67
|
### Using A Layout
|
|
92
68
|
|
|
93
|
-
|
|
94
|
-
Layouts can be used to wrap the contents of the routes in menus, headers, footers, etc.
|
|
95
|
-
|
|
96
|
-
There is already a layout in the `src/main.<%= jsx %>` file:
|
|
97
|
-
|
|
98
|
-
```tsx
|
|
99
|
-
const rootRoute = createRootRoute({
|
|
100
|
-
component: () => (
|
|
101
|
-
<>
|
|
102
|
-
<Outlet />
|
|
103
|
-
<TanStackRouterDevtools />
|
|
104
|
-
</>
|
|
105
|
-
),
|
|
106
|
-
});
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
You can use the Soliid component specified in the `component` property of the `rootRoute` to wrap the contents of the routes. The `<Outlet />` component is used to render the current route within the body of the layout. For example you could add a header to the layout like so:
|
|
69
|
+
In the File Based Routing setup the layout is located in `src/routes/__root.tsx`. Anything you add to the root route will appear in all the routes.
|
|
110
70
|
|
|
111
|
-
|
|
112
|
-
import { Link } from "@tanstack/solid-router";
|
|
71
|
+
More information on layouts can be found in the [Layouts documentation](https://tanstack.com/router/latest/docs/framework/solid/guide/routing-concepts#layouts).
|
|
113
72
|
|
|
114
|
-
|
|
115
|
-
component: () => (
|
|
116
|
-
<>
|
|
117
|
-
<header>
|
|
118
|
-
<nav>
|
|
119
|
-
<Link to="/">Home</Link>
|
|
120
|
-
<Link to="/about">About</Link>
|
|
121
|
-
</nav>
|
|
122
|
-
</header>
|
|
123
|
-
<Outlet />
|
|
124
|
-
<TanStackRouterDevtools />
|
|
125
|
-
</>
|
|
126
|
-
),
|
|
127
|
-
});
|
|
128
|
-
```
|
|
129
|
-
<% } else { %>In the File Based Routing setup the layout is located in `src/routes/__root.tsx`. Anything you add to the root route will appear in all the routes. The route content will appear in the JSX where you use the `<Outlet />` component.
|
|
73
|
+
## Server Functions
|
|
130
74
|
|
|
131
|
-
|
|
75
|
+
TanStack Start provides server functions that allow you to write server-side code that seamlessly integrates with your client components.
|
|
132
76
|
|
|
133
77
|
```tsx
|
|
134
|
-
import {
|
|
135
|
-
import { TanStackRouterDevtools } from '@tanstack/solid-router-devtools'
|
|
78
|
+
import { createServerFn } from '@tanstack/solid-start'
|
|
136
79
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
<>
|
|
142
|
-
<header>
|
|
143
|
-
<nav>
|
|
144
|
-
<Link to="/">Home</Link>
|
|
145
|
-
<Link to="/about">About</Link>
|
|
146
|
-
</nav>
|
|
147
|
-
</header>
|
|
148
|
-
<Outlet />
|
|
149
|
-
<TanStackRouterDevtools />
|
|
150
|
-
</>
|
|
151
|
-
),
|
|
80
|
+
const getServerTime = createServerFn({
|
|
81
|
+
method: 'GET',
|
|
82
|
+
}).handler(async () => {
|
|
83
|
+
return new Date().toISOString()
|
|
152
84
|
})
|
|
153
85
|
```
|
|
154
|
-
<% } %>
|
|
155
|
-
The `<TanStackRouterDevtools />` component is not required so you can remove it if you don't want it in your layout.
|
|
156
|
-
|
|
157
|
-
More information on layouts can be found in the [Layouts documentation](https://tanstack.com/router/latest/docs/framework/solid/guide/routing-concepts#layouts).
|
|
158
86
|
|
|
159
87
|
## Data Fetching
|
|
160
88
|
|
|
@@ -163,30 +91,26 @@ There are multiple ways to fetch data in your application. You can use TanStack
|
|
|
163
91
|
For example:
|
|
164
92
|
|
|
165
93
|
```tsx
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
94
|
+
import { createFileRoute } from '@tanstack/solid-router'
|
|
95
|
+
|
|
96
|
+
export const Route = createFileRoute('/people')({
|
|
169
97
|
loader: async () => {
|
|
170
|
-
const response = await fetch(
|
|
171
|
-
return response.json()
|
|
172
|
-
results: {
|
|
173
|
-
name: string;
|
|
174
|
-
}[];
|
|
175
|
-
}>;
|
|
176
|
-
<% } else { %>
|
|
177
|
-
return response.json();
|
|
178
|
-
<% } %> },
|
|
179
|
-
component: () => {
|
|
180
|
-
const data = peopleRoute.useLoaderData();
|
|
181
|
-
return (
|
|
182
|
-
<ul>
|
|
183
|
-
{data.results.map((person) => (
|
|
184
|
-
<li key={person.name}>{person.name}</li>
|
|
185
|
-
))}
|
|
186
|
-
</ul>
|
|
187
|
-
);
|
|
98
|
+
const response = await fetch('https://swapi.dev/api/people')
|
|
99
|
+
return response.json()
|
|
188
100
|
},
|
|
189
|
-
|
|
101
|
+
component: PeopleComponent,
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
function PeopleComponent() {
|
|
105
|
+
const data = Route.useLoaderData()
|
|
106
|
+
return (
|
|
107
|
+
<ul>
|
|
108
|
+
<For each={data().results}>
|
|
109
|
+
{(person) => <li>{person.name}</li>}
|
|
110
|
+
</For>
|
|
111
|
+
</ul>
|
|
112
|
+
)
|
|
113
|
+
}
|
|
190
114
|
```
|
|
191
115
|
|
|
192
116
|
Loaders simplify your data fetching logic dramatically. Check out more information in the [Loader documentation](https://tanstack.com/router/latest/docs/framework/solid/guide/data-loading#loader-parameters).
|
|
@@ -213,3 +137,5 @@ This project uses [eslint](https://eslint.org/) and [prettier](https://prettier.
|
|
|
213
137
|
# Learn More
|
|
214
138
|
|
|
215
139
|
You can learn more about all of the offerings from TanStack in the [TanStack documentation](https://tanstack.com).
|
|
140
|
+
|
|
141
|
+
For TanStack Start specific documentation, visit [TanStack Start](https://tanstack.com/start).
|
|
@@ -3,19 +3,24 @@
|
|
|
3
3
|
"private": true,
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"dev": "vite --port 3000",
|
|
7
|
-
"build": "vite build
|
|
6
|
+
"dev": "vite dev --port 3000",
|
|
7
|
+
"build": "vite build",
|
|
8
|
+
"start": "node .output/server/index.mjs",
|
|
8
9
|
"preview": "vite preview",
|
|
9
10
|
"test": "vitest run"
|
|
10
11
|
},
|
|
11
12
|
"dependencies": {
|
|
12
13
|
"@tanstack/solid-router": "^1.133.20",
|
|
13
14
|
"@tanstack/solid-router-devtools": "^1.133.20",
|
|
15
|
+
"@tanstack/solid-router-ssr-query": "^1.132.25",
|
|
14
16
|
"@tanstack/solid-start": "^1.133.20",
|
|
15
|
-
"solid
|
|
17
|
+
"lucide-solid": "^0.544.0",
|
|
18
|
+
"solid-js": "^1.9.9",
|
|
19
|
+
"vite-tsconfig-paths": "^5.1.4"
|
|
16
20
|
},
|
|
17
21
|
"devDependencies": {
|
|
18
22
|
"@tanstack/devtools-vite": "^0.3.11",
|
|
23
|
+
"vite-plugin-lucide-preprocess": "^1.4.6",
|
|
19
24
|
"vite-plugin-solid": "^2.11.10",
|
|
20
25
|
"typescript": "^5.7.2",
|
|
21
26
|
"vite": "^7.1.7"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<% if (addOns.length === 0 && integrations.length === 0 && routes.length === 0) { ignoreFile() } %>import { Link } from '@tanstack/solid-router'
|
|
2
2
|
<% for(const integration of integrations.filter(i => i.type === 'header-user')) { %>
|
|
3
3
|
import <%= integration.jsName %> from "<%= relativePath(integration.path) %>";
|
|
4
|
-
<% } %><%
|
|
4
|
+
<% } %><%
|
|
5
5
|
const icons = new Set([
|
|
6
6
|
"Menu",
|
|
7
7
|
"X",
|
|
@@ -23,10 +23,9 @@ import { createSignal } from 'solid-js';
|
|
|
23
23
|
import {
|
|
24
24
|
<%= Array.from(icons).sort().join(", ") %>
|
|
25
25
|
} from "lucide-solid";
|
|
26
|
-
<% } %>
|
|
27
26
|
|
|
28
27
|
export default function Header() {
|
|
29
|
-
<%
|
|
28
|
+
<%
|
|
30
29
|
const menusWithChildren = addOns.filter(a => a.routes?.some(r => r.children));
|
|
31
30
|
const userHeaders = integrations.filter(i => i.type === 'header-user');
|
|
32
31
|
%>
|
|
@@ -151,26 +150,4 @@ const userHeaders = integrations.filter(i => i.type === 'header-user');
|
|
|
151
150
|
</aside>
|
|
152
151
|
</>
|
|
153
152
|
);
|
|
154
|
-
<% } else { %>
|
|
155
|
-
return (
|
|
156
|
-
<header class="p-2 flex gap-2 bg-white text-black justify-between">
|
|
157
|
-
<nav class="flex flex-row">
|
|
158
|
-
<div class="px-2 font-bold">
|
|
159
|
-
<Link to="/">Home</Link>
|
|
160
|
-
</div>
|
|
161
|
-
<% for(const addOn of addOns) {
|
|
162
|
-
for(const route of (addOn?.routes||[])?.filter(r => r.url && r.name)) { %>
|
|
163
|
-
<div class="px-2 font-bold"><Link to="<%= route.url %>"><%= route.name %></Link></div>
|
|
164
|
-
<% } } %>
|
|
165
|
-
</nav>
|
|
166
|
-
<% if (integrations.filter(i => i.type === 'header-user').length > 0) { %>
|
|
167
|
-
<div>
|
|
168
|
-
<% for(const integration of integrations.filter(i => i.type === 'header-user')) { %>
|
|
169
|
-
<<%= integration.jsName %> />
|
|
170
|
-
<% } %>
|
|
171
|
-
</div>
|
|
172
|
-
<% } %>
|
|
173
|
-
</header>
|
|
174
|
-
)
|
|
175
|
-
<% } %>
|
|
176
153
|
}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import { HeadContent, Outlet, Scripts, createRootRouteWithContext } from '@tanstack/solid-router'
|
|
2
2
|
import { TanStackRouterDevtools } from '@tanstack/solid-router-devtools'
|
|
3
3
|
|
|
4
4
|
<% if (addOnEnabled['solid-ui']) { %>
|
|
5
5
|
import "@fontsource/inter"
|
|
6
6
|
<% } %>
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import { Suspense } from 'solid-js'
|
|
11
|
-
<% } %>
|
|
8
|
+
import { HydrationScript } from 'solid-js/web'
|
|
9
|
+
import { Suspense } from 'solid-js'
|
|
12
10
|
|
|
13
11
|
<% if (addOns.length || integrations.length || routes.length) { %>import Header from '../components/Header'
|
|
14
12
|
<% } %>
|
|
@@ -26,7 +24,6 @@ export const Route = createRootRouteWithContext()({
|
|
|
26
24
|
shellComponent: RootComponent,
|
|
27
25
|
})
|
|
28
26
|
|
|
29
|
-
<% if (addOnEnabled.start) { %>
|
|
30
27
|
function RootComponent() {
|
|
31
28
|
return (
|
|
32
29
|
<html>
|
|
@@ -50,27 +47,3 @@ function RootComponent() {
|
|
|
50
47
|
</html>
|
|
51
48
|
);
|
|
52
49
|
}
|
|
53
|
-
<% } else { %>
|
|
54
|
-
function RootComponent() {
|
|
55
|
-
return (
|
|
56
|
-
<>
|
|
57
|
-
<% for(const integration of integrations.filter(i => i.type === 'provider')) { %>
|
|
58
|
-
<<%= integration.jsName %>>
|
|
59
|
-
<% } %>
|
|
60
|
-
<HeadContent />
|
|
61
|
-
<% if (addOns.length || integrations.length || routes.length) { %>
|
|
62
|
-
<Header />
|
|
63
|
-
<% } %>
|
|
64
|
-
<Outlet />
|
|
65
|
-
<TanStackRouterDevtools />
|
|
66
|
-
<% for(const integration of integrations.filter(i => i.type === 'layout')) { %>
|
|
67
|
-
<<%= integration.jsName %> />
|
|
68
|
-
<% } %>
|
|
69
|
-
<% for(const integration of integrations.filter(i => i.type === 'provider').reverse()) { %>
|
|
70
|
-
</<%= integration.jsName %>>
|
|
71
|
-
<% } %>
|
|
72
|
-
<Scripts />
|
|
73
|
-
</>
|
|
74
|
-
)
|
|
75
|
-
}
|
|
76
|
-
<% } %>
|
|
@@ -1,41 +1,103 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
1
|
+
import { createFileRoute } from "@tanstack/solid-router";
|
|
2
|
+
import { For } from "solid-js"
|
|
3
|
+
import {
|
|
4
|
+
Zap, Server, Route as RouteIcon, Shield, Waves, Sparkles,
|
|
5
|
+
} from "lucide-solid";
|
|
3
6
|
|
|
4
|
-
|
|
7
|
+
export const Route = createFileRoute("/")({ component: App });
|
|
5
8
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
function App() {
|
|
10
|
+
const features = [
|
|
11
|
+
{
|
|
12
|
+
icon: <Zap class="w-12 h-12 text-cyan-400" />,
|
|
13
|
+
title: "Powerful Server Functions",
|
|
14
|
+
description: "Write server-side code that seamlessly integrates with your client components. Type-safe, secure, and simple.",
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
icon: <Server class="w-12 h-12 text-cyan-400" />,
|
|
18
|
+
title: "Flexible Server Side Rendering",
|
|
19
|
+
description: "Full-document SSR, streaming, and progressive enhancement out of the box. Control exactly what renders where.",
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
icon: <RouteIcon class="w-12 h-12 text-cyan-400" />,
|
|
23
|
+
title: "API Routes",
|
|
24
|
+
description: "Build type-safe API endpoints alongside your application. No separate backend needed.",
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
icon: <Shield class="w-12 h-12 text-cyan-400" />,
|
|
28
|
+
title: "Strongly Typed Everything",
|
|
29
|
+
description: "End-to-end type safety from server to client. Catch errors before they reach production.",
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
icon: <Waves class="w-12 h-12 text-cyan-400" />,
|
|
33
|
+
title: "Full Streaming Support",
|
|
34
|
+
description: "Stream data from server to client progressively. Perfect for AI applications and real-time updates.",
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
icon: <Sparkles class="w-12 h-12 text-cyan-400" />,
|
|
38
|
+
title: "Next Generation Ready",
|
|
39
|
+
description: "Built from the ground up for modern web applications. Deploy anywhere JavaScript runs.",
|
|
40
|
+
},
|
|
41
|
+
];
|
|
9
42
|
|
|
10
|
-
function IndexComponent() {
|
|
11
43
|
return (
|
|
12
|
-
<div class="
|
|
13
|
-
<
|
|
14
|
-
<
|
|
15
|
-
|
|
16
|
-
class="
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
44
|
+
<div class="min-h-screen bg-gradient-to-b from-slate-900 via-slate-800 to-slate-900">
|
|
45
|
+
<section class="relative py-20 px-6 text-center overflow-hidden">
|
|
46
|
+
<div class="absolute inset-0 bg-gradient-to-r from-cyan-500/10 via-blue-500/10 to-purple-500/10"></div>
|
|
47
|
+
<div class="relative max-w-5xl mx-auto">
|
|
48
|
+
<div class="flex items-center justify-center gap-6 mb-6">
|
|
49
|
+
<img
|
|
50
|
+
src="/tanstack-circle-logo.png"
|
|
51
|
+
alt="TanStack Logo"
|
|
52
|
+
class="w-24 h-24 md:w-32 md:h-32"
|
|
53
|
+
/>
|
|
54
|
+
<h1 class="text-6xl md:text-7xl font-black text-white [letter-spacing:-0.08em]">
|
|
55
|
+
<span class="text-gray-300">TANSTACK</span>{" "}
|
|
56
|
+
<span class="bg-gradient-to-r from-cyan-400 to-blue-400 bg-clip-text text-transparent">
|
|
57
|
+
START
|
|
58
|
+
</span>
|
|
59
|
+
</h1>
|
|
60
|
+
</div>
|
|
61
|
+
<p class="text-2xl md:text-3xl text-gray-300 mb-4 font-light">
|
|
62
|
+
The framework for next generation AI applications
|
|
63
|
+
</p>
|
|
64
|
+
<p class="text-lg text-gray-400 max-w-3xl mx-auto mb-8">
|
|
65
|
+
Full-stack framework powered by TanStack Router for React and Solid.
|
|
66
|
+
Build modern applications with server functions, streaming, and type
|
|
67
|
+
safety.
|
|
68
|
+
</p>
|
|
69
|
+
<div class="flex flex-col items-center gap-4">
|
|
70
|
+
<a
|
|
71
|
+
href="https://tanstack.com/start"
|
|
72
|
+
target="_blank"
|
|
73
|
+
rel="noopener noreferrer"
|
|
74
|
+
class="px-8 py-3 bg-cyan-500 hover:bg-cyan-600 text-white font-semibold rounded-lg transition-colors shadow-lg shadow-cyan-500/50"
|
|
75
|
+
>
|
|
76
|
+
Documentation
|
|
77
|
+
</a>
|
|
78
|
+
<p class="text-gray-400 text-sm mt-2">
|
|
79
|
+
Begin your TanStack Start journey by editing{" "}
|
|
80
|
+
<code class="px-2 py-1 bg-slate-700 rounded text-cyan-400">
|
|
81
|
+
/src/routes/index.tsx
|
|
82
|
+
</code>
|
|
83
|
+
</p>
|
|
84
|
+
</div>
|
|
85
|
+
</div>
|
|
86
|
+
</section>
|
|
87
|
+
|
|
88
|
+
<section class="py-16 px-6 max-w-7xl mx-auto">
|
|
89
|
+
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
|
90
|
+
<For each={features}>
|
|
91
|
+
{(feature) => (
|
|
92
|
+
<div class="bg-slate-800/50 backdrop-blur-sm border border-slate-700 rounded-xl p-6 hover:border-cyan-500/50 transition-all duration-300 hover:shadow-lg hover:shadow-cyan-500/10">
|
|
93
|
+
<div class="mb-4">{feature.icon}</div>
|
|
94
|
+
<h3 class="text-xl font-semibold text-white mb-3">{feature.title}</h3>
|
|
95
|
+
<p class="text-gray-400 leading-relaxed">{feature.description}</p>
|
|
96
|
+
</div>
|
|
97
|
+
)}
|
|
98
|
+
</For>
|
|
99
|
+
</div>
|
|
100
|
+
</section>
|
|
39
101
|
</div>
|
|
40
|
-
)
|
|
102
|
+
);
|
|
41
103
|
}
|
|
@@ -1,26 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
import { defineConfig } from "vite";
|
|
2
2
|
import { devtools } from '@tanstack/devtools-vite'
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
import federationConfig from "./module-federation.config.js";
|
|
9
|
-
<% } %><% for(const integration of integrations.filter(i => i.type === 'vite-plugin')) { %>
|
|
10
|
-
<%- integrationImportContent(integration) %>
|
|
3
|
+
import viteTsConfigPaths from 'vite-tsconfig-paths'
|
|
4
|
+
import tailwindcss from "@tailwindcss/vite"
|
|
5
|
+
import { tanstackStart } from "@tanstack/solid-start/plugin/vite";
|
|
6
|
+
import solidPlugin from 'vite-plugin-solid';
|
|
7
|
+
<% for(const integration of integrations.filter(i => i.type === 'vite-plugin')) { %><%- integrationImportContent(integration) %>
|
|
11
8
|
<% } %>
|
|
9
|
+
import lucidePreprocess from "vite-plugin-lucide-preprocess";
|
|
12
10
|
|
|
13
|
-
// https://vitejs.dev/config/
|
|
14
11
|
export default defineConfig({
|
|
15
|
-
plugins: [devtools(), <% for(const integration of integrations.filter(i => i.type === 'vite-plugin')) { %><%- integrationImportCode(integration) %>,<% } %>
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
plugins: [lucidePreprocess(), devtools(), <% for(const integration of integrations.filter(i => i.type === 'vite-plugin')) { %><%- integrationImportCode(integration) %>,<% } %>
|
|
13
|
+
// this is the plugin that enables path aliases
|
|
14
|
+
viteTsConfigPaths({
|
|
15
|
+
projects: ['./tsconfig.json'],
|
|
16
|
+
}),
|
|
19
17
|
tailwindcss(),
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
'~': resolve(__dirname, './src'),
|
|
24
|
-
},
|
|
25
|
-
},<% } %>
|
|
18
|
+
tanstackStart(),
|
|
19
|
+
solidPlugin({ ssr: true }),
|
|
20
|
+
],
|
|
26
21
|
})
|
package/dist/frameworks.js
CHANGED
|
@@ -28,7 +28,6 @@ export function scanAddOnDirectories(addOnsDirectories) {
|
|
|
28
28
|
const filePath = resolve(addOnsBase, dir, 'info.json');
|
|
29
29
|
const fileContent = readFileSync(filePath, 'utf-8');
|
|
30
30
|
const info = JSON.parse(fileContent);
|
|
31
|
-
info.tailwind = info.tailwind ?? true;
|
|
32
31
|
let packageAdditions = {};
|
|
33
32
|
let packageTemplate = undefined;
|
|
34
33
|
if (existsSync(resolve(addOnsBase, dir, 'package.json'))) {
|
package/dist/package-json.js
CHANGED
|
@@ -24,12 +24,8 @@ export function createPackageJSON(options) {
|
|
|
24
24
|
name: options.projectName,
|
|
25
25
|
};
|
|
26
26
|
const additions = [
|
|
27
|
-
options.typescript
|
|
28
|
-
|
|
29
|
-
: undefined,
|
|
30
|
-
options.tailwind
|
|
31
|
-
? options.framework.optionalPackages.tailwindcss
|
|
32
|
-
: undefined,
|
|
27
|
+
options.framework.optionalPackages.typescript,
|
|
28
|
+
options.framework.optionalPackages.tailwindcss,
|
|
33
29
|
options.mode ? options.framework.optionalPackages[options.mode] : undefined,
|
|
34
30
|
];
|
|
35
31
|
for (const addition of additions.filter(Boolean)) {
|
|
@@ -42,10 +38,10 @@ export function createPackageJSON(options) {
|
|
|
42
38
|
const templateValues = {
|
|
43
39
|
packageManager: options.packageManager,
|
|
44
40
|
projectName: options.projectName,
|
|
45
|
-
typescript:
|
|
46
|
-
tailwind:
|
|
47
|
-
js:
|
|
48
|
-
jsx:
|
|
41
|
+
typescript: true,
|
|
42
|
+
tailwind: true,
|
|
43
|
+
js: 'ts',
|
|
44
|
+
jsx: 'tsx',
|
|
49
45
|
fileRouter: options.mode === 'file-router',
|
|
50
46
|
codeRouter: options.mode === 'code-router',
|
|
51
47
|
addOnEnabled: options.chosenAddOns.reduce((acc, addon) => {
|
package/dist/template-file.js
CHANGED
|
@@ -10,6 +10,22 @@ function convertDotFilesAndPaths(path) {
|
|
|
10
10
|
.map((segment) => segment.replace(/^_dot_/, '.'))
|
|
11
11
|
.join(sep);
|
|
12
12
|
}
|
|
13
|
+
function normalizeSourceExtension(target, typescript) {
|
|
14
|
+
if (!typescript) {
|
|
15
|
+
return target;
|
|
16
|
+
}
|
|
17
|
+
const normalizedTarget = target.replace(/\\/g, '/');
|
|
18
|
+
if (!normalizedTarget.startsWith('src/')) {
|
|
19
|
+
return target;
|
|
20
|
+
}
|
|
21
|
+
if (normalizedTarget.endsWith('.js')) {
|
|
22
|
+
return `${target.slice(0, -3)}.ts`;
|
|
23
|
+
}
|
|
24
|
+
if (normalizedTarget.endsWith('.jsx')) {
|
|
25
|
+
return `${target.slice(0, -4)}.tsx`;
|
|
26
|
+
}
|
|
27
|
+
return target;
|
|
28
|
+
}
|
|
13
29
|
export function createTemplateFile(environment, options) {
|
|
14
30
|
function getPackageManagerAddScript(packageName, isDev = false) {
|
|
15
31
|
return formatCommand(getPackageManagerInstallCommand(options.packageManager, packageName, isDev));
|
|
@@ -57,10 +73,10 @@ export function createTemplateFile(environment, options) {
|
|
|
57
73
|
const templateValues = {
|
|
58
74
|
packageManager: options.packageManager,
|
|
59
75
|
projectName: options.projectName,
|
|
60
|
-
typescript:
|
|
61
|
-
tailwind:
|
|
62
|
-
js:
|
|
63
|
-
jsx:
|
|
76
|
+
typescript: true,
|
|
77
|
+
tailwind: true,
|
|
78
|
+
js: 'ts',
|
|
79
|
+
jsx: 'tsx',
|
|
64
80
|
fileRouter: options.mode === 'file-router',
|
|
65
81
|
codeRouter: options.mode === 'code-router',
|
|
66
82
|
addOnEnabled,
|
|
@@ -97,6 +113,7 @@ export function createTemplateFile(environment, options) {
|
|
|
97
113
|
return;
|
|
98
114
|
}
|
|
99
115
|
let target = convertDotFilesAndPaths(file.replace('.ejs', ''));
|
|
116
|
+
target = normalizeSourceExtension(target, options.typescript);
|
|
100
117
|
// Strip option prefixes from filename (e.g., __postgres__schema.prisma -> schema.prisma)
|
|
101
118
|
const prefixMatch = target.match(/^(.+\/)?__([^_]+)__(.+)$/);
|
|
102
119
|
if (prefixMatch) {
|
|
@@ -116,9 +133,6 @@ export function createTemplateFile(environment, options) {
|
|
|
116
133
|
parser: 'typescript',
|
|
117
134
|
});
|
|
118
135
|
}
|
|
119
|
-
if (!options.typescript) {
|
|
120
|
-
target = target.replace(/\.tsx$/, '.jsx').replace(/\.ts$/, '.js');
|
|
121
|
-
}
|
|
122
136
|
if (append) {
|
|
123
137
|
await environment.appendFile(resolve(options.targetDir, target), content);
|
|
124
138
|
}
|