create-rsc-kit 0.8.0 → 0.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/templates.js +24 -2
- package/package.json +1 -1
package/dist/templates.js
CHANGED
|
@@ -205,12 +205,22 @@ export function viteConfig(o) {
|
|
|
205
205
|
plugins.push('babel({ presets: [reactCompilerPreset()] })');
|
|
206
206
|
if (o.tailwind)
|
|
207
207
|
plugins.push('tailwindcss()');
|
|
208
|
+
// `@/` for the source directory. Vite does not read tsconfig `paths`, so the
|
|
209
|
+
// alias has to exist here as well or the import type-checks and then fails to
|
|
210
|
+
// resolve — and the tsconfig half is what tools like shadcn look for when
|
|
211
|
+
// they ask whether this project has an import alias at all.
|
|
208
212
|
return `${imports.join('\n')}
|
|
213
|
+
import { fileURLToPath } from 'node:url'
|
|
209
214
|
|
|
210
215
|
export default defineConfig({
|
|
211
216
|
plugins: [
|
|
212
217
|
${plugins.join(',\n ')},
|
|
213
218
|
],
|
|
219
|
+
resolve: {
|
|
220
|
+
alias: {
|
|
221
|
+
'@': fileURLToPath(new URL('./${o.sourceDir}', import.meta.url)),
|
|
222
|
+
},
|
|
223
|
+
},
|
|
214
224
|
})
|
|
215
225
|
`;
|
|
216
226
|
}
|
|
@@ -220,6 +230,16 @@ export const tsconfig = (o) => JSON.stringify({
|
|
|
220
230
|
target: 'ESNext',
|
|
221
231
|
module: 'ESNext',
|
|
222
232
|
moduleResolution: 'bundler',
|
|
233
|
+
// `@/thing` for `<sourceDir>/thing`. Matched by resolve.alias in the
|
|
234
|
+
// vite config, which is what actually resolves it — this half is for
|
|
235
|
+
// the type system, and for the tools that read a tsconfig to find out
|
|
236
|
+
// whether the project has an import alias. shadcn refuses to init
|
|
237
|
+
// without one.
|
|
238
|
+
//
|
|
239
|
+
// No `baseUrl`: TypeScript removed it, and emitting it now is an
|
|
240
|
+
// outright TS5102 on a freshly scaffolded app. Paths resolve relative
|
|
241
|
+
// to this file without it.
|
|
242
|
+
paths: { '@/*': [`./${o.sourceDir}/*`] },
|
|
223
243
|
jsx: 'react-jsx',
|
|
224
244
|
strict: true,
|
|
225
245
|
noEmit: true,
|
|
@@ -253,8 +273,9 @@ export const tsconfig = (o) => JSON.stringify({
|
|
|
253
273
|
}, null, 2) + '\n';
|
|
254
274
|
export function layout(o) {
|
|
255
275
|
return `${o.tailwind ? "import './styles.css'\n" : ''}import type { ReactNode } from 'react'
|
|
276
|
+
import type { Metadata } from '@rsc-kit/core/metadata'
|
|
256
277
|
|
|
257
|
-
export const metadata = {
|
|
278
|
+
export const metadata: Metadata = {
|
|
258
279
|
title: { template: '%s · ${o.name}', default: '${o.name}' },
|
|
259
280
|
}
|
|
260
281
|
|
|
@@ -288,8 +309,9 @@ export function page(o) {
|
|
|
288
309
|
// did was look broken, and the fix someone reaches for is to stop
|
|
289
310
|
// prerendering the page that is teaching them about prerendering.
|
|
290
311
|
return `import { Counter } from '../components/Counter'
|
|
312
|
+
import type { Metadata } from '@rsc-kit/core/metadata'
|
|
291
313
|
|
|
292
|
-
export const metadata = { title: 'Home' }
|
|
314
|
+
export const metadata: Metadata = { title: 'Home' }
|
|
293
315
|
|
|
294
316
|
// A server component. It runs on the server and ships no JavaScript of its
|
|
295
317
|
// own — this file is not in the browser bundle. It can be \`async\` and await
|