Pixi.js and TypeScript AMD module compilation

Published January 10, 2020
Advertisement

If you use Pixi with TypeScript maybe my information will be useful for you in the future when you compile to AMD modules.

I had a problem with import in TypeScript when I compiled using "module": "AMD". I had the error when I compiled like this: "cannot find pixi.js module". Because "." (dot) int the name does not allow to compile to AMD modules.

I solved this problem very easy. I just:

  1. renamed the folder "node_modules/pixi.js" to "node_modules/pixijs"
  2. replaced in the file "pixi.js.d.ts" this code:
declare module "pixi.js" {
    export = PIXI;
}

to this:

declare module "pixijs" {
    export = PIXI;
}

My example with instruction: https://github.com/8Observer8/getting-started-with-pixijs-and-typescript
Playground: https://next.plnkr.co/edit/2dkQtKRY30nvoYmF?preview

I hope it will help you.

0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement