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

[Bug] Cannot load SVG using Assets.load #4

Open
UlyssesZh opened this issue Jul 26, 2023 · 0 comments
Open

[Bug] Cannot load SVG using Assets.load #4

UlyssesZh opened this issue Jul 26, 2023 · 0 comments

Comments

@UlyssesZh
Copy link

Reproduction:

npm i @pixi/node
echo '<?xml version="1.0" encoding="UTF-8"?><svg xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" width="32" height="32"></svg>' > test.svg
node -e "require('@pixi/node').Assets.load('test.svg');"
/home/ulysses/temp/pixi-node-test/node_modules/@pixi/assets/lib/loader/Loader.js:93
          throw new Error(`[Loader.load] Failed to load ${url}.
                ^

Error: [Loader.load] Failed to load /home/ulysses/temp/pixi-node-test/test.svg.
ReferenceError: Image is not defined
    at /home/ulysses/temp/pixi-node-test/node_modules/@pixi/assets/lib/loader/Loader.js:93:17
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Promise.all (index 0)
    at async Loader.load (/home/ulysses/temp/pixi-node-test/node_modules/@pixi/assets/lib/loader/Loader.js:98:5)
    at async AssetsClass._mapLoadToResolve (/home/ulysses/temp/pixi-node-test/node_modules/@pixi/assets/lib/Assets.js:170:26)
    at async AssetsClass.load (/home/ulysses/temp/pixi-node-test/node_modules/@pixi/assets/lib/Assets.js:95:17)

Node.js v18.16.0

The cause of the bug is here:
https://github.com/pixijs/pixijs/blob/9ce9bd2c80837265b986e1fa7af37a3d9fb4393d/packages/core/src/textures/resources/SVGResource.ts#L110
The new Image() is causing the ReferenceError because there is no Image in the Node environment.

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

1 participant