42 Commits

Author SHA1 Message Date
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
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
aec53a0406
feat(misc): remove handling of @nrwl scope (#28589)
This PR removes logic where we handle both `@nx/` and `@nrwl/` scope.
The latter scope has stopped being published in v20, and are no longer
relevant.

- Cleans up e2e
- Removes references to `@nrwl/` scope in our generators and executors
- Removes `@nrwl/` from `nx/package.json` `packageGroup`
- Cleans up documentation quality script
2024-10-29 11:04:44 -04:00
Jack Hsu
e71e2f3da8
Revert "feat(core): add shutdown lifecycle hook to node executor" (#27794)
Reverts nrwl/nx#27354

This patch is causing issues that are more serious than what it fixes.
2024-09-06 10:55:47 -04:00
Jack Hsu
d1c901df1e
fix(js): respect "watch" option when "runBuildTargetDependencies" is true (#27677)
This PR fixes and issue when `watch: false` and
`runBuildTargetDependencies: true` results in the server process
restarting, but no build happens.

<!-- 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 #20963
2024-08-28 14:09:45 -04:00
Wei Liang
b5a93364c5
feat(core): add shutdown lifecycle hook to node executor (#27354)
<!-- 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 -->
When the application are received a shutdown signal, the application
doesn't execute before shutdown functions and directly shutdown whole
application. The situation cannot execute before shutdown functions like
[NestJS Lifecycle
Events](https://docs.nestjs.com/fundamentals/lifecycle-events) and
custom shutdown hooks.

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
The application can run shutdown hooks like below output:

 NX   Successfully ran target build for project nest-test (5s)

Debugger listening on
ws://localhost:9229/e4bd44c0-9a6a-468a-8b46-b6fef1cef1c7
For help, see: https://nodejs.org/en/docs/inspector

```
 NX   Successfully ran target build for project nest-test (4s)

Debugger listening on ws://localhost:9229/75c8449b-43a4-4d8b-88c0-231761d7248c
For help, see: https://nodejs.org/en/docs/inspector

To exit the process with SIGINT, press Ctrl+C
[Nest] 393107  - 08/09/2024, 6:31:26 PM     LOG [NestFactory] Starting Nest application...
[Nest] 393107  - 08/09/2024, 6:31:26 PM     LOG [InstanceLoader] AppModule dependencies initialized +10ms
[Nest] 393107  - 08/09/2024, 6:31:26 PM     LOG [RoutesResolver] AppController {/api}: +7ms
[Nest] 393107  - 08/09/2024, 6:31:26 PM     LOG [RouterExplorer] Mapped {/api, GET} route +3ms
[Nest] 393107  - 08/09/2024, 6:31:26 PM     LOG [NestApplication] Nest application successfully started +2ms
[Nest] 393107  - 08/09/2024, 6:31:26 PM     LOG 🚀 Application is running on: http://localhost:3000/api
[Nest] 393107  - 08/09/2024, 6:31:29 PM     LOG onModuleDestroy
onModuleDestroy: 5.001s
[Nest] 393107  - 08/09/2024, 6:31:34 PM     LOG beforeApplicationShutdown SIGINT
beforeApplicationShutdown: 5.004s
[Nest] 393107  - 08/09/2024, 6:31:39 PM     LOG onApplicationShutdown SIGINT
onApplicationShutdown: 5.005s

 NX  Process exited with code 130, waiting for changes to restart...
```

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

Fixes #9237 and #18037

---------

Co-authored-by: Jack Hsu <jack.hsu@gmail.com>
2024-08-16 14:23:18 -04:00
LongYinan
981eb30a0f
feat(core): support compile to wasi target (#22870)
This pull request is trying to add wasm32-wasi target support for the
nx/native

To test the build, you can run the following commands:

- `rustup target add wasm32-wasip1-threads`
- `pnpm exec napi build --release --platform --package-json-path
packages/nx/package.json --manifest-path packages/nx/Cargo.toml --js
./native-bindings.js -o packages/nx/src/native --target
wasm32-wasip1-threads`

And the wasm file will be built at
packages/nx/src/native/nx.wasm32-wasi.wasm

Blocked by:

- Support @napi-rs/cli 3.0  Cammisuli/monodon#48
- https://github.com/napi-rs/napi-rs/issues/2009

The pseudo_terminal mod is excluded on the wasm32 targets, which is as
expected.

The watch mod is excluded because of the upstream `watchexec` deps
introduced by ignore-files don't support the wasi target at this moment
(but we can improve it).

## Related Issues
Fixes https://github.com/nrwl/nx/issues/21860
Fixes https://github.com/nrwl/nx/issues/23821

---------

Co-authored-by: FrozenPandaz <jasonjean1993@gmail.com>
2024-07-05 15:55:35 -04:00
Maciej Łyskawiński
5245bedc41
fix(js): node executor now correctly kills tasks when exiting (#19219)
Previously, the node executor od @nx/js did not kill spawned processes
due to not awaiting finishing of killing and infinite loop.
This fix allows for seemless running nx in docker containers with
support for signals

<!-- 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
When killing nx running `@nx/js:node`, child processes are not killed

## Expected Behavior
Child processes should be killed
2024-06-28 12:36:40 -04:00
Nicholas Cunningham
1f6aba03a1
fix(js): Correct file path for cjs.js (#23081) 2024-04-29 19:54:09 +00:00
Nicholas Cunningham
c27a668530
fix(webpack): Should work when absolute paths are supplied as output (#22736) 2024-04-09 09:27:10 -06:00
Jack Hsu
a9e554ff79
fix(js): propagate error from child process to @nx/js:node executor (#22705) 2024-04-05 17:45:04 -04:00
Craigory Coppola
3069f3e165
chore(js): pass full context to parseTargetString (#19136) 2023-09-20 09:08:10 -04:00
Jack Hsu
d63d3573c4
feat(js): add generateExportsField and additionalEntryPoints options to update exports field when building with tsc/swc (#18319) 2023-08-01 09:23:48 -06:00
Jack Hsu
661efa913d
feat(bundling): generate matching d.ts files for rollup (#18342) 2023-07-28 09:04:26 +02:00
Leosvel Pérez Espinosa
ca5e673a80
feat(misc): add alternative implementation to calculate buildable dependencies using the task graph (#18125) 2023-07-19 15:11:13 -04:00
Jack Hsu
e2c0abc1a7
fix(js): run build in watch mode when specified for faster recompile time (#18145) 2023-07-17 14:48:32 -04:00
Jack Hsu
c6a0615fa5
fix(js): add watchIgnore and runBuildTargetDependencies options to speed up build (#17953) 2023-07-05 14:50:53 -04:00
Denis Frenademetz
47d23c8436
fix(js): js:node executor resolves main.js and build options correctly (#17884)
Co-authored-by: Katerina Skroumpelou <sk.katherine@gmail.com>
2023-07-05 10:10:15 +00:00
Jack Hsu
b7d283bced
fix(js): skip watcher if --watch=false for node executor (#17887) 2023-06-30 15:10:24 -04:00
Nicholas Cunningham
bd7157bb83
fix(nextjs): Custom server should run on fresh apps without errors (#17806) 2023-06-27 16:33:04 +00:00
Colum Ferry
fffd84c3aa
fix(react): ssr should serve correctly and e2e should function (#17725) 2023-06-22 14:51:41 +01:00
Katerina Skroumpelou
36838d6211
fix(js): node executor should always log error (#17622) 2023-06-16 16:45:05 +00:00
Jack Hsu
35ed04741d
fix(js): add support for waitUntilTargets back (#17553) 2023-06-12 09:38:47 -05:00
Nicholas Cunningham
478fb8ba56
fix(js): Ensure runTimeArgs are not ignored (#17527) 2023-06-12 08:28:38 -06:00
Katerina Skroumpelou
417ac38759
fix(js): dont ignore args option on node executor (#17463) 2023-06-07 18:15:53 +03:00
Katerina Skroumpelou
392366f0fd
fix(js): pass buildTargetOptions in executor (#17459) 2023-06-07 08:12:00 -04:00
Nicholas Cunningham
8f771e023b
fix(node): When serving using js:node executor NODE_ENV should not be undefined (#17375) 2023-06-02 13:56:40 -04:00
Craigory Coppola
f01cdca79d
fix(js): sourcemaps should work with js:node executor (#17261) 2023-05-29 11:08:11 -04:00
Jack Hsu
dc7122984e
feat(js): improve @nx/js:node executor to be more resilient to many file change events (#16924) 2023-05-11 16:31:52 -04:00
Jason Jean
2d195007b0
feat(core): switch packages to use the @nx scope (#16069) 2023-04-14 19:56:37 -04:00
Colum Ferry
361ddb1b0f
feat(js): move buildable libs to js (#15558) 2023-03-09 16:36:50 -05:00
William Sedlacek
8700c8674e
fix(js): unique hash for each execution (#14154) 2023-01-09 11:56:22 -05:00
Craigory Coppola
285dc39371
feat(core): support targets with colons in the name without quotes (#13938) 2022-12-28 15:18:07 -05:00
Sahil Purav
4c5a139a42
fix(js): node executor address already in use (#14023) 2022-12-27 12:14:33 -05:00
William Sedlacek
82d44adfb4
fix(js): unique node execution (#13813) 2022-12-14 10:25:57 -05:00
Jack Hsu
dda9ea1f87
feat(bundling): remove deprecated UMD format support for rollup (#12426) 2022-10-05 22:44:06 -04:00
Craigory Coppola
6948ffdcff fix(core): project graph should be read from executor context
These changes lower the risk of reading the cache during a write operation when multiple
processes are actively writing / reading the cache.
2022-08-19 12:50:07 -04:00
Jack Hsu
e45c2f24ba
feat(nextjs): improve support for custom server (#11325)
- Add new generator for custom server
- Add @nrwl/js:node executor for serving custom server
- Deprecate @nrwl/node:node in favor of the above
2022-08-02 18:37:23 +00:00
Jack Hsu
95f5a085fa
feat(node): consolidate js and node plugins (#9086)
* chore(node): update docs after consolidating js and node plugins

* feat(node): consolidate js and node plugins
2022-02-23 16:59:03 -05:00
Jack Hsu
4070eaec15
feat(js): improve watch mode support for tsc and swc builds (#8502) 2022-01-19 11:37:04 -05:00
Jack Merrill
931ba3a115
fix(js): fix npm module resolving (#8316) (#8352)
* fix(js): fix npm module resolving (#8316)

* fix(js): add secondary npm module check

(nrwl#8316)
2022-01-14 10:33:33 -06:00
Chau Tran
1139c616e1 feat(js): add nrwl/js:node executor to serve node apps 2021-12-22 10:33:02 -05:00