1065 Commits

Author SHA1 Message Date
Leosvel Pérez Espinosa
a5d20030db
fix(js): update outDir in runtime tsconfig files to match types export in package.json (#30217)
## Current Behavior

In the TS solution setup, several project generators produce the runtime
tsconfig files (e.g. `tsconfig.lib.json`) with the `outDir` set to
`out-tsc/<project name>`. This causes issues with the inferred
`typecheck` task because the project `package.json` has the `types`
export pointing to `dist/...`, which wouldn't be produced by
`typecheck`.

## Expected Behavior

In the TS solution setup, project generators should produce the runtime
tsconfig files (e.g. `tsconfig.lib.json`) with the `outDir` set to a
path (`dist`) that matches the value in the project `package.json`'s
`types` export.

## Related Issue(s)

Fixes #
2025-02-28 16:10:58 -05:00
Leosvel Pérez Espinosa
914b1cc1db
fix(js): handle plugin correctly for non-buildable libs and don't add duplicated pattern to workspaces config (#30209)
## Current Behavior

- Generating a non-buildable library in a workspace using the TS
solution setup where a plugin registration for `@nx/js/typescript`
already exists and doesn't configure a build target, results in that
plugin registration being updated excluding the new project and a new
registration being added including the project but inferring the build
target.
- Generating a library in a sub-directory that matches a pattern in the
package manager workspaces configuration, results in a more specific
pattern being added to the workspace configuration.

## Expected Behavior

- Generating a non-buildable library in a workspace using the TS
solution setup where a plugin registration for `@nx/js/typescript`
already exists and doesn't configure a build target, should not modify
that plugin registration and it should not add an extra one.
- Generating a library in a sub-directory that matches a pattern in the
package manager workspaces configuration, should not add a more specific
pattern.

## Related Issue(s)

Fixes #
2025-02-28 14:41:46 +01:00
Isaac Mann
8b11d8bfe5
docs(core): add migrations docs for 20.x (#30186)
Adds migration docs for all 20.0 through 20.4 migrations
2025-02-27 15:58:41 -05:00
Kevin Hallmark
c02719d2df
feat(module-federation): Update to the latest version of @module-federation (#30147) 2025-02-25 15:49:19 +04:00
Emily Xiong
fc39b3dc49
fix(react): add release option for @nx/react:lib --publishable (#29776) 2025-02-15 13:27:18 +04:00
Nicholas Cunningham
3152502629
feat(react): Update react-router-dom to latest (#29919)
Update `react-router-dom` and `remix` package versions to latest.
Currently, there should be no breaking changes from our generators.
2025-02-14 14:10:56 -07:00
Leosvel Pérez Espinosa
eb0505b1ad
fix(vite): ignore vite temp files in eslint config (#29909)
## Current Behavior

Vite config temp files can sometimes cause errors to be thrown by
ESLint.

## Expected Behavior

Vite config temp files should be ignored by ESLint.

## Related Issue(s)

Fixes #
2025-02-13 17:04:26 +01:00
Nicholas Cunningham
4e04979a36
fix(rspack): should be inferred by default (#29736)
This PR updates the Rspack Plugin to be inferred by default.

### Currently
When you generate a project using rspack it would not be inferred and
would add the executor to `project.json`.

### After
Generating a project using rspack will add it to inferred plugins inside
`nx.json` and update the `rspack.config.js` to be a standard config and
use Nx plugins.
2025-02-12 07:24:39 -07:00
Colum Ferry
c1ebcb9129
feat(vite): add support for vite 6 (#29871)
## Current Behavior
Nx currently supports Vite at version 5. Nx does not generate vite
configurations using Vite 6 which has been released.
 

## Expected Behavior
Nx should use Vite 6 for vite projects.

## TODO
- [x] Add Package Update Migrations for Existing Projects
- [x] Add AST migrations to handle breaking change in resolve.extensions
- [x] Add migration to install `jsx` or `jiti` to handle processing TS
postcss config files
2025-02-11 11:28:23 -05:00
Colum Ferry
a7c8c1021e
feat(testing): support vitest 3 (#29908)
## Current Behavior
We currently still generate Vitest configuration using Vitest v1.

Vitest v3 has released so Nx is pretty far behind now.


## Expected Behavior
Update vitest version to v3 and use it to configure new projects.
Existing workspaces using v1 will continue to use v1.
2025-02-07 13:10:01 -05:00
Leosvel Pérez Espinosa
8d056c9cdb
fix(misc): generate config with output contained within project root (#29850)
Updates some generators to ensure the build tool produces the output
contained within the project root for the TS solution setup.

## Current Behavior

## Expected Behavior

## Related Issue(s)

Fixes #
2025-02-04 09:16:02 -05:00
Phillip Barta
7df5737e12
feat(node): upgrade express to v4.21.2 to address security vulnerabilities (#29419)
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
Nx should install and depend on a version of express without security
vulnerabilities.

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #

Co-authored-by: Igor Loskutov <igor.loskutoff@gmail.com>
Co-authored-by: Colum Ferry <cferry09@gmail.com>
2025-01-27 11:49:20 -05:00
Leosvel Pérez Espinosa
1a13a67982
fix(misc): generate remix libs correctly and install correct @types/react version for react libs (#29760)
- Fix server file location for the `@nx/remix:library` generator
- Do not error when generating a buildable Remix library in the TS
solution setup
- Install the correct versions of react-related packages when generating
a React library

## Current Behavior

## Expected Behavior

## Related Issue(s)

Fixes #
2025-01-27 10:28:48 -05:00
Jack Hsu
45847a6754
feat(js): remove nx property from generated package.json files (#29705)
This PR updates our generators to no longer generate with `nx` in
`package.json` by default. The only times it is needed is if you pass
add `tags` or `implicitDependencies` to the project config.

This PR replaces our `projectType` checks to use the `getProjectType`
util from `@nx/js` to prefer the project config, but otherwise will
check for our conventions (e.g. using `exports` for libs,
`tsconfig.lib.json` vs `tsconfig.app.json`).

## Impact
- There shouldn't be any behavioral changes to existing projects that
have explicit `projectType`, `name`, etc. in with `project.json` or
`package.json` (via `nx` property).
- For new projects created under the new TS setup, the `nx` property
will no longer be there. Generators with logic that depend on
`projectType` will now check for `tsconfig.lib.json` and
`tsconfig.app.json` (so all of our generators are covered). If none of
those tsconfig files are found, then we check `package.json`, since
libraries are required to have `exports` to be consumed.
2025-01-23 20:03:28 -05:00
Leosvel Pérez Espinosa
4bbbea2def
fix(react): ensure project name is escaped in spec matcher when generating an application (#29732)
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #
2025-01-23 17:55:48 +01:00
Colum Ferry
a468d72c7f
feat(react): add support for React 19 for new Workspaces (#29286)
## Current Behavior
We currently have no support for React 19, generating only React 18
applications.

## Expected Behavior
Add utils to determine what version of React is installed in the
workspace.
If React 18 is the main version of react installed, continue to generate
React 18 projects.
If React 19 is the main version of react installed, generate React 19
projects.
If no React version is installed or can be determined, generate React 19
projects.
2025-01-17 15:14:48 +00:00
Jack Hsu
1e032fb9e5
fix(misc): update e2e config generators to align with new TS solution setup (#29638)
This PR updates the `@nx/detox:app` generator to match the new TS
solution setup. The `@nx/cypress:configuration` and
`@nx/cypress:configuration` generators are also updated so that they can
be run on existing projects and generator the correct tsconfig files.

The Playwright/Cypress example can be seen as follows:

```shell
# Skip e2e
nx g @nx/react:app apps/demo --bundler vite --e2eTestRunner none

# now configure e2e
nx g @nx/playwright --project demo
```

Now if you add this line to `apps/demo/e2e/example.spec.ts`:
```
const x: number = 'a';
```

And run `nx typecheck demo`, it will pass. This happens because the
`e2e/**/*.ts` pattern is missing. Thus, we need to ensure that a
`tsconfig.e2e.json` project is added for the Playwright spec files. Same
thing with Cypress.

The Detox generator does not support adding configuration to existing
project, so we don't quite get the same problem. The fix for Detox is
just to make sure the tsconfig content is not following the old
(integrated) version, but the updated TS solution version.

## Current Behavior
Detox TS setup is incorrect. Running Cypress and Playwright
configuration generator on existing projects generate invalid setup,
such that spec files are not typechecked.

## Expected Behavior
E2E generators should all generate correct TS setup.

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #
2025-01-16 13:10:34 -05:00
Leosvel Pérez Espinosa
ed6b220214
fix(js): fix typo so exports field in package.json is properly sorted (#29643)
## Current Behavior

It tries to sort `exported` which is an invalid field.

## Expected Behavior

It should sort `exports`.

## Related Issue(s)

Fixes #
2025-01-16 08:44:31 -05:00
Leosvel Pérez Espinosa
a1271776d5
fix(misc): generate module and moduleResolution in base tsconfig based on cnw preset (#29633)
## Current Behavior
<!-- This is the behavior we have today -->

Creating a new workspace using the TS solution setup always generates a
`tsconfig.base.json` with `module: nodenext` and `moduleResolution:
nodenext`.

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

Creating a new workspace using the TS solution setup should generate a
`tsconfig.base.json` with `module: nodenext`/`moduleResolution:
nodenext` for Node stacks and `module: esnext`/`moduleResolution:
bundler` for Web stacks (React, Vue).

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #
2025-01-15 16:21:35 -05:00
Jack Hsu
cc441a6dc7
fix(js): sort package.json fields by idiomatic order (#29635)
This PR updates our app/lib generators such that `package.json` files
generated have fields in idiomatic order.

e.g.

```json
{
  "name": "...",
  "version": "...",
  "private": true,
  "type": "module",
  "main": "...",
  ...
  "dependencies": { ... }
}
```

The import fields such as name, version, private, and type are at the
top. Dep fields that could be noisy are at the bottom.

## Current Behavior
<!-- This is the behavior we have today -->

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #
2025-01-15 15:52:23 -05:00
Colum Ferry
7ef4fa795f
fix(vite): plugin should infer 'vite' for dev/serve command (#29585)
## Current Behavior
We currently have a `serveTargetName` that defaults to `serve` in the
`@nx/vite/plugin`.
This infers a `vite serve` command for the `serve` task to vite
projects.

While not incorrect, it could be abrasive for users coming from the
`vite` ecosystem to Nx.
The command to start the Vite Dev Server is `vite`, so we should infer
this.

`create-vite` also creates a package.json script with `"dev": "vite"`
meaning users are likely running `npm run dev`.

This creates two points of differences for vite ecosystem users.

## Expected Behavior
Deprecate `serveTargetName` in favour of `devTargetName` to more closely
align with lanugage from the Vite ecosystem.

Infer the command `vite` instead of `vite serve` for the `serve` and
`dev` tasks.
2025-01-15 17:32:10 +00:00
Leosvel Pérez Espinosa
9dbebbee20
fix(misc): ensure exports are generated for several lib generators in ts solution setup (#29588)
- Update React Native, React, Remix and Vue library generators to
produce `exports` in the `package.json` for the TS solution setup
- Fix an issue in `@nx/rollup/with-nx` where an unhandled `undefined`
plugin was causing an error to be thrown
- Fix output path of the build task for React Native libraries in the TS
solution setup

<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #
2025-01-10 15:49:49 -05:00
Colum Ferry
dbdb72aee2
fix(react): setup mf env var as input for rspack (#29584)
## Current Behavior
The Module Federation `NxRuntimeLibraryControlPlugin` relies on an
environment variable that is set during the build/serve process.
This could potentially lead to issues with cache restoration.

The impact should be minimal as the runtime control plugin should only
be added to the module federation config when the env var is set.
It should only be set by the `module-federation-dev-server` executor
which is invoked during serve - a non-cacheable task already.

## Expected Behavior
Ensure the env var is set as an input to ensure maximum accuracy with
module federation builds via rspack executor
2025-01-10 17:15:08 +00:00
Leosvel Pérez Espinosa
dd9b09f917
fix(js): generate js libs with exports in package.json and ensure esm output when using rollup bundler (#29565)
- Ensure libs are generated with `exports` in `package.json`
- Generate `types` instead of `typings` in package.json
- Update js lib with rollup to only output esm
- Update `tsconfig.spec.json` for js libraries with rollup to set
`module: esnext` and `moduleResolution: bundler` (they use `@swc/jest`)
- Fix `@nx/js/typescript` issue with absolute paths when normalizing
inputs/outputs
- Fix `@nx/js/typescript` issue identifying buildable libs
- Fix express app generator not installing `@types/express`

<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #

---------

Co-authored-by: Jack Hsu <jack.hsu@gmail.com>
2025-01-10 08:29:09 -05:00
Jack Hsu
fb318005f2
fix(js): avoid nested paths in workspaces because they can lead to future issues (#29553)
For the new TS setup, we currently use nested glob patterns: `apps/**`,
`libs/**`, and `packages/**`.

Nested paths can result into too many projects being matched. For
example, if `libs/mylib/src/__fixtures__/package.json` is there for
testing, it will be matched as a project and likely result in an error.

Other tools like turborepo also caution against this:
https://turbo.build/repo/docs/crafting-your-repository/structuring-a-repository#declaring-directories-for-packages

If users want to, they could change to nested `**` paths, but we should
not use it by default.

Note: For CNW, we only use `apps/*` by default since that is where the
project lives. When users do `nx g lib packages/foo` then `packages/*`
will be added automatically.

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->
Use nested `**` paths.

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
Don't use nested `**` paths.

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #
2025-01-08 18:08:39 -05:00
Colum Ferry
5157a0daf9
feat(module-federation): upgrade to latest version of @module-federation/enhanced (#29535)
## Current Behavior
We currently use version `0.7.6` of `@module-federation/enhanced`.
This version does not contain the `externalRuntime` experiment to reduce
the remoteEntry bundle size.

## Expected Behavior
Upgrade Nx dependency of `@module-federation/enhanced` to version
`0.8.8`.
2025-01-08 10:32:38 +00:00
Jack Hsu
90c0c8ebf6
fix(react): transpile SVGR into React 19 compatible component (#29543)
This PR fixes an issue with React 19 and our `@nx/react/plugins/jest`
transform. The current transform uses an unsupported `$$typeof` symbol,
and also uses the deprecated `forwardRef` API.

The updated transform will use new API for React 19 and older, while
maintaining the previous API for React 18 and earlier. The backwards
compatibility may be needed if the test is using `ref`, which requires
`forwardRef` older versions.

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
SVGR fails in Jest tests with React 19

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
SVGR works

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #
2025-01-07 18:26:02 -05:00
Jack Stevenson
9e78142185
fix(js): only add typescript project references for explicit dependencies in sync generator (#28998)
This change omits references to implicit dependency tsconfigs for
typescript projects in the sync generator, since given that they are not
referenced directly in code there is no need for project references.

## Current Behavior
TypeScript sync generator adds references to any dependency project
which has a tsconfig (where composite is true), including implicit
dependencies where these references are unnecessary and can potentially
cause build failures.

See [example
repo](https://github.com/cogwirrel/nx-sync-generator-implicit-deps-example).

## Expected Behavior
Only explicit dependencies should be referenced in tsconfigs.

## Related Issue(s)
Fixes #28997

---------

Co-authored-by: Leosvel Pérez Espinosa <leosvel.perez.espinosa@gmail.com>
2025-01-07 10:35:08 +01:00
Phillip Barta
7a583dacc6
cleanup(repo): remove unused dependencies (#27676) 2024-12-19 18:45:57 +04:00
Colum Ferry
2db82dd36d
feat(rsbuild): move plugin export to root of package (#29415)
## Current Behavior
The Rsbuild plugin is exported at `@nx/rsbuild/plugin`


## Expected Behavior
Export the plugin from `@nx/rsbuild` i.e. the root of the package.
2024-12-19 14:09:57 +00:00
Colum Ferry
656d69b466
fix(module-federation): ensure @nx/module-federation package is installed for users (#29416)
## Current Behavior
The `@nx/module-federation` package is a direct dependency of some of
the other packages in the Nx Plugin ecosystem.
It should be resolved correctly by package managers such that it can be
used when setting up MF projects.

However, some users are facing issues with module resolutions where the
package is not found as expected.

## Expected Behavior
Install the package directly for the user to ensure module resolution
works as expected.

## Related Issue(s)

Fixes #29269
2024-12-19 14:09:48 +00:00
Nicholas Cunningham
a675bd2a06
fix(js): Configure typescript plugin to handle non-buildable libs (#29393)
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->
Currently, we are excluding non-buildable libs from the
`@nx/js/typescript` plugin. Although that allows non-buildable projects
from have the build target being inferred it also as a side-effect
removes the `typecheck` target which is unintended. Additionally, to
breaks the pattern of being self containment that TS project solutions
brings as we were modifying the root `nx.json`

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
1. Non-buildable libs should not have a build target.
2. Non-buildable libs should have the typecheck target.
3. Buildable libs remain unchanged and should have both a build and
typecheck target.
4. Remove the `exclude` from `nx.json` for non-buildable libs.

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #
2024-12-18 15:20:29 -05:00
Nicholas Cunningham
d05f30fb01
fix(core): Adding react apps/libs to workspaces so they can be referenced. (#29202)
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->
This PR address a few things:

1. When we generate an app or a library using the new TS Solution they
are not added to the workspaces/packages option.
2. Currently, when we use `pnpm` to generate a workspace the
`pnpm-workspace.yaml` looks like below which is not correct
```
packages: 
  - packages/**
```

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

1. Libraries and apps should be referenced correctly out of the box so
that they can be symlinked after installation.
2. The intended `pnpm-workspace.yaml` should look similar to:
```
packages: 
  - 'packages/**'
  - 'demo'
```

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

---------

Co-authored-by: Jack Hsu <jack.hsu@gmail.com>
2024-12-18 12:39:47 -05:00
Colum Ferry
4b586a1acc
feat(rsbuild): add react and vue support for app generation (#29349)
## Current Behavior
We do not have a generator that can scaffold a react or vue app using
rsbuild.


## Expected Behavior
Update the react application generator to support a bundler option of
rsbuild
Update the vue application generator to support a bundler option of
rsbuild
2024-12-18 11:44:21 -05:00
Leosvel Pérez Espinosa
f922e2bcf0
fix(misc): fix misc generation issues with the ts solution setup (#29350)
Fix misc generation issues related to the new TS solution setup:

- Improve Cypress config default formatting (when no prettier)
- Remove leftover compiler options from `tsconfig.json` files
- Do not add TS path mappings
- Update `outDir` for `typecheck` tasks to be `out-tsc/...`
- Generate Nx configuration in `package.json` files for e2e test runner
projects
- Fix issue with `@nx/js:library` and `--bundler=vite`
- Other smaller changes

<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #
2024-12-16 16:23:50 +00:00
Leosvel Pérez Espinosa
99a0e7c5a0
fix(misc): ensure tsBuildInfoFile is generated inside outDir (#29343)
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #
2024-12-16 14:53:18 +01:00
Jack Hsu
a8de7df0e0
feat(js): update vue/node app and lib generators to support TS solutions (#29299)
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #

---------

Co-authored-by: Leosvel Pérez Espinosa <leosvel.perez.espinosa@gmail.com>
2024-12-12 15:43:14 -05:00
Emily Xiong
cfcd4d1440
fix(react): fix tailwind for react library and component (#29319)
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes https://github.com/nrwl/nx/issues/27954
2024-12-12 13:05:21 -05:00
Jack Hsu
c2eae0e297
fix(react): fix issues with react ts setup (#29312)
Fixes a couple of things:

1. React application should ignore `eslint.config.js`,
`eslint.config.cjs`, and `eslint.config.mjs` files since they are not
part of the app runtime.
2. React lib generators should always run `npm install`. It currently
runs only when `package.json` has changed, but we need to run it to link
packages regardless of `package.json` changes.
2024-12-11 15:00:56 -05:00
Edouard Bozon
5068a26ed6
chore(react): fix formatting for the style prompt (#28159)
## Current Behavior


![image](https://github.com/user-attachments/assets/39a12e28-e175-46e7-a3f7-7ac9b1b4cb82)


## Expected Behavior
Correct format

## Related Issue(s)
N/A

---------

Co-authored-by: Colum Ferry <cferry09@gmail.com>
2024-12-11 13:41:38 +00:00
Nigel Sirisomphone
e4939fa3ee
fix(react): assert test property is defined on webpack rule in nx-react-webpack-plugin (#27525)
The `removeSvgLoaderIfPresent` method in `apply-react-config.ts`
iterates through each Webpack rule, calls `toString` on each `test`
property, and checks for the presence of the string `"svg"` to see if
any existing SVG plugins need to be removed.

Some of the Webpack rules in the config don't have the test property,
and calling `toString` without asserting the test property is defined
first throws type errors.

This commit introduces a very small change that simply asserts that
`rule.test` is not `undefined` before calling `.toString()`.

## Current Behavior
Running a React Webpack library with `svgr` enabled causes compilation
errors.

<img width="1171" alt="Screenshot 2024-08-20 at 10 36 09 AM"
src="https://github.com/user-attachments/assets/cb28d1ca-10d2-4d20-aa78-e69339a8273b">

<img width="487" alt="Screenshot 2024-08-20 at 10 39 28 AM"
src="https://github.com/user-attachments/assets/c170e0d8-8674-43b0-97a3-a5dffd398c17">

## Expected Behavior
Enabling SVGR in the `NxReactWebpackPlugin` config should compile as
normal.

---------

Co-authored-by: Colum Ferry <cferry09@gmail.com>
2024-12-11 10:40:21 +00:00
Colum Ferry
ee91b63b42
feat(rsbuild): add inferred targets plugin (#29192)
## Current Behavior
There is currently no way to execute Rsbuild targets via Nx.

## Expected Behavior
Add a `@nx/rsbuild/plugin` to infer targets based on the
`rsbuild.config` files in the workspace.
Also add an `init` generator to allow for `nx init` in existing rsbuild
projects.
2024-12-10 12:36:15 -05:00
Jack Hsu
7e388243e0
fix(react): add files entry for publishable libraries (#29277)
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #
2024-12-10 09:08:39 -05:00
Leosvel Pérez Espinosa
6684fc0688
fix(vite)!: generate config with esm by default (#29270)
BREAKING CHANGE

When generating projects that use Vite, the Vite configuration will be
set to use the ESM format only. Previously, the configuration was set to
produce both ESM and CJS, but the dual format was not correctly
configured in the libraries' `package.json` files, nor was it producing
the correct declaration files.

<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #
2024-12-10 11:58:51 +01:00
Leosvel Pérez Espinosa
28c53f942b
feat(misc): handle artifact generators' path options including file extensions (#29111)
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->

Artifact generators don't handle consistently receiving a file extension
in the `path` option.

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

Artifact generators should handle receiving a file extension in the
`path` option. If the file extension is passed, the file path will be
treated as "complete" and used fully as provided. If the `path` provided
doesn't contain a file extension, the default extension will be appended
to it (or the one provided in a related option, e.g. `--language`,
`--js`, etc) together with the suffix for generators that use it.

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #
2024-12-09 09:13:15 -05:00
Jack Hsu
6c5916a79f
feat(rollup): use .cjs file extension for config files (#29196)
The `rollup.config.js` file will be resolved as ESM if the closest
`package.json` has `type: 'module`. This causes an error when computing
the project graph and when reading the file for builds.

```
  Original error: require is not defined in ES module scope, you can use import instead
```

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

This PR also updates the output directory to `{projectRoot}/dist` for
the new TS setup.

## Current Behavior
`nx g @nx/react:lib --bundler=rollup` has an error due to Node
resolution

## Expected Behavior
`nx g @nx/react:lib --bundler=rollup` works out of the box

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #29193, #[29195](https://github.com/nrwl/nx/issues/29195)

---------

Co-authored-by: Leosvel Pérez Espinosa <leosvel.perez.espinosa@gmail.com>
2024-12-04 12:53:42 -05:00
Jack Hsu
972c01bd25
feat(storybook): add support for TS solutions file (#29194)
This PR adds support for the [new TS
setup](https://github.com/nrwl/nx/discussions/29099) with Storybook.
2024-12-04 17:44:07 +00:00
Colum Ferry
aefafc55ba
feat(module-federation): alias host and remote generators to consumer and producer (#29190)
## Current Behavior
Our Module Federation support across Angular and React contains Host and
Remote generators.
The module-federation.io docs have started to shift towards Consumer and
Producer terminology for better translation of meanings across
languages.


## Expected Behavior
To stay consistent with official terminology, add aliases for the host
and remote generators to allow for the new terminology. i.e. host ->
consumer, remote -> producer.

Therefore the following are all valid

```shell
nx g host shell --remotes=remote1
nx g host shell --producers=producer1
nx g consumer shell --remotes=remote1
nx g consumer shell --producers=remote1

nx g remote remote1 --host=shell
nx g remote remote1 --consumer=shell
nx g producer producer1 --host=shell
nx g producer producer1 --consumer=shell
```
2024-12-04 16:45:27 +00:00
Nicholas Cunningham
dd14f3943c
fix(react): None buildable libs should not have a build target (#29175) 2024-12-03 16:30:51 -07:00
Colum Ferry
5448046f06
feat(module-federation): move common executor logic to module-federation package (#29151)
## Current Behavior
The logic for the `module-federation-dev-server` and
`module-federation-ssr-dev-server` is duplicated across Angular, React
and Rspack.

The majority of this logic is the same, and the duplication causes an
increased maintenance tax.

## Expected Behavior
Move the logic into a utility that is exposed from
`@nx/module-federation`.
2024-12-03 08:15:20 -05:00