question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Documentation insufficient for v6.x explaining that @pixi/assets is external, opt-in

See original GitHub issue

Expected Behavior

The docs show how to use the assets loader:

import { Assets } from 'pixi.js';

Current Behavior

This doesn’t work:

image

At runtime: Uncaught SyntaxError: The requested module '/node_modules/.vite/deps/pixi__js.js?v=25d6e02b' does not provide an export named 'Assets' (at plugin.ts:8:23)

This is on pixi 6.5.6 which as far as I know is the default.

Other attempt with @pixi/assets

Seeing that, I digged around and found this repo which seems to be in the process of converting to a monorepo (though I couldn’t find any docs about that). I then found the @pixi/assets package and added it to my project.

This worked up to a point: When creating animated sprites using textures from the Assets package I get a strange error:

image

This happens because this._texture in AnimatedSprite is undefined, which in turns is caused by the following:

image image

The textures coming from the Assets loader are not instances of the same base texture class as the one being checked inside AnimatedSprite.

This leads me to believe the reason this doesn’t work is that using the @pixi/assets package on top of the normal pixi.js package probably ends up with two versions of the same files being imported, and thus two versions of the base texture class, maybe. Though when I looked at the monorepo, the Assets package seems to have no dependencies, so I don’t know.

Possible Solution

I don’t know, I just expected to be able to import Assets from pixi.js as said in the docs.

I wouldn’t mind using the monorepo package otherwise, but this is undocumented and I don’t know if it’s intended to be used.

Steps to Reproduce

  • Try to import Assets from pixi.js
  • It doesn’t exist

Environment

  • pixi.js version: 6.5.6
  • Browser & Version: Chrome Version 106.0.5249.119 (Official Build) (arm64)
  • OS & Version: MacOS
  • Note: I am running this using Vite. Though I don’t think that should matter as this is standard import behaviour.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
SuperSodaSeacommented, Oct 18, 2022

Document for v6.x is here: https://pixijs.download/v6.x/docs/PIXI.Assets.html

I think the document here should also be modified to illustrate @pixi/assets is not included in pixi.js bundle as for v6.x.

1reaction
SuperSodaSeacommented, Oct 18, 2022

By the way, I think we need to add links for different version of API Docs (latest, v7.x, v6.x, dev, etc.) on the navbar of pixijs.com instead of just the latest release version, in order to avoid confusion.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found