diff --git a/packages/next/src/generators/application/lib/create-application-files.ts b/packages/next/src/generators/application/lib/create-application-files.ts index d70728da10ce5..ae9fe71e7e141 100644 --- a/packages/next/src/generators/application/lib/create-application-files.ts +++ b/packages/next/src/generators/application/lib/create-application-files.ts @@ -63,6 +63,10 @@ export function createApplicationFiles(host: Tree, options: NormalizedSchema) { let { extends: _, ...updatedJson } = json; + // Don't generate the `paths` object or else workspace libs will not work later. + // It'll be generated as needed when a lib is first added. + delete json.compilerOptions.paths; + updatedJson = { ...updateJson, compilerOptions: { diff --git a/packages/next/src/generators/library/library.ts b/packages/next/src/generators/library/library.ts index c548ee0d9f705..b1d6cf2c32b74 100644 --- a/packages/next/src/generators/library/library.ts +++ b/packages/next/src/generators/library/library.ts @@ -54,7 +54,20 @@ export async function libraryGenerator(host: Tree, rawOptions: Schema) { 'src', `server.${options.js ? 'js' : 'ts'}` ), - `// Use this file to export React server components\n` + `// Use this file to export React server components + export * from './lib/hello-server';` + ); + host.write( + joinPathFragments( + options.projectRoot, + 'src/lib', + `hello-server.${options.js ? 'js' : 'tsx'}` + ), + `// React server components are async so you make database or API calls. + export async function HelloServer() { + return