86 Commits

Author SHA1 Message Date
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
Jason Jean
bf206e578e
feat(misc): non conflicting init/add flow (#22791) 2024-04-15 16:45:08 -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
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
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
Jack Hsu
507fe42e4f
feat(webpack): add plugin to automatically configure build and serve targets (#20243) 2023-11-28 13:01:03 -05:00
Eric Renken
e8b6034b6c
feat(nextjs): can set compiler when setting up nxComponentTestingPreset (#19171) 2023-11-03 17:11:42 +02: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
Jack Hsu
8826a7737d
feat(react): remove stylus option from generators (#19441) 2023-10-12 12:49:45 -04: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
Victor Savkin
0848031dd9 feat(core): move task hashing into daemon 2023-05-17 11:37:57 -04: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
95421c6945
feat(nextjs): update Next.js to 13.4.1 and default to App Router for new apps (#16948) 2023-05-12 16:09:20 -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
Jack Hsu
66addbfa81
fix(nextjs): with stylus and less support (#16764) 2023-05-04 08:32:44 -06: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
Caleb Ukle
06a885aca2
feat(next): support nextjs cypress component testing (#16292) 2023-04-21 15:15:28 -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