73 Commits

Author SHA1 Message Date
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
Thomas Blanchard
4994223d03
fix(nextjs): error in with-nx.ts (#12973) 2022-11-07 10:13:21 -05:00
Konstantin Azizov
94edbe9f6c
fix(nextjs): specify return type in withNx plugin (#12486) 2022-10-26 14:00:17 -04:00
Jack Hsu
50f6cbb11d
feat(nextjs): remove dependency on "@nrwl/next" for the production build (#12247) 2022-09-26 12:38:44 -04:00
Jason Jean
c64dbdec24
fix(next): fix withNx with nx property doesn't exist (#11900) 2022-09-06 21:33:15 +00:00
Jack Hsu
9b26bc1585
fix(nextjs): SVGR plugin should not be used if nx: { svgr: false } is set in next.config.js (#11829) 2022-09-01 15:55:24 +00:00
Nicholas Cunningham
522dcdd339
feat(nextjs): improve type checking for nextjs config file (#11497)
Co-authored-by: Nicholas Cunningham <ndcunningham>
2022-08-09 11:31:22 -04:00