64 Commits

Author SHA1 Message Date
Jack Hsu
8fa7065cf1
docs(misc): update generator examples to use new directory/path positional args (#28144)
This PR updates examples in `.md` files (both docs and blog posts) to
use positional args. Nx 20 changes the position arg to be either
`directory` for apps/libs or `path` for artifacts (e.g. components).

So before you'd do this:

```
nx g app myapp --directory=apps/myapp
nx g lib mylib --directory=libs/mylib
nx g lib mylib --directory=libs/nested/mylib
nx g lib @acme/foo --directory=libs/@acme/foo --importPath=@acme/foo
nx g component foo --directory=libs/ui/src/foo --pascalCaseFiles
```

Will now be simplified to

```
nx g app apps/myapp
nx g lib libs/mylib
nx g lib libs/nested/mylib
nx g lib libs/@acme/foo # name and import path are both "@acme/foo"
nx g component libs/ui/src/foo/Foo
```

For cases where `name` and `importPath` need to be changed, you can
always manually specify them.

```
nx g lib libs/nested/foo # name is foo
nx g lib libs/nested/foo --name=nested-foo # specify name with prefix
nx g lib libs/@acme/foo --name # use "foo" as name and don't match importPath
nx g lib libs/@internal/foo --importPath=@acme/foo # different importPath from name

<!-- 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-09-30 13:20:10 -04:00
Jack Hsu
85877e3e18
feat(react): make vitest the default test runner since it supports ESM and different moduleResolution better (#28153)
This PR updates the default test runner for React/Web apps to be
`vitest`. It aligned better with our emphasis on modern tooling, and the
lack of ESM and proper TS support (using `module` other than `commonjs`)
in Jest makes it hard to use in some workspaces.

<!-- 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-09-30 09:00:01 -04:00
Leosvel Pérez Espinosa
d454f25aad
feat(testing): update test generators to exclude test files from the runtime tsconfig file (#27991)
<!-- 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-09-23 09:25:12 -04:00
Jack Hsu
042049c785
feat(js): generate package.json with overrides and resolutions (#27601)
This PR ensures that `overrides` and `resolutions` are in the generated
package.json file as well. If they are missing, then using
`--frozen-lockfile` will fail due to mismatched overrides in the
lockfile.

Also adds a `skipOverrides` flag to the affected executors and plugins
-- same as `skipPackageManger` that was added previously.

Affected executors/plugins:
- `@nx/vite:build`
- `@nx/webpack:webpack`
- `@nx/remix:build`
- `@nx/next:build`
- `NxAppWebpackPlugin`


<!-- 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 #26884
2024-08-22 17:21:49 -04:00
Jack Hsu
83237a8670
feat(js): add skipPackageManager option to build executors in order to skip generating "packageManager" entry in package.json (#27518)
This PR adds `skipPackageManager` option to several build executors in
order to disable generating the `packageManager` field in the resulting
`package.json` file. This field may be problematic on different
platforms so we want a way to work around it.

Affected executors:
- `@nx/webpack:webpack`
- `@nx/vite:build`
- `@nx/next:build`
- `@nx/remix:build`




<!-- 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 #27027
2024-08-20 09:18:30 -04:00
Jack Hsu
402bae2ce1
fix(vite): load the correct config file from @nx/vite:test executor (#27514)
This PR ensures that we pass Vite config file to the programmatic
`startTest` API from Vitest. It fixes the issue with plugins not loading
as well as other issues with the config file not being used.

This mainly affects a custom `configFile` option being passed to the
executor. The previous fix to additionally load in `plugins` via
overrides is causing plugins to load twice when the Vite config file is
picked up by Vitest (e.g. #27500).

## 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 #27500, #22001
2024-08-19 14:08:29 -04:00
Colum Ferry
b36c39e331
feat(vite): add convert-to-inferred migration generator (#26249)
- feat(vite): add convert-to-inferred generator for migrating to
inference
- feat(vite): add build postTargetTransformer
- feat(vite): add serve, preview, test postTargetTransformer
- feat(vite): convert-to-inferred should clean up inputs and outputs
- docs(vite): add convert-to-inferred
- feat(vite): update outDir correctly

<!-- 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` -->

## Current Behavior
<!-- This is the behavior we have today -->
There is currently no generator that can migrate projects that use
`@nx/vite:*` executors to use Inference plugins.

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
Add `@nx/vite:convert-to-inferred` generator

## 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>
2024-06-14 14:53:25 -04:00
Jack Hsu
4a5eb23302
fix(bundling): vite init generator supports updating vite projects to use workspace libraries (#26503)
This PR adds a `@nx/vite:setup-paths-plugin` generator to add
`nxViteTsPaths` plugin to all vite config files in the workspace. This
can also be used with init/add as follows:

```shell
nx add @nx/vite --setupPathsPlugin
nx g @nx/vite:init --setupPathsPlugin
```

Which takes a config such as:

```ts
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'

export default defineConfig({
  plugins: [react()],
})
```

And updates it to:

```ts
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';

export default defineConfig({
  plugins: [react(), nxViteTsPaths()],
})
```

Taking into account ESM (default) and CJS (deprecated).

<!-- 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` -->

## 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-06-11 16:55:58 -04:00
Leosvel Pérez Espinosa
2b820a274e
docs(misc): update /packages/ links to /nx-api/ (#26128)
- Update `/packages/` links to `/nx-api/`
- Convert some unneeded absolute links to relative
- Remove leftover examples doc for the already removed `cypress-project`
generator

<!-- 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` -->

## 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 #26126
2024-05-28 09:44:48 -04:00
Leosvel Pérez Espinosa
6576325f7b
docs(misc): fix misc issues (#22039)
Co-authored-by: Isaac Mann <isaacplmann@users.noreply.github.com>
2024-02-28 10:02:27 -05:00
Katerina Skroumpelou
00dae6a811
fix(vite): update vitest and use parseCLI (#21890) 2024-02-22 11:03:08 -05:00
Katerina Skroumpelou
fe17fc3287
fix(vite): project conversion generator (#21646) 2024-02-20 16:38:12 +02:00
Miroslav Jonaš
3ead01987b
fix(nx-dev): remove fence from new packages and "nx add" commands (#21705) 2024-02-08 14:43:50 +01:00
Isaac Mann
61436a64ef
docs(core): inferred targets (#21167)
Co-authored-by: Katerina Skroumpelou <mandarini@users.noreply.github.com>
Co-authored-by: Colum Ferry <cferry09@gmail.com>
Co-authored-by: Emily Xiong <xiongemi@gmail.com>
Co-authored-by: Nicholas Cunningham <ndcunningham@gmail.com>
Co-authored-by: Jason Jean <jasonjean1993@gmail.com>
Co-authored-by: Victor Savkin <mail@vsavkin.com>
Co-authored-by: Jack Hsu <jack.hsu@gmail.com>
2024-02-03 00:14:05 -05:00
Jason Jean
396ffc4636
feat(core): enable project crystal by default (#21403)
Co-authored-by: Katerina Skroumpelou <sk.katherine@gmail.com>
Co-authored-by: Jack Hsu <jack.hsu@gmail.com>
Co-authored-by: Colum Ferry <cferry09@gmail.com>
Co-authored-by: Leosvel Pérez Espinosa <leosvel.perez.espinosa@gmail.com>
Co-authored-by: Emily Xiong <xiongemi@gmail.com>
Co-authored-by: Nicholas Cunningham <ndcunningham@gmail.com>
2024-02-02 03:40:59 -05:00
beeman
a9974d3f25
docs(misc): change http:// to https:// (#19534) 2024-01-30 11:33:13 -05:00
Vinit Neogi
d147604c7f
feat(vite): allow passing path to custom tsconfig file when skipTypeCheck is false (#19784) 2024-01-30 16:14:53 +02:00
Leosvel Pérez Espinosa
e4758358b0
feat(misc): optionally update package.json scripts in init generators (#21204) 2024-01-22 13:51:41 -05:00
Aditya Mathur
dd5f3c8d17
docs(misc): standardize all the install commands with different pm (#21226) 2024-01-19 15:21:42 +01:00
Emily Xiong
6141f44203
feat(core): add keepExistingVersions to all packages (#21169) 2024-01-17 14:22:58 -05:00
Leosvel Pérez Espinosa
047dc22aed
cleanup(misc): clean up init generators (#21088) 2024-01-16 15:29:44 +01:00
Katerina Skroumpelou
7da53c026e
fix(vite): replaceFile and fileReplacement fixes (#21077) 2024-01-10 18:53:34 +02:00
Katerina Skroumpelou
679db5d584
fix(vite): config migration account for other syntaxes (#20693) 2023-12-11 11:52:27 -05:00
Katerina Skroumpelou
2c88282e8a
fix(vite): adjust config generation (#20367) 2023-11-29 15:58:49 +02:00
Juri
54eab7f8b1 docs(vite): remove webcomponents setup and adjust some wording 2023-11-28 18:05:51 +01:00
Katerina Skroumpelou
34552539fe
fix(vite): vitest should use v8 as default (#20156) 2023-11-10 13:07:33 +00:00
Isaac Mann
d1fe398ea0
docs(core): packages to api (#19281) 2023-09-22 14:24:35 -04:00
Isaac Mann
4f3988cb2c
docs(core): sync nx package versions (#18973) 2023-09-08 08:25:19 -04:00
Isaac Mann
1ac034ba60 docs(core): move package recipes 2023-08-25 14:32:13 +02:00
Mike Gregson
36dae70fb0
feat(vite): add v8 coverage support to vitest generator (#18114) 2023-07-27 12:49:56 -05:00
Julius Osokinas
6bf3dc91ad
feat(vite): server executor https prop as object (#18048)
Co-authored-by: Julius Osokinas <julius.osokinas@kevin.eu>
2023-07-10 13:42:59 +03:00
Joe Walton
a995940b19
feat(vite): allow passing multiple test files to vite:test (#17496)
Co-authored-by: Caleb Ukle <caleb.ukle+github@pm.me>
2023-06-26 15:31:04 -05:00
Jack Hsu
8d5ef222cc
feat(testing): add support for additional environment options when generating vite config (#17560) 2023-06-13 13:30:52 -04:00
Luca Becker
26e3e16cb9
chore(vite): remove typo in the comment / documentation (#17488) 2023-06-08 09:54:47 -04:00
Katerina Skroumpelou
b953565bc2
feat(vite): add type check to vite builder (#17487) 2023-06-08 15:57:51 +03:00
Vinícius Neto
a9f8cc61fa
feat(vite): add incremental builds support to Vite plugin build executor (#17433)
Co-authored-by: Katerina Skroumpelou <sk.katherine@gmail.com>
2023-06-08 10:07:57 +03:00
Emily Xiong
631a948ded
feat(react): add swc as compiler option for react vite (#17224) 2023-05-30 14:06:50 -04:00
Katerina Skroumpelou
636b9115e9
feat(vite): add cssCodeSplit in build options (#17213) 2023-05-25 14:07:51 +00:00
Caleb Ukle
ad841c9048
docs(repo): update docs/schemas to use nx scoped packages - nx labs (#16865) 2023-05-09 08:30:52 -05:00
Joe Walton
402a00f841
feat(vite): add option to generate a package.json to build executor (#16428) 2023-05-08 17:43:10 +03:00
Isaac Mann
afa5eb59fa
docs(core): document the @nrwl => @nx rescope (#16403)
Co-authored-by: FrozenPandaz <jasonjean1993@gmail.com>
2023-04-27 18:14:59 -04:00
Katerina Skroumpelou
44654251bd
feat(vite): allow setting of build target (#16588) 2023-04-26 16:26:26 -04:00
Liam McAteer
83ada9dcc1
feat(vite): add --testFile argument to @nrwl/vite:test (#16324)
Co-authored-by: Liam McAteer <=>
2023-04-26 15:11:14 -05:00
Leosvel Pérez Espinosa
4eb7cc7bf1
fix(misc): skip formatting files in nested generator calls (#15961) 2023-03-31 11:22:18 -04:00
Katerina Skroumpelou
8e838b5aac
fix(vite): configuration docs and optional chain targets (#15655) 2023-03-14 19:56:04 +02:00
Ethan Pursley
ae6dc6b91d
fix(vite): add configuration option for emptyOutDir (#15619) 2023-03-13 11:53:24 +02:00
Katerina Skroumpelou
ceb6ff346d
docs(vite): fix example for dts plugin (#15190) 2023-02-23 10:07:23 -05:00
Katerina Skroumpelou
bff786962b
fix(vite): set root and path on dts plugin (#14964) 2023-02-14 12:08:46 +00:00
Dmitriy Stepanenko
2f9978f4d3
feat(vite): be able to use a custom build target for the preview server (#14951) 2023-02-13 13:44:53 +02:00
Chau Tran
259d4b29cf
fix(vite): fix watch schema for build executor to object or boolean i… (#14756) 2023-02-02 15:58:37 +00:00