Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(node): update CNW to support generating a node server with a framework #14313

Merged
merged 1 commit into from
Jan 13, 2023

Conversation

ndcunningham
Copy link
Contributor

@ndcunningham ndcunningham commented Jan 12, 2023

This PR updates --preset to also include node-server, such that you can use

npx create-nx-workspace --preset=node-server

Changes

This will generate a node-server using one of the following user-decided frameworks:

  • express
  • koa
  • connect
  • fastify

It works in conjunction with the @nrwl/node:app generator.

As such the --framework is also an optional tag which can be used to decide upfront which framework should be generated.
If not provided the user will be asked during the creation of their workspace

@ndcunningham ndcunningham requested a review from jaysoo January 12, 2023 16:09
@vercel
Copy link

vercel bot commented Jan 12, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
nx-dev ✅ Ready (Inspect) Visit Preview Jan 13, 2023 at 6:35PM (UTC)

@@ -96,6 +98,10 @@ const presetOptions: { name: Preset; message: string }[] = [
message:
'react-native [a monorepo with a single React Native application]',
},
{
name: Preset.NodeServer,
message: 'node [a standalone repo with a single Node Server]',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add e.g. Express since it's the most popular choice and we can be make obvious which selection to pick.

}));
if (options.framework && options?.bundler === 'esbuild') {
// updatae tsconfig.app.json to typecheck default exports https://www.typescriptlang.org/tsconfig#esModuleInterop
updateJson(tree, `${options.appProjectRoot}/tsconfig.app.json`, (json) => ({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this may have been a mistake in the past. We should always update the compilerOptions on tsconfig.json not tsconfig.app.json.

The reason is that other tsconfig files such as tsconfig.spec.json will also need those options.

We should update it to be:

if (options.rootProject) {
  // ... 
} else {
  // ...
}

I don't think need to check framework or bundler, unless the framework needs other entries in types, like types: ['node', 'express'].

@github-actions
Copy link

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants