710 Commits

Author SHA1 Message Date
MisterPandaPooh
4fc52cf836
fix(js): use absolute filetorun path (#30091)
Fix a bug introduced in #30087

#### Current Behavior
The `@nx/js` plugins throw an error when the project is served in the
project root but not in the workspace root.

#### Expected Behavior
Ensure that `nx run $project:serve` works correctly both in the
workspace root and the project root, restoring the previous behavior.

#### Related Issue(s)
Fixes #30087
2025-02-25 11:44:51 +00:00
Colum Ferry
46e5dcefb0
fix(js): use uuid when generating tmp tsconfig (#30118)
## Current Behavior
When multiple processes/tasks are running in parallel for a single
project that produce tmp tsconfig files for buildable libraries, they
can clobber each other.
 

## Expected Behavior
Ensure the config file is generated with a unique id to prevent
clobbering
2025-02-20 15:53:44 -05:00
Emily Xiong
42e860d3ea
feat(js): upgrade verdaccio to 6 (#30015) 2025-02-19 13:44:31 +04:00
James Henry
443d4fd27a
feat(core): support bun's new text-based lockfile and use bun publish within nx release (#30064) 2025-02-19 13:42:35 +04:00
Emily Xiong
1047991200
fix(js): identify correct circular dependecies (#29759) 2025-02-19 13:13:08 +04:00
Leosvel Pérez Espinosa
96c775b4cf
fix(js): invalidate tsconfig files cache in the @nx/js/typescript plugin when extended files change (#30071)
## Current Behavior

- The persistent tsconfig files cache used by the `@nx/js/typescript`
plugin does not get invalidated when the tsconfig files it extends from
are updated.
- Absolute paths are stored in the cache, which would be incorrect when
distributing the cache.
- The plugin throws a cryptic error when the lock file doesn't exist.

## Expected Behavior

- The persistent tsconfig files cache used by the `@nx/js/typescript`
plugin should get invalidated when the tsconfig files it extends from
are updated.
- Paths should be stored relative to the workspace root.
- The plugin should handle when the lock file is missing.

Additionally, a few other performance improvements were made to offset
the overhead introduced by creating a stricter cache key:

- cache and reuse file reads between tsconfig reads and file hashing
(now each file is only read once, if read at all)
- initialize a pre-populate tsconfig files cache in a first pass to skip
checking cache entries' key in subsequent reads
- reduce the tsconfig file cached content we store to disk
- cache the check for external project references

## Related Issue(s)

Fixes #29429
2025-02-18 12:34:59 +01:00
James Henry
b10856bb32
feat(release): configure when all branches should be checked for a matching releaseTagPattern (#30044) 2025-02-14 17:02:02 +04:00
Leosvel Pérez Espinosa
13319a857d
fix(js): improve the @nx/js/typescript plugin performance (#30024)
Improve the perf of the `@nx/js/typescript` plugin both in cold and warm
scenarios. The main changes done are:

- Batch some processing to do it once instead of doing it per config
file (avoids some duplicated processing)
- Use a custom TS host to read tsconfig files to reduce I/O operations
- Cache tsconfig files' reads

Benchmark results in a repo with 656 TS projects:

```
# Before the changes

Cold (NX_CACHE_PROJECT_GRAPH=false): ~2285 ms
Warm (NX_CACHE_PROJECT_GRAPH=true): ~2142 ms

# After the changes

Cold (NX_CACHE_PROJECT_GRAPH=false): ~597 ms
Warm (NX_CACHE_PROJECT_GRAPH=true): ~220 ms
```

Note: Once https://github.com/nrwl/nx/pull/29935 is merged. I'll send
another change to batch the file hashes.

## Current Behavior

## Expected Behavior

## Related Issue(s)

Fixes #
2025-02-13 14:26:38 -05:00
Leosvel Pérez Espinosa
713b9fbaaf
feat(linter): add runtimeHelpers option to @nx/dependency-checks rule (#29954) 2025-02-11 15:30:07 +04:00
Emily Xiong
540aeff488
fix(js): allow publishable library to run release command (#29775)
<!-- 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 -->
- there is no option `fallbackCurrentVersionResolver: 'disk',`
- can't run release for newly created publishable libraries

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
- move code to add release for publishable libraries into its own file
to be reused by other stacks
- add `fallbackCurrentVersionResolver: 'disk',` to project's
release.version. generatorOptions

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

Fixes https://github.com/nrwl/nx/issues/29723
2025-02-10 14:02:15 -05:00
Nicholas Cunningham
29e5ce2963
fix(nextjs): enhance support for custom server with SWC configuration (#29895)
This pull request contains a few changes to enhance our swc support for
Next.js with a custom server.

### Issues
Currently, we have a few issues with our configuration when using
executors for Next.js with a custom server:

1. The custom server does not have an independent build configuration.
2. The custom server does not have an independent output directory.
3. Serving via `@nx/next-server` or via `@nx/js:node` with
configurations `production` and `development` does not always work.
(These are contained inside `project.json`).

### Changes
All the above issues have been addressed

1. We now have an independent swc build configuration
called`.server.swrc` (_follows the same format as `.eslintrc`,
`.babelrc`_) etc...
2. Now each custom server output will be named `{app}-server` such that
if you have multiple custom servers for multiple apps the names will not
clash.
3. Serving now works out of the box but can be adjusted to suit your
needs via updating the custom server entry file `main.ts`
2025-02-06 11:34:32 -07:00
Jack Hsu
0944e34be4
fix(js): set --ws=false when running npm config for jest e2e (#29887)
When we run inferred Jest tasks with workspaces enabled, it'll result in
an error like this:

```
npm ERR! A complete log of this run can be found in: /Users/jack/.npm/_logs/2025-02-05T13_41_51_079Z-debug-0.log
Error: Command failed: npm config set //localhost:4873/:_authToken "secretVerdaccioToken"
npm ERR! code ENOWORKSPACES
npm ERR! This command does not support workspaces.
```

This is because the cwd is the project root (e.g. `packages/mypkg-e2e`),
and `npm config set` cannot be run on packages inside the workspaces. By
passing `--ws=false`, it'll only be run in the workspace root and won't
error.

## Current Behavior
Jest e2e tests inferred from `@nx/jest/plugin` fail when starting a
local registry.

## Expected Behavior
Jest e2e tests should work even if they are inferred (or have cwd other
than workspace root).

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

Fixes #
2025-02-05 11:46:50 -05:00
Leosvel Pérez Espinosa
c7ff6d358d
fix(js): do not infer tsc tasks with verbose output by default (#29804)
## Current Behavior

The `@nx/js/typescript` plugin infers tasks with `--verbose`. This can
prevent users from running the same task with `--clean.` It can also
produce a lot of logs that might not be too relevant.

## Expected Behavior

The `@nx/js/typescript` plugin should not infer tasks with `--verbose`.
This is more aligned with other tools.

A new plugin option `verboseOutput` is added to allow inferring all
tasks with `--verbose` if desired.

Note: This revealed that some things were working (e.g., `dependsOn`)
because all the `typecheck` commands inferred by the different plugins
matched. As soon as the command is different, the different inferred
tasks are not merged, which is expected. We shouldn't rely on that, and
each plugin inferring the task should set the right options/metadata.
The different plugins were updated in this PR accordingly (they don't
have the verbose option).

We'll follow up on this later, so only the `@nx/js/typescript` plugin
infers the `typecheck` task. This is a breaking change so it will be for
Nx v21.

## Related Issue(s)

Fixes #28677
2025-01-30 14:19:06 +01:00
Ashley Hunter
567a3f7ce7
fix(js): ensure js library creation respects skipFormat (#28831)
<!-- 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 -->
If I set `skipFormat` to `true` when creating a JS library with the
rollup bundler, formatting is still run during the rollup configuration
creation step.

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
`skipFormat` flag should be respected.

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

Fixes #
2025-01-28 11:56:36 -05:00
ilovemoon
4100515e78
chore(js): update dep babel-plugin-macros to ^3.1.0 (#28649)
<!-- 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 -->

```bash
@coreproject-moe/monorepo@ /home/moonlitgrace/Projects/coreproject-monorepo
├─┬ @coreproject-moe/icons@0.0.65 -> ./packages/icons
│ └─┬ jest-config@29.7.0
│   └─┬ jest-circus@29.7.0
│     └─┬ dedent@1.5.3
│       └── babel-plugin-macros@2.8.0 deduped invalid: "^3.1.0" from node_modules/dedent
└─┬ @nx/js@20.0.5
  └── babel-plugin-macros@2.8.0
```

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

No conflicts, without overriding `package.json`

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

Fixes #28620
2025-01-27 10:20:29 +00:00
Leosvel Pérez Espinosa
86798a286e
fix(testing): finish dev server async generator in cypress executor (#29689)
<!-- 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 -->

Running an e2e task using the `@nx/cypress:cypress` executor that starts
a dev server by running another task that uses the `@nx/js:node`
executor result in the process to hang after the e2e tests have finished
running.

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

The async generator returned by starting the dev server and consumed by
the `@nx/cypress:cypress` executor should be finished, and the
`@nx/js:node` executor should properly clean up its child process once
the generator is finished.

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

Fixes #29571
2025-01-24 10:03:10 -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
d6015613f5
feat(misc): use @swc/jest instead of ts-jest for the ts solution setup (#29718)
## Current Behavior

When using the TS solution setup and `jest` is used, `ts-jest` is used
as the transformer in most cases (except when the build compiler is
`swc`). The `ts-jest` transformer doesn't support modern module
resolutions like `nodenext` and it doesn't support TS project references
either.

## Expected Behavior

When using the TS solution setup and `jest` is used, `@swc/jest` should
be used as the transformer in cases where previously `ts-jest` was being
used and regardless of using `swc` as the build compiler.

## Related Issue(s)

Fixes #
2025-01-23 11:59:16 -05:00
Leosvel Pérez Espinosa
6d8fe5c5fe
feat(angular): support angular v19.1 (#29523)
Add support for Angular v19.1.x.
2025-01-16 16:23:12 -05:00
Leosvel Pérez Espinosa
8a6e44b788
fix(js): ignore bundler config files correctly in eslint config when using vitest in js library generator (#29649)
## Current Behavior

Generating a js library with esbuild or rollup as bundlers and vitest as
the unit test runner, results in an eslint configuration where the
bundler config file is not ignored from the `@nx/dependency-checks`
rule.

## Expected Behavior

Generating a js library with esbuild or rollup as bundlers and vitest as
the unit test runner, should result in an eslint configuration where the
bundler config file is ignored from the `@nx/dependency-checks` rule.

## Related Issue(s)

Fixes #
2025-01-16 15:51:32 +01:00
Leosvel Pérez Espinosa
ad96cc17c9
fix(js): do not generate package.json file for non-buildable js libraries in non-ts solution setup (#29646)
## Current Behavior

When generating a non-buildable js library in a workspace using the
integrated setup, a `package.json` file is generated.

## Expected Behavior

When generating a non-buildable js library in a workspace using the
integrated setup, a `package.json` file should not be generated.

## Related Issue(s)

Fixes #
2025-01-16 15:32:08 +01: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
Jack Hsu
0ae8665a88
feat(js): infer build-deps and watch-deps targets for incremental builds (#29609)
This PR adds `build-deps` and `watch-deps` targets to buildable JS
projects to help with incremental builds.

A use-case for this is if an app (e.g. Vite React app) has buildable
dependencies that need to be rebuilt when they change.

Say, you create a React app and lib as follows:

```
nx g @nx/react:app apps/react-app --bundler vite 
nx g @nx/react:lib packages/react-lib --bundler vite
```

And import `react-lib` inside the app.

```jsx
import { ReactLib } from '@acme/react-lib';
//...
return <ReactLib />
```

The user can then run:

```
nx watch-deps react-app
```

And then serve the app in another terminal:
```
nx serve react-app
```

Then whenever code is updated for a buildable dependency, it'll be
rebuilt and then reloaded in the app.
2025-01-14 16:13:43 -05:00
Jack Hsu
65e9a6b203
fix(js): non-buildable js libs specify type=module (#29620)
In the new TS solution setup, non-buildable libraries should still`type:
module`. This can lead to problem since ESM is used but the type will
default to CJS.

This PR also updates `nx sync` for TS references such that transitive
deps are not sycned by default, unless
`NX_ENABLE_TS_SYNC_TRANSITIVE_DEPENDENCIES=true` env var is setup.
Previously, the transitive deps are synced unless the env var disables
it. There isn't a good reason to enable it by default, and it is much
cleaner to not sync by default. This means that if we have libs `a`,
`b`, and `c`, where `a -> b` and `b -> c` dependency edges are formed,
then running:

```
nx sync
```

Will update `a/tsconfig.json` to contain refs to `b` but not `c`.
Whereas:

```
NX_ENABLE_TS_SYNC_TRANSITIVE_DEPENDENCIES=true nx sync
```

Will update `a/tsconfig.json` to contain refs to both `b` and `c`.

<!-- 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
`type` is missing

## Expected Behavior
`type: module` is set in `package.json`

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

Fixes #
2025-01-14 16:13:32 -05:00
Nicholas Cunningham
61815929d7
fix(js): improve error handling during SWC compilation (#29605)
Improves our error handling for swc when using `@nx/js:swc` executor

<!-- 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 -->
The executor fails to build if the workspace has a newer versions of
`@swc/cli` e.g.(`0.6.0`) is installed since it now uses stderr instead
of message to log errors.
RE: https://github.com/swc-project/pkgs/pull/53

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
The executor should pass in this scenario.


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

Fixes #29599
2025-01-13 10:20:50 -07:00
Leosvel Pérez Espinosa
a352c81876
fix(js): do not generate explicit vitest task config for a js library unless adding plugin is disabled (#29606)
<!-- 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 -->

Generating a js library with any bundler other than `vite` and with the
`vitest` test runner results in an explicit `test` task in the project
configuration.

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

Generating a js library with any bundler other than `vite` and with the
`vitest` test runner should not generate an explicit `test` task in the
project configuration. The `test` task should be inferred.

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

Fixes #
2025-01-13 17:37:20 +01:00
Leosvel Pérez Espinosa
0d5bfe3700
fix(misc): ensure all project generators add project to workspaces config (#29582)
- Update project generators to add the project to the workspaces setup
in the new TS solution setup
- Update some library generators that were not running package
installation

<!-- 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 13:32:16 -05: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
cbfc6fe97f
fix(js): update detection of ts solution setup (#29576)
Since we simplified `tsconfig.base.json`'s `compilerOptions` to not
include values that match defaults (as per Jake's feedback), the logic
to detect TS solution setup should check that `declaration` is
explicitly set to `false`, rather than that it is falsy.


Clean up PR: https://github.com/nrwl/nx/pull/29550

<!-- 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 -->
We're not detecting TS solution setup correctly

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

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

Fixes #
2025-01-09 15:50:45 -05:00
Nicholas Cunningham
a77e3ef083
fix(js): Update typescript plugin check for buildable projects (#29431)
<!-- 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 use `rootDir` to check if the project is buildable. This
might not be correct in the case where the transpiled files are inside
source.

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
It should work the for projects as long as the main / exports files are
not source files.

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

Fixes #
2025-01-09 11:03:33 -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
Leosvel Pérez Espinosa
71653dcbfe
feat(js): simplify generated tsconfig.base.json compiler options in ts solution setup (#29550)
Simplify generated `tsconfig.base.json` file in the TS solution setup by
removing compiler options set to their default values.

<!-- 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-08 18:21:50 +01:00
Leosvel Pérez Espinosa
0334dad23f
fix(js): ensure js libraries' build produce esm output in ts solution setup (#29546)
- Update js libraries for bundlers `esbuild`, `swc`, and `tsc` to
produce ESM output when using the TS solution setup.
- Fix `esbuild` and `swc` executors so they generate declaration files
even when skipping type-checking.
- Add `cjs` and `cts` to the `ignoredFiles` pattern for the rollup
config file in the eslint config.
- Ensure running an install after a js library is generated when using
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-08 18:21:39 +01:00
Leosvel Pérez Espinosa
160800e66f
fix(js): do not set project references to non-existing tsconfig files in sync generator (#29536)
<!-- 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-08 16:45:15 +01:00
Jack Hsu
df27a97c7e
fix(js): infer outputs correctly when both rootDir and outDir are set for tsconfig (#29531)
When the tsconfig has `rootDir` and `outDir` both defined, then the
`*.tsbuildinfo` file is not cached. This makes incremental tsc not work
through distribution (e.g. agents).

For example, given this `tsconfig.lib.json` file:

```json
{
  "compilerOptions": {
    "outDir": "out-tsc/lib-1",
    "rootDir": "src"
  }
}
```

The outputs (e.g. `*.d.ts` files) are under
`{projectRoot}/out-tsc/lib-1`, but the tsbuild info file is under
`{projectRoot}/out-tsc/tsconfig.lib.tsbuildinfo`.

## Current Behavior
tsbuildinfo file is not cached

## Expected Behavior
tsbuildinfo file is cached

## 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>
2025-01-07 11:17:23 -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
Bartosz Adamczyk
90e12a77af
fix(release): invalid config path in hint for using skipLockFileUpdate (#29425) 2024-12-23 19:17:11 +04:00
Emily Xiong
81c66eca73
fix(js): not generate tsconfig if already exists (#29317)
<!-- 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 -->
- in serve target, it uses executor `@nx/webpack:dev-server`
- in `packages/webpack/src/executors/dev-server/dev-server.impl.ts`,
when buildLibsFromSource is false, it calls createTmpTsConfig to create
a temp config
- in webpack.config.js, it has `module.exports =
composePlugins(withNx()`. in withNx, it calls
NxTsconfigPathsWebpackPlugin.
- when buildLibsFromSource is false, it called createTmpTsConfig again
based on the temp config. it created an infinite loop because it creates
a tsconfig that extends itself.

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
- do not create a temp config if it is a generated ts config

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

Fixes https://github.com/nrwl/nx/issues/28006
2024-12-20 13:10:06 -05:00
Nicolas Beaussart
0ebe59cda9
fix(js): handle resolution from within node_module in the sync generator (#29412)
closed #29411

<!-- 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 -->
The resolve function from ts.System returning the full path, and so
including the workspaceRoot that is also append by the FsTree

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
Resolution within node_modules are correctly followed

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

Fixes #29411
2024-12-19 15:23:24 +01: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
Emily Xiong
1d7465b02e
feat(core): not exit when one plugin installation failed (#28684)
<!-- 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 -->
it tries to install all plugins at once. if failed, it will stop the
remaining plugins from being installed.

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
it will continue if one plugin failed.

success message:
<img width="301" alt="Screenshot 2024-12-11 at 11 36 14 AM"
src="https://github.com/user-attachments/assets/2bc389f0-4fda-4959-afab-57594c9d600b">
failed message:
<img width="894" alt="Screenshot 2024-12-12 at 2 58 17 PM"
src="https://github.com/user-attachments/assets/7b51d5e9-f308-48c3-9b7d-bc4219802acb"
/>


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

Fixes #
2024-12-16 14:38:22 -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
Leosvel Pérez Espinosa
13ec93c783
fix(js): ensure typescript-sync generator produces formatted references when no prettier is installed (#29368)
<!-- 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:05 +01:00
Tine Kondo
cfb67cf124
feat(testing): allow custom address for local registry (#29050)
… output<!-- 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 -->
The `startLocalRegistry()` always assumed that the local registry was
started on `localhost` , which is not necessary the case, if for example
user has set the `listenAddress` option in the underlying `verdaccio
executor` or via the `verdaccio config
file`128778e7d1/packages/js/src/executors/verdaccio/verdaccio.impl.ts (L130)

As a result the `startLocalregistry()`, will never return as, it is
waiting forever to detect the local registry URL in the process output:
128778e7d1/packages/js/src/plugins/jest/start-local-registry.ts (L40)

This customization of `verdaccio` listen address is something required,
namely when running within a **devcontainer**. In that case, the address
must be set to `0.0.0.0`, so that the registry can be accessed from
`http://localhost:4873` from host machine.


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

Allow customizing the `listenAddress` when starting the local registry,
via an additional option that can be provided when calling the method.
It default value will be `localhost`.

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

Fixes https://github.com/nrwl/nx/issues/28238
2024-12-10 12:36:55 -05:00
Ben McCann
e3f8c813d6
fix(js): switch from fast-glob to tinyglobby (#29141) 2024-12-10 12:42:27 +04:00
Nicholas Cunningham
89ab8874b0
fix(core): Update bundlers to not typecheck if using new TS solution setup (#29227)
If we are using the new TS setup we should opt out of doing type
checking during build since we already have a typecheck target and it
may lead to doing type checking twice.
2024-12-09 10:40:43 -07:00