110 Commits

Author SHA1 Message Date
Colum Ferry
0857492c93
fix(vite): set NODE_ENV to production correctly #28584 (#28663)
<!-- 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 -->
After the switch to use `resolveConfig` we failed to set the value for
`NODE_ENV` which is an argument to the function.
This means it always defaulted to development.


## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
Ensure `NODE_ENV` is set as expected.

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

Fixes #28584
2024-10-28 13:43:53 +00:00
Colum Ferry
f9f3de06d0
fix(vite): use resolveConfig instead of loadConfigFromFile to ensure node env set #27627 (#28444)
<!-- 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 the Vite Build Executor, we're using `loadConfigFromFile` from Vite
to get the config options.
The issue with this is that vite will not attempt to set `NODE_ENV`
which may be required by both the config file that is being loaded, and
other plugins.


## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
Use resolveConfig which does set NODE_ENV correctly


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

Fixes #27627
2024-10-17 12:26:34 -04:00
Ali Yusuf
2546082852
fix(vite): exit from test if no files found (#27722)
<!-- 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
After running `nx test project` or `nx run-many -t test` with no test
files with `@nx/vite:test` plugin, vitest process exit directly but nx
reporter keep waiting for finish notification which cause to waiting
indefinitely.

vitest reference:

https://github.com/vitest-dev/vitest/blob/main/packages/vitest/src/node/core.ts#L409-L413

https://github.com/vitest-dev/vitest/blob/main/packages/vitest/src/node/cli/cli-api.ts#L102-L116

console log example:
```bash
nx test project

> nx run project:test


 RUN  v2.0.5 /path/to/project

include: src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}
exclude:  **/node_modules/**, **/dist/**, **/cypress/**, **/.{idea,git,cache,output,temp}/**, **/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*
No test files found, exiting with code 0
```

```bash
nx run-many -t test --no-cache -p project

 NX   Running target test for project project

      With additional flags:
        --cache=false

   →  Executing 1/1 remaining tasks...

   ⠹  nx run project:test
```

## Expected Behavior
`nx test project` should exit directly in case vitest process exit
early.

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

Fixes #
2024-09-16 16:23:33 +01: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
58cd577f2c
fix(vite): vitest executor should continue to load plugins #22001 (#27118)
<!-- 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 -->
Plugins were not being loaded by vitest executor when calling
`startVitest` when using a vite config file with a custom name.

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
Correctly load the plugins found in the resolved config file, regardless
of the config file name


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

Fixes #22001
2024-07-25 15:48:19 +00:00
Colum Ferry
db7cb5de48
fix(vite): respect existing package.json type #27057 (#27084)
<!-- 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 `@nx/vite:build` executor is always overwriting the
`packageJson.type` field when generating a packageJson.


## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
The `@nx/vite:build` executor should respect the existing type in
packageJson

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

Fixes #27057
2024-07-24 08:29:45 -04:00
Colum Ferry
8cf69c4b9a
fix(vite): typecheck vue projects with vue-tsc #20242 (#26450)
<!-- 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 -->
Typechecking of  Vue Projects with Vite is not functioning correctly

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
Typechecking of Vue projects should type check the .vue files and not
error in TS files importing .vue files

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

Fixes #20242
2024-07-22 17:52:59 +01:00
Colum Ferry
0327559ca4
fix(vite): ensure typecheck is using correct tsconfig #21844 (#26447)
<!-- 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 -->
When running typecheck, we use the provided tsconfig or find the
projects tsconfig.
This doesn't take into consideration the buildLibsFromSource which
creates a tmp tsconfig to map buildable libraries.


## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
Ensure the correct tsconfig is used when running typecheck

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

Fixes #21844
2024-06-10 12:56:19 -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
Thomas Dekiere
637a00469e
fix(vite): pass cli arguments as options to vitest (#22355) 2024-04-12 10:28:08 +01:00
Noriyuki Shinpuku
54d47805de
chore(vite): revert comment about closeAllConnections (#21634) 2024-03-22 18:40:08 -04:00
Katerina Skroumpelou
00dae6a811
fix(vite): update vitest and use parseCLI (#21890) 2024-02-22 11:03:08 -05:00
Leosvel Pérez Espinosa
077debe2b2
fix(vite): normalize vitest cli args in executor (#21870) 2024-02-19 17:28:05 +01:00
Craigory Coppola
deb0f1a492
chore(repo): bump deprecation messages to v19 (#21430) 2024-01-30 16:29:05 -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
Vinit Neogi
85b3a5f3b9
fix(vite): prevent vite:build copying package.json when generatePackageJson false (#19780) 2024-01-30 16:13:33 +02:00
Julien Simonet
ea3c2426d3
fix(js): ensure result is valid before attempting to close it during rollup watch 2024-01-17 12:35:21 -05:00
Katerina Skroumpelou
7da53c026e
fix(vite): replaceFile and fileReplacement fixes (#21077) 2024-01-10 18:53:34 +02:00
Katerina Skroumpelou
c79377e735
fix(vite): only import vite dynamically (#21050) 2024-01-09 15:48:32 +01:00
Katerina Skroumpelou
ce81133162
fix(vite): build executor watch (#21042) 2024-01-08 20:46:02 +02:00
Katerina Skroumpelou
dd44ad9778
fix(vite): more properly resolve arguments from configurations (#20825) 2023-12-19 17:36:16 +02:00
Katerina Skroumpelou
de0d238e13
fix(vite): vitest migration add reporters (#20823) 2023-12-18 17:54:58 +02:00
Katerina Skroumpelou
7641f73278
fix(vite): only dynamically import vite (#20774) 2023-12-15 15:24:05 +02:00
Katerina Skroumpelou
d36f313776
fix(vite): ignore CJS build deprecated warning (#20719) 2023-12-12 16:29:13 +02:00
Katerina Skroumpelou
5b4305819b
fix(vite): better extra args resolution (#20708) 2023-12-12 15:43:56 +02:00
Katerina Skroumpelou
2c88282e8a
fix(vite): adjust config generation (#20367) 2023-11-29 15:58:49 +02:00
Katerina Skroumpelou
82b39d1f86
feat(vite): update to version 5 (#20341) 2023-11-21 09:45:21 -05:00
Katerina Skroumpelou
34552539fe
fix(vite): vitest should use v8 as default (#20156) 2023-11-10 13:07:33 +00:00
Craigory Coppola
d899abe7f4
fix(vite): remove process.send call (#20171) 2023-11-09 21:16:01 -05:00
Jason Jean
a86d926612
feat(testing): add cypress create nodes plugin (#19840) 2023-11-09 14:05:19 -05:00
Katerina Skroumpelou
f1f0f15f0a
fix(vite): throw informative error if no vitest config exists (#19819) 2023-10-24 09:07:39 -04:00
Jack Hsu
1899a9ee35
feat(vite): future-proof Vite plugin to support ESM-only version of Vite (#19533) 2023-10-11 10:49:21 -04:00
Craigory Coppola
b222933417
chore(bundling): pass full context to parseTargetString (#19157) 2023-09-20 09:07:08 -04:00
Craigory Coppola
353d8d089d
cleanup(core): move js lockfile parsing to v2 plugin (#18779) 2023-08-30 14:26:41 -04:00
Emily Xiong
9d5a3830be
feat(misc): remove dotenv from executors (#18719) 2023-08-22 20:00:37 -04:00
Katerina Skroumpelou
ff04be5188
fix(vite): default vitest provider to v8 (#18515) 2023-08-08 10:46:10 +03:00
Caleb Ukle
6529be96cf
feat(vite): add tsconfig paths resolution plugin (#17844) 2023-07-17 15:42:12 +00:00
Leosvel Pérez Espinosa
95a2256a34
feat(misc): deprecate executor options to generate package.json for libraries (#17923) 2023-07-11 15:28:03 +00: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
Katerina Skroumpelou
899240046b
fix(vite): properly find projectRoot (#17517) 2023-06-09 09:07:32 -06: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
Caleb Ukle
ca38a2390b
fix(testing): resolve full paths to vite configs for vitest (#17396) 2023-06-02 16:32:32 -05:00
Katerina Skroumpelou
636b9115e9
feat(vite): add cssCodeSplit in build options (#17213) 2023-05-25 14:07:51 +00:00
Katerina Skroumpelou
9fc99c6c18
fix(vite): register tsconfig paths for vitest (#17047) 2023-05-18 11:13:02 -04:00
Emily Xiong
e8c31d7ac7
fix(react): fix react windows e2e tests (#16959) 2023-05-12 11:09:46 +03:00