Closed maxmadknight closed 4 years ago
Hmm, strange, could you share your Node.js and Webpack versions?
node v12.14.0 npm 6.14.7
But this issue was discovered on product server with other versions. Can tell exactly
Are you able to reproduce it on your local system with these versions? Also still missing the Webpack version 😅
I share the same issue:
node: v12.16.2
webpack: v4.44.1
webpack-cli: v3.3.12
Downgrading to v3.5.7 fix the issue.
Interesting, I can’t seem to reproduce it but I’ll push a potential fix for this later today if multiple people are experiencing this.
@cascornelissen thanks for your quick reply. Perhaps my webpack configuration might help you to figure out what happen:
new SVGSpritemapPlugin(
[
'./src/images/svg-sprite/**/*.svg',
],
{
output: {
filename: 'polaris-sprite.svg',
svg4everybody: false,
svgo: {
plugins: [
{ removeDesc: true },
{ removeAttrs: { attrs: 'fill|class|style' } },
{ removeStyleElement: true },
{ removeRasterImages: true },
{ sortAttr: true },
],
},
},
sprite: {
prefix: 'polaris__',
},
},
),
Took a bit longer than I hoped but the fix in 672bb2b6 should resolve this. Could any of you try this out?
npm install --no-save cascornelissen/svg-spritemap-webpack-plugin#118
Pinging @maxgram and @ivankristianto (or anyone else who can reproduce the original issue) to make sure the fix gets verified before making a release.
@cascornelissen from my quick test, it still doesn't work. I think this is more on compatible issue with my setup. Let me hunt it down this weekend and post anything I found here.
Thanks, I don't think there's any way for the same error to pop up when installing from the 118
branch so please include the actual error/stacktrace if you're running into anything ✌🏼
@cascornelissen I'm very curious about this issue and spent a bit of time to hunt it down. And better, i provide the proof of concept what causing the issue. Here is the repo: https://github.com/ivankristianto/svg-spritemap-webpack-plugin-demo
And if you enable this line: https://github.com/ivankristianto/svg-spritemap-webpack-plugin-demo/blob/master/src/client.js#L5
And do yarn && yarn build
,
it will throw this error:
95% [0] emitting SVGSpritemapPlugin(node:10529) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'startsWith' of null
my environment:
node: v12.16.2
webpack: v4.44.1
webpack-cli: v3.3.12
And if you try with the version 3.5.7
, it can compile successfully.
If there is anything I can help you more, please let me know.
And last but not least, thank you so much for your help and build / maintain this plugin.
That error helps a lot, it's slightly different than the initial issue (Cannot read property 'startsWith' of undefined
vs Cannot read property 'startsWith' of null
). Apparently both of you have chunks without a name for some reason and apparently chunk.name
can be both undefined
and null
🤷🏼♂️
Could you try installing it from the 118
branch once more? It should now handle both edge cases.
@cascornelissen yes it's working for my case! Thank you so much.
@ivankristianto, the fix for this issue has been released in version 3.5.9
🚀 I'm expecting this to also solve the original issue, thanks for helping me debug it!
Thanks. It's very useful improve for me right now :smile:
On build 3.5.8 getting next error, on 3.5.7 all is OK