Skip to content

Support TypeScript-solution workspaces in the application generator #219

Open

Description

@tbinna

Problem

The application generator only supports classic Nx workspaces, where projects use project.json and libraries resolve through tsconfig.base.json path aliases. In a TypeScript-solution workspace (project references, workspace packages, nodenext resolution), generated Forge apps don't build.

New Nx workspaces are increasingly TypeScript-solution workspaces. For example, when create-nx-workspace 24 runs inside an AI agent, it ignores --preset=apps and creates one from the nrwl/empty-template template. This also means the e2e suite tests a different workspace layout depending on whether an agent runs it.

Proposed solution

Support both layouts, following the upstream @nx/node application generator (packages/node/src/generators/application):

  1. Detection: use isUsingTsSolutionSetup(tree) from @nx/js/internal in normalizeOptions.
  2. Project definition: in TypeScript-solution workspaces, write the app's package.json (with an nx section) instead of project.json, add a useProjectJson option like upstream, and register the app in the workspace with addProjectToTsSolutionWorkspace.
  3. TypeScript config: set module and moduleResolution to nodenext in tsconfig.app.json and add project references with updateTsconfigFiles.
  4. Output path: use upstream's <projectRoot>/dist convention in getForgeOutputPath, so the build output and the Forge targets still agree.
  5. Graph plugin: createNodes only creates a Forge project if there's a project.json next to manifest.yml. It also needs to accept a project defined by package.json.
  6. Package executor: check that package.json generation for the Forge bundle works when the app has its own package.json and depends on workspace libraries through workspace:*.
  7. E2E: run application.generator.spec.ts against both layouts, with the workspace layout chosen explicitly rather than depending on the environment.

Notes

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions