Conversation
…nction BREAKING CHANGE: The svgr option has been removed from withReact, NxReactWebpackPlugin, and withNx (for Next.js). Projects that need SVGR support should now use the new withSvgr composable function from @nx/react. For React webpack projects: - Import withSvgr from '@nx/react' - Add withSvgr() to your composePlugins chain after withReact() For Next.js projects: - Add SVGR webpack configuration directly to your next.config.js Migrations have been provided to automatically update existing configurations. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
View your CI Pipeline Execution ↗ for commit 27660f4
☁️ Nx Cloud last updated this comment at |
There was a problem hiding this comment.
Nx Cloud is proposing a fix for your failed CI:
We've updated the Next.js SVGR end-to-end tests to align with the breaking change that removes the nx.svgr option. The tests now use the new pattern where SVGR webpack configuration is added directly to the Next.js config via a withSvgr function, which matches the migration script output and ensures SVGR functionality continues to work as expected.
We verified this fix by re-running e2e-next:e2e-ci--src/next-svgr.test.ts.
Suggested Fix changes
diff --git a/e2e/next/src/next-svgr.test.ts b/e2e/next/src/next-svgr.test.ts
index c0531a1067..4b6176c5fc 100644
--- a/e2e/next/src/next-svgr.test.ts
+++ b/e2e/next/src/next-svgr.test.ts
@@ -54,14 +54,46 @@ describe('NextJs SVGR support', () => {
`
const { composePlugins, withNx } = require('@nx/next');
const nextConfig = {
- nx: {
- svgr: true,
- },
+ nx: {},
};
const plugins = [
withNx,
];
- module.exports = composePlugins(...plugins)(nextConfig);
+
+ // Add SVGR webpack config function
+ const withSvgr = (config) => {
+ // Add SVGR support
+ config.module.rules.push({
+ test: /\\.svg$/,
+ issuer: { not: /\\.(css|scss|sass)$/ },
+ resourceQuery: {
+ not: [
+ /__next_metadata__/,
+ /__next_metadata_route__/,
+ /__next_metadata_image_meta__/,
+ ],
+ },
+ use: [
+ {
+ loader: require.resolve('@svgr/webpack'),
+ options: {
+ svgo: false,
+ titleProp: true,
+ ref: true,
+ },
+ },
+ {
+ loader: require.resolve('file-loader'),
+ options: {
+ name: 'static/media/[name].[hash].[ext]',
+ },
+ },
+ ],
+ });
+ return config;
+ };
+
+ module.exports = composePlugins(...plugins, withSvgr)(nextConfig);
`
);
@@ -116,18 +148,46 @@ describe('NextJs SVGR support', () => {
`
const { composePlugins, withNx } = require('@nx/next');
const nextConfig = {
- nx: {
- svgr: {
- svgo: false,
- titleProp: true,
- ref: true,
- },
- },
+ nx: {},
};
const plugins = [
withNx,
];
- module.exports = composePlugins(...plugins)(nextConfig);
+
+ // Add SVGR webpack config function
+ const withSvgr = (config) => {
+ // Add SVGR support
+ config.module.rules.push({
+ test: /\\.svg$/,
+ issuer: { not: /\\.(css|scss|sass)$/ },
+ resourceQuery: {
+ not: [
+ /__next_metadata__/,
+ /__next_metadata_route__/,
+ /__next_metadata_image_meta__/,
+ ],
+ },
+ use: [
+ {
+ loader: require.resolve('@svgr/webpack'),
+ options: {
+ svgo: false,
+ titleProp: true,
+ ref: true,
+ },
+ },
+ {
+ loader: require.resolve('file-loader'),
+ options: {
+ name: 'static/media/[name].[hash].[ext]',
+ },
+ },
+ ],
+ });
+ return config;
+ };
+
+ module.exports = composePlugins(...plugins, withSvgr)(nextConfig);
`
);
❌ The fix was rejected.
⚙️ An Nx Cloud workspace admin can disable these reviews in workspace settings.
…default in SVGR migration - Fixed AST selectors to be more specific using direct property access instead of :has() syntax - Added support for require statements in addition to import statements - Added support for export default in addition to module.exports - Added test case for export default with NxReactWebpackPlugin - Ensured withSvgr is properly inserted in composePlugins calls for withReact style - Moved module.exports wrapping to use AST changes instead of string replacement Related Issue(s) Fixes NXC-3106
Added test coverage for ESM imports/export default, NxReactWebpackPlugin with svgr false, and NxReactWebpackPlugin with svgr options object Related Issue(s) Fixes NXC-3106
Grouped withReact and NxReactWebpackPlugin tests into separate describe blocks for better test organization and readability Related Issue(s) Fixes NXC-3106
|
This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request. |
BREAKING CHANGE: The svgr option has been removed from withReact, NxReactWebpackPlugin, and withNx (for Next.js). Projects that need SVGR support should now use the new withSvgr composable function from @nx/react.
For React webpack projects:
For Next.js projects:
Migrations have been provided to automatically update existing configurations.
Closes NXC-3106