112 Commits

Author SHA1 Message Date
Jack Hsu
8804f12450
feat(bundling): add convert-to-inferred generator for @nx/rollup (#26280)
This PR adds `@nx/rollup:convert-to-inferred` generator.


## 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-06-13 13:52:55 -04:00
Zoran Kokeza
14eb8de800
fix(react): disable react refresh overlay (#22013)
## Current Behavior
Currently when a user runs into a compile/runtime error in react
application 2 error overlays will show. One from react-refresh-plugin
and the second one from webpack-dev-server (which is enabled by default)

![image](https://github.com/nrwl/nx/assets/19208948/c6be47bc-3ffd-4148-bdc6-18b59affae7f)

![image](https://github.com/nrwl/nx/assets/19208948/65ebe2a4-ed47-4feb-b289-645f3e2303cc)

### Steps to reproduce

This is reproducible using both webpack config types when the react
refresh plugin is applied to the configuration.
1. create fresh nx react app with webpack
2. add `hot: true`in webpack dev server configuration, so
react-refresh-plugin gets applied
3. anywhere in the app code throw an error i.e.
```
useEffect(() => {
  setTimeout(() => {
    throw new Error('test');
  }, 1000);
}, []);
```
4. observe 2 error overlays shown
Or clone the repo https://github.com/zoran995/nx-react-error-overlay,
branch main is using nx enhanced config, branch default-config is using
plain webpack config. Here is also a codesandbox showcasing an issue
https://codesandbox.io/p/github/zoran995/nx-react-error-overlay/main?file=%2Fapps%2Forg%2Fsrc%2Fapp%2Fapp.tsx&import=true

## Expected Behavior
Only one error should be shown to the user, and this is the actual
configuration of the plugin that is used by react scripts. I went with
not exposing another config option for nx react webpack plugin as there
is already an option to configure webpack dev server error overlay and
most of the react community is used to have the react-refresh one
disabled.
2024-05-29 09:20:37 -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
5e08b153c9
feat(bundling): upgrade rollup to v4 (#22656) 2024-04-18 22:08:07 -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
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
Jack Hsu
f4569efe0a
fix(react): update default webpack config for component testing (#20749) 2023-12-13 15:02:45 -05:00
Jack Hsu
1cd8b05486
fix(react): webpack backwards compat for @nx/react/plugin/webpack (#20697) 2023-12-11 14:39:59 -05:00
Jack Hsu
507fe42e4f
feat(webpack): add plugin to automatically configure build and serve targets (#20243) 2023-11-28 13:01:03 -05:00
Jack Hsu
395eb70336
feat(webpack): add NxWebpackPlugin that works with normal Webpack configuration (#19984) 2023-11-08 11:03:34 -05:00
Eric Renken
e8b6034b6c
feat(nextjs): can set compiler when setting up nxComponentTestingPreset (#19171) 2023-11-03 17:11:42 +02:00
Katerina Skroumpelou
01847b15c4
fix(react): storybook plugin tsconfig resolution (#19631) 2023-10-16 11:12:32 -04:00
Jack Hsu
8826a7737d
feat(react): remove stylus option from generators (#19441) 2023-10-12 12:49:45 -04:00
Colum Ferry
14643b68b5
feat(react): use TS config files for module federation (#19455) 2023-10-12 11:42:41 -04:00
Craigory Coppola
a18dd48510
chore(react): pass full context to parseTargetString (#19156) 2023-09-20 09:07:21 -04:00
Caleb Ukle
193206ac86
feat(testing): support cypress v13 (#18899) 2023-09-01 11:55:13 -04:00
Ben McCann
38fec9ca77
feat(testing): Vite 5 compatibility for Cypress (#18535) 2023-08-08 14:24:05 -05:00
Caleb Ukle
7d15e0c350
chore(repo): bump webpack version (#17836) 2023-06-28 19:54:38 +00:00
Katerina Skroumpelou
e58cc798a5
feat(storybook): move tsconfig one level up (#17749) 2023-06-26 16:25:52 +03:00
Caleb Ukle
f3f74068ea
fix(testing): update default webpack config for react CT (#17562) 2023-06-21 11:41:33 -04:00
Colum Ferry
99739179c7
chore(react): remove unnecessary type cast (#17689) 2023-06-20 08:50:42 -05:00
Jack Hsu
08339ee49f
feat(js): do not generate root babel.config.json for babel projects (#17289) 2023-06-06 15:45:33 -04:00
Chris McLeod
be267a7cd9
fix(react): do not require webpackConfig for cypress component testing (#16966)
Co-authored-by: Loïc BERTRAND <loic.bert.marcel@gmail.com>
2023-05-16 21:53:09 +00:00
Caleb Ukle
dfd51634f3
fix(testing): prevent ct and e2e generators overwriting configs (#16651) 2023-05-11 12:19:16 -04:00
Caleb Ukle
ebcc4363d0
fix(testing): fix react CT w/ vite and dependant projects (#16475) 2023-04-28 16:40:04 -04:00
Jason Jean
76dfc62412
feat(web): replace usages of @nrwl with @nx (#16376) 2023-04-19 10:59:41 -04:00
Jack Hsu
ced3ab9c59
feat(nextjs): add migration for Next.js 13.3.0 (#16370) 2023-04-18 10:26:23 -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
d8f9f32e7a
fix(react): update types for "@nrwl/react/plugins/webpack" for projec… (#15235) 2023-02-24 18:43:29 +02:00
Katerina Skroumpelou
b7fe0a2311
docs(storybook): add titles and descriptions to all docs (#14749) 2023-02-01 17:03:51 +00:00
Jack Hsu
ec28689a80
docs(webpack): add guide for webpack plugins (e.g. withNx, withWeb, etc.) (#14720) 2023-01-31 17:06:32 +00:00
Dan Roujinsky
e92097c5d0
fix(webpack): use webpack-merge for plugins to preserve values, fix React SVG loader (#14695) 2023-01-31 10:09:58 -05:00
Jack Hsu
795e4d6985
fix(webpack): fix support for module federation plugin (#14653) 2023-01-27 14:14:31 +02:00
Jack Hsu
d5332b4e23
feat(webpack): move web-specific options into withWeb plugin (#14590) 2023-01-26 14:17:13 -05:00
Jack Hsu
cd92d102d3
feat(webpack): add isolatedConfig option to skip automatically applying Nx plugins (#14618) 2023-01-26 10:32:34 -05:00
Katerina Skroumpelou
c3de9fdd76
fix(storybook): react plugin sourcemap type (#14600)
Co-authored-by: Bashkim Isai <me@bashkim.com>
2023-01-25 17:43:25 +02:00
Katerina Skroumpelou
61f7a9a85a
fix(react): storybook plugin fixes (#14493) 2023-01-20 08:18:43 -05:00
Jack Hsu
01b42896a2
fix(react): add migration to install @nrwl/webpack if needed by Story… (#14480) 2023-01-19 18:27:36 +00:00
Jack Hsu
454fba49b2
feat(webpack): generate React and Web apps with webpack.config.js file (#14285) 2023-01-12 10:06:25 -05:00
Jack Hsu
6feb56e014
feat(webpack): remove support for legacy browsers (#14190) (#14257) 2023-01-11 10:13:35 +02:00
Jack Hsu
fcc02d1932
feat(webpack): remove support for legacy browsers (#14190) 2023-01-09 12:15:37 +02:00
Craigory Coppola
285dc39371
feat(core): support targets with colons in the name without quotes (#13938) 2022-12-28 15:18:07 -05:00
Caleb Ukle
663d38bdba
feat(testing): support async webpack config for react component testing (#14037) 2022-12-28 11:17:53 -05:00
Nikita Glazov
37dc336a0a
fix(nx/react): wrong svg import processing (#12477) 2022-12-19 15:45:33 -05:00
Jack Hsu
9ac63667b2
fix(react-native): support React Native buildable libs that do not use SVGR (#13909) 2022-12-19 18:09:08 +00:00
Yehuda Goldberg
6a2884297c
fix(react): load svg component in buildable library (#12226) 2022-12-19 15:39:26 +00:00