cascornelissen / svg-spritemap-webpack-plugin

SVG spritemap plugin for webpack
MIT License
207 stars 49 forks source link

(node:19636) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'trim' of undefined #200

Closed lmoroz closed 1 year ago

lmoroz commented 1 year ago

Description When trying to build the project I'm getting this: (node:19636) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'trim' of undefined at …\node_modules\svg-spritemap-webpack-plugin\lib\generate-svg.js:161:26

Expected behavior To build normally, probably with warning about broken SVG-file

Actual behavior Build freezes on the error: (node:19636) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag--unhandled-rejections=strict(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:19636) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

System information

System:
    OS: Windows 10 10.0.19044
    CPU: (20) x64 Intel(R) Core(TM) i9-10900 CPU @ 2.80GHz
    Memory: 7.26 GB / 31.69 GB
  Binaries:
    Node: 14.16.0 - C:\Progs\nodejs\node.EXE
    Yarn: 1.22.17 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 8.1.3 - C:\Progs\nodejs\npm.CMD
  npmPackages:
    @babel/core: ^7.17.9 => 7.19.1
    @babel/preset-env: ^7.16.11 => 7.19.1
    babel-loader: ^8.2.4 => 8.2.5
    svg-spritemap-webpack-plugin: ^4.5.0 => 4.5.0
    webpack: ^5.72.0 => 5.74.0
    webpack-cli: ^4.9.2 => 4.10.0
    webpack-dev-server: ^4.8.1 => 4.11.1

Minimal reproduction A minimal repository that reproduces the problem

Additional context Set of svg-files just contains SVG without <path…

cascornelissen commented 1 year ago

Took a while cause I was quite busy but it seems like one of your input SVGs contains invalid XML.

This specifically seems to be caused by your plans.svg which contains a data-plans-svg attribute without a value on L1 which is invalid XML. Trying to open the file on my end in my browser (Mozilla Firefox) actually throws an XML parsing error too.