79 Commits

Author SHA1 Message Date
Nicholas Cunningham
ce05a98476
fix(nextjs): Add deprecation message for svgr (#28705)
<!-- 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, if you are using Next.js 15 have SVGR enabled via `WithNx`
and are using turbopack. You could potentially have issues loading your
svg. This happens because of how webpack imports svg and not having an
additional configuration for turbopack (currently it is under the
experimental option).

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
Moving forward, we can call this out and deprecate the option to be
removed in Nx 21. As such should you need to use SVGs it is recommended
to do so manually. Something similar to [this
comment](https://github.com/vercel/turborepo/issues/4832#issuecomment-1751407444).

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

Fixes #
2024-10-30 18:52:18 -06:00
Nicholas Cunningham
faf448379d
fix(nextjs): Remove deprecated export executor (#28702)
<!-- 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-10-30 18:10:47 -06:00
Jack Hsu
81892b51fd
feat(misc)!: handle v20 deprecations in plugins (#28222)
This PR removes these from v20 since they were deprecated and slated for
removal:

- `executeWebpackDevServerBuilder` export from `@nx/angular/executors`,
users should use `executeDevServerBuilder`
- `withStylus` util from `@nx/next/plugins/with-stylus` since it was
deprecated in v17 and has just throw an error that users need to use
SASS with Next.js

The `getRollupOptions` function from `@nx/react/plugins/bundle-rollup`
has been deprecated as mention previously and slated for removal in v22.
New users are using inferred targets from Rollup, and existing projects
using this module should run `nx g @nx/rollup:convert-to-inferred` or
manually update rollup config to use `withNx` function.

Also, bumped some deprecation for later in v21:

- Remove inline builds from tsc/swc 
- Changes to SVGR to align with Webpack v5 (e.g. `import ReactComponent
from './img.svg?svgr'`)
- Remove `isolatedConfig` from Webpack executor -- requires a migration
that extracts to a standard webpack config just in case (different from
the original one that extracts to `withNx`)

The ESLint TODOs were rescoped to `TODO(eslint)` and we'll look at it in
further flat config work rather than tying it to an Nx release.

<!-- 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-10-02 15:29:31 -04:00
Nicholas Cunningham
31c5745126
fix(nextjs): should not fail when running outside of nx cli (#27523)
fixes: #22450

<!-- 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, if you run any next target outside of nx the build will fail
because we only fallback for graph creation of if running prod server.

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
Targets should work if they are run outside of the Nx cli

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

Fixes #
2024-08-20 11:43:28 -06:00
Trang Doan
22b654a3a9
fix(nextjs): Fix order, and wrong number call to createWebpackConfig() (#27337)
<!-- 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
Assets are not copied to the dist folder after running @nx/next:build

## Expected Behavior
Assets should be copied to the dist folder after @nx/next:build

## Related Issue(s)
https://github.com/nrwl/nx/issues/26900

Fixes #
Fix the order, and wrong number of parameters call to
createWebpackConfig()

---------

Co-authored-by: Nicholas Cunningham <ndcunningham@gmail.com>
2024-08-14 08:12:20 -04:00
Nicholas Cunningham
4197a91845
feat(nextjs): Add convert-to-inferred generator (#26706)
This PR enables the ability to migrate project(s) from using nextjs
executors to inferred targets.

---------

Co-authored-by: Jack Hsu <jack.hsu@gmail.com>
2024-06-27 11:21:35 -04:00
Sean Parmelee
a8ae302ae4
fix(nextjs): support canary versions of next (#22672)
<!-- 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 using a `canary` version of `next` in an nx monorepo where the
next.js application depends on a lib that's also in the monorepo,
running `nx build` results in `Module parse failed: Unexpected token`
errors start occurring.

The use of a `canary` version essentially reintroduces
https://github.com/nrwl/nx/issues/16658 because of how `semver` [handles
pre-release
tags](https://github.com/npm/node-semver/tree/main?tab=readme-ov-file#prerelease-tags).
As mentioned in the docs, we can suppress this behavior by passing the
`includePrerelease` option, which is what this PR does.

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
`nx build` successfully builds my Next.js application

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->
https://github.com/nrwl/nx/issues/16658
https://github.com/nrwl/nx/issues/16516
https://github.com/nrwl/nx/issues/19635
2024-06-04 09:36:30 -06:00
Nicholas Cunningham
9cd0b420d1
feat(react): Add SvgOptions for NxReactWebpackPlugin and WithNx (#23283)
This PR adds the ability to now override our svg options by providing
them either using `NxReactWebpackPlugin` for react apps or `withNx` for
Next.js apps

```
new NxReactWebpackPlugin({
  svgr: {
    svgo: true,
    titleProp: true,
    ref: true,
  }
}),
  ```

This now gives you control on customizing how the svg is handled. Should you need to enable svgo you can provide the config using `svgr.config.js`

https://react-svgr.com/docs/options/#svgo

closes: #9487
2024-05-13 08:15:44 -06:00
Jack Hsu
2e621f324c
feat(misc): v19 cleanup for Nx plugins (#23104)
This PR removes deprecated code that's been slated for removal in Nx 19
- mentioned as `TODO(v19)` comments.

## Breaking Changes

- **CNW:** `create-nx-workspace` no longer support `--preset=empty` and
`--preset=core`, use `--preset=apps` and `--preset=npm` respectively.
Deprecated in Nx 15.9.
- **Next.js:** `NX_` environment variables are no longer bundled into
Next.js apps, use `NEXT_PUBLIC` instead. Deprecated in Nx 16.8.
- **Webpack, Storybook, Esbuild:** `NX_` environment variables are no
longer bundled into browser bundles, use `NX_PUBLIC` instead. This
removes the possibility of intentional bundling of `NX_` variables.
Deprecated in Nx 18.
- **Cypress:** `cypressComponentConfiguration` generator removed from
`@nx/cypress`, use `configurationGenerator`instead. Deprecated in Nx
16.8.
- **Cypress:** `cypressProjectGenerator` generator removed from
`@nx/cypress`, use `configurationGenerator` instead. Deprecated in Nx
15.9.
- **Expo:** `withNxWebpack` removed from `@nx/expo`, use [metro
bundler](https://docs.expo.dev/guides/customizing-metro/)
(https://docs.expo.dev/guides/customizing-metro/) in app.json instead.
There is a migration to handle this in Nx 19. Deprecated in Nx 15.8.

## Deferred to v20

- **JS:** `classProperties.loose` option removed from `@nx/js/babel`
preset, use `loose` instead. Deprecated in Nx 17.0.
- **ESLint:** Low priority task to "deviations from
@typescript-eslint/recommended" for our lint rules. @JamesHenry will
look at this later before Nx 20, but it is unimportant.
- **React:** component testing does not work with Project Crystal, and
we need the executor + built-in webpack configs to run CT. Will do a
follow-up on this after Nx 19 release. Related issue:
https://github.com/nrwl/nx/issues/21546
- **Next.js:** `withStylus` removal from `@nx/next`, use SASS instead.
It hasn't worked, but we kept the file to throw an error when used.
Deprecated in Nx 17.0.
- **Next.js**: `@nx/next:component` and `@nx/next:page` generators to
not derive the `components` and `app`/`pages` directory. Use `nx g
@nx/next:component apps/myapp/components/button` instead. Deprecated in
Nx 17.0.
- **Webpack:** `isolatedConfig` option removal from
`@nx/webpack:webpack` executor. There is a migration to handle this in
Nx 19. Deprecated in in Nx 17.2.
- **Angular:** `executeWebpackDevServerBuilder` removal from
`@nx/angular/executors`, use `executeDevServerBuilder` instead.
Deprecated in Nx 17.0.
2024-05-02 13:37:12 -04:00
Jack Hsu
270788e47b
fix(webpack): bring back previous SVG and SVGR behavior for React projects (#22628) 2024-04-02 20:46:41 -04:00
Jack Hsu
b7ffb257a2
fix(bundling): prevent sensitive keys from being bundled (#22413) 2024-03-20 13:01:43 -04:00
Jack Hsu
207b4926d1
feat(nextjs): use global NX_GRAPH_CREATION in withNx plugin to guard against graph creation during create nodes (#22026) 2024-02-27 14:57:39 -05:00
Nicholas Cunningham
4c8c24b97a
fix(nextjs): Add missing e2e-ci target for cypress (#21805) 2024-02-16 16:36:01 -05:00
Nicholas Cunningham
b1d0294d46
fix(nextjs): Svg should work when svgr is true in next config (#21761) 2024-02-09 17:55:26 -07:00
Craigory Coppola
deb0f1a492
chore(repo): bump deprecation messages to v19 (#21430) 2024-01-30 16:29:05 -05:00
Nicholas Cunningham
7ddc3136ba
chore(nextjs): Remove env variable warning message (#21238) 2024-01-19 10:32:12 -07:00
Jason
8badd4b101
fix(nextjs): fix crash when paths is undefined (#20598) 2023-12-07 11:17:35 +02:00
Nicholas Cunningham
b8d24e6d0e
feat(nextjs): Add support for create nodes for nextjs (#20193) 2023-12-06 16:52:09 -07:00
Jack Hsu
bda1c7d153
fix(nextjs): apply transpilation fixes and other webpack config when running dev-server (#20615) 2023-12-06 15:14:33 -05:00
Nicholas Cunningham
e12050b3d3
fix(nextjs): When running dev server .next folder should be in source (#20536) 2023-12-04 09:40:38 -07:00
Nicholas Cunningham
1389fc0dab
fix(nextjs): Custom server should work on fresh applications (#19833) 2023-10-24 14:43:57 -06:00
Nicholas Cunningham
55167521d0
fix(nextjs): Add missing environment variables for Nx 18 environment variables (#19585) 2023-10-12 12:33:35 -06:00
Nicholas Cunningham
78f7f9f9e5
fix(nextjs): Add missing env to base Nx Env (#19201) 2023-09-22 08:27:43 -04:00
Jack Hsu
9362de0681
fix(nextjs): do not warn on NX_INVOKED_BY_RUNNER and only show warning once (#19254) 2023-09-20 11:30:13 -04:00
Craigory Coppola
8530b45988
chore(nextjs): pass full executor context where available to parseTargetOptions (#19138) 2023-09-20 09:07:34 -04:00
Nicholas Cunningham
da2a08e575
fix(nextjs): Deprecate adding NX_ vars to Webpack Define (#18892) 2023-08-29 13:44:05 -06:00
Nicholas Cunningham
50ee9904e1
fix(nextjs): Respect CLI output path when provided (#17947) 2023-07-04 13:58:13 -06:00
Jack Hsu
77ca8d7c33
feat(nextjs): allow withNx to be used with other executors such as run-commands (#17819) 2023-06-27 10:24:26 -04:00
Jack Hsu
fdf755584f
fix(nextjs): update workspace libs setup in weback config (#17795) 2023-06-26 12:26:52 -04:00
Jack Hsu
7dd8fb615e
feat(nextjs): add babel root-mode option to withNx plugin (#17286) 2023-05-29 08:57:41 -06:00
Jack Hsu
9881efa4dc
feat(nextjs): remove the "root" option from Next.js build executor since it can be inferred (#17248) 2023-05-26 19:08:02 +00:00
Nicholas Cunningham
3d76d95b29
feat(nextjs): Use next.js cli for build and serve targets (#16896) 2023-05-17 11:09:11 -04:00
Jack Hsu
7246a34526
chore(nextjs): add lint rule to make sure relative imports or imports of nx packages are disallowed (#16895) 2023-05-10 13:52:08 -04:00
Jack Hsu
c9d73d2a5f
fix(nextjs): read serverActions config safely (#16909) 2023-05-10 08:21:11 -06:00
Jack Hsu
854b180013
fix(nextjs): inline dev-only dependencies and add e2e test to catch issues (#16890) 2023-05-09 13:28:52 -04:00
Jack Hsu
dc911051aa
fix(nextjs): withNx works with production build (#16867) 2023-05-08 12:53:56 -04:00
Jack Hsu
88615152fb
fix(nextjs): enable Next.js 13.4 support (#16819) 2023-05-05 14:57:21 -04:00
Jack Hsu
8d35edac39
fix(nextjs): add workspace dependencies to transpilePackages automatically (#16774) 2023-05-04 18:08:34 -04:00
Nicholas Cunningham
4dea8b72fe
fix(nextjs): Nightly failures since yarn eagerly reads imports (#16522) 2023-04-24 17:44:35 -04:00
Jack Hsu
564ffaeebd
fix(nextjs): remove the need to install @nx/next for production builds (#16469) 2023-04-21 16:13:16 -04:00
Jason Jean
76dfc62412
feat(web): replace usages of @nrwl with @nx (#16376) 2023-04-19 10:59:41 -04:00
Jason Jean
2d195007b0
feat(core): switch packages to use the @nx scope (#16069) 2023-04-14 19:56:37 -04:00
Jack Hsu
73227515ed
feat(nextjs): add composePlugins util when using multiple plugins (#16296) 2023-04-13 15:41:17 -06:00
Jack Hsu
b3200fb7c4
fix(nextjs): set correct distDir when running production server through Nx (#15861) 2023-03-23 16:57:10 +00:00
Jack Hsu
e904e04611
fix(nextjs): add missing style deps for less and stylus (#15839) 2023-03-22 22:05:18 +00:00
Jack Hsu
c7e49c564a
fix(nextjs): produce correct next.config.js file for production server (#15824) 2023-03-22 14:03:09 -04:00
Jack Hsu
63cdddfa11
fix(nextjs): handle buildable libs correctly (#15795) 2023-03-21 11:21:02 -04:00
Jason Jean
4b9865c187
fix(react): fix next import (#15724) 2023-03-16 15:38:48 -06:00
Nicholas Cunningham
be81405a84
fix(nextjs): refactor how webpack config is loaded with nextjs (#15650)
Co-authored-by: FrozenPandaz <jasonjean1993@gmail.com>
2023-03-15 18:07:19 -04:00
Jack Hsu
dc16468607
fix(nextjs): check validity of Nx context in withNx plugin (#13358) 2022-11-23 16:21:25 +00:00