Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Latest NextJS (10.1.4-canary.6) with Webpack 5 enabled fails: error - ./some-icon.svg?sprite TypeError: Cannot read property 'version' of undefined #236

Open
andresgutgon opened this issue Apr 15, 2021 · 5 comments

Comments

@andresgutgon
Copy link

What?

Hi, I'm trying to update my NextJS project from 10.0.5-canary.3 to 10.1.4-canary.6. And I'm enabling Webpack 5.

The feature that I'm using from next-optimized-images is the SVG sprite generation.

After remove node_modules and start Next project again in dev mode I see this error on the console:

error - ./components/Footer/logo-footer.svg?sprite
TypeError: Cannot read property 'version' of undefined
event - build page: /next/dist/pages/_error

Did anyone found this problem?

This is my next.cofig.js

const withPlugins = require('next-compose-plugins')
const optimizedImages = require('next-optimized-images')
const nextConfig = {
  distDir: 'next-server',
  future: { webpack5: true },
}

module.exports = withPlugins(
  [
    [
      optimizedImages,
      {
        imagesFolder: 'images',
        imagesName: '[name]-[hash].[ext]',
        handleImages: ['svg', 'png'],
        svgo: {}
      }
    ]
  ],
  nextConfig
)

Thanks

@andresgutgon
Copy link
Author

This plugin is changing webpack configuration right?
Could be that the way this plugin is changing webpack config is not compatible with webpack 5 vercel/next.js#23143 ?

I tried v3 of this plugin but I can't use because sprite feature is not ready there

@andresgutgon
Copy link
Author

andresgutgon commented Apr 15, 2021

Meanwhile my solution is to include webpack 4 in my package.json dependencies and set future: { webpack5: false }, in my next.config.js

@danielberndt
Copy link

It's an issue in the underlying repo. A PR is already prepared: JetBrains/svg-sprite-loader#452.

You can use patch-package to apply this fix locally in case the PR isn't merged yet.

@danielberndt
Copy link

svg-sprite-loader 6.0.6 has been released with a fix for the error, so I believe should mean that this issue can be closed, right?

@andresgutgon
Copy link
Author

Let me check and I'll close it : )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants