-
-
Notifications
You must be signed in to change notification settings - Fork 177
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
import "pixi-viewport"
won't import properly in NextJS
#474
Comments
The thing is the issue was already solved in this commit but it seems the change was never published with a new version on npm. @davidfig Am I correct? Any chance you could publish a new version? |
For now, I managed to by-pass importing the lib only when is rendered by the browser. if (isPlatformBrowser(this.platformId)) { // <--- angular validation to check if the platform is browser
const { Viewport } = await import('pixi-viewport');
this.viewPort = new Viewport({
worldWidth: this.app.stage.width,
worldHeight: this.app.stage.height,
screenWidth: this.app.renderer.width,
screenHeight: this.app.renderer.height,
events: this.app.renderer.events,
});
} |
Facing the same issue with The first thing I did was also this: const { Viewport } = await import('pixi-viewport') But then I'm now facing an error when trying to: viewport.addChild(bunny) It raises a runtime error:
Not completely sure if this is consecutive issue of another. Or they're two separate things. Additionally, it raises an error in tsc:
In other threads they say to re-install node_modules but this doesn't help: still wrong types. Were you able to make it all work? Successfully draw a bunny or something? |
@jerrygreen Yeah I made it work for 5.0.2 (I didn't upgrade to 5.1.0 yet) by using https://github.com/shipurjan/bioparallel/blob/master/patches/pixi-viewport%405.0.2.patch pnpm applies this patch every time I install packages and I haven't had problems ever since |
The problem seems to be this: #487 |
Hello, I'm using NextJS inside Tauri.
I set all components (and all pages in the router + layout) to client, however I still can't import
pixi-viewport
, because it referenceswindow
The lines causing this seem to be below, because if I change them to fixed values the error disappears
in
\node_modules\.pnpm\pixi-viewport@5.0.2\node_modules\pixi-viewport\dist\pixi_viewport.js
Here is the code I'm using:
Changing these lines to
seems to fix it.
The text was updated successfully, but these errors were encountered: