8Observer8 Posted June 26, 2019 Share Posted June 26, 2019 EDITED: This problem is solved. The solution is in this message. Hello, Require.js does not understand '.' (dot) in the module name: "pixi.js". Here in the RequireConfig.ts file: RequireConfig.ts requirejs.config({ baseUrl: "js", paths: { "pixi.js": "https://cdnjs.cloudflare.com/ajax/libs/pixi.js/5.0.4/pixi.min" } }); requirejs(["Program"], () => { }); I changed "pixi.js" to "pixijs" in this file: "node_modules\pixi.js\pixi.js.d.ts" here: declare module "pixijs" { export = PIXI; } But now PIXI is undefined in my example: import * as PIXI from "pixijs"; export class Game { public constructor() { const app = new PIXI.Application(); console.log(app); } } Quote Link to comment Share on other sites More sharing options...
8Observer8 Posted June 26, 2019 Author Share Posted June 26, 2019 Is Pixi.js not compatible with AMD? For example, gl-matrix: https://cdnjs.cloudflare.com/ajax/libs/gl-matrix/2.8.1/gl-matrix.js You will see AMD: if("function"==typeof define&&define.amd)define([],n); Or Babylon.js: https://cdnjs.cloudflare.com/ajax/libs/babylonjs/4.0.3/babylon.max.js You will see AMD: else if(typeof define === 'function' && define.amd) Quote Link to comment Share on other sites More sharing options...
8Observer8 Posted June 26, 2019 Author Share Posted June 26, 2019 I see that Pixi.js support AMD too: https://cdnjs.cloudflare.com/ajax/libs/pixi.js/5.0.4/pixi.js else { // AMD if (typeof undefined == 'function' && undefined.amd) { undefined(function(){ return nativePromiseSupported ? NativePromise : Promise; }); } Quote Link to comment Share on other sites More sharing options...
8Observer8 Posted June 26, 2019 Author Share Posted June 26, 2019 I found the answer here: https://stackoverflow.com/questions/20295954/loader-requirejs-doesnt-respect-dependencies I must use this construction in RequireConfig.ts: shim: { "pixijs": { exports: "PIXI" } } themoonrat 1 Quote Link to comment Share on other sites More sharing options...
themoonrat Posted June 26, 2019 Share Posted June 26, 2019 Thanks for posting your solution! I'm sure it'll help others 8Observer8 1 Quote Link to comment Share on other sites More sharing options...
8Observer8 Posted June 26, 2019 Author Share Posted June 26, 2019 Yes, I solved the problem and I can set breakpoints, debug with Chrome extension in VSCode and even public my multi file examples on the Playground: click to run. This example just shows a version of Pixi.js. But there are a little problem when I compile, bundle with Browserify and minify with UglifyJS. Because I renamed "pixi.js" to "pixijs" here in the "node_modules/pixi.js.d.ts" file: declare module "pixijs" { export = PIXI; } Quote Link to comment Share on other sites More sharing options...
8Observer8 Posted June 26, 2019 Author Share Posted June 26, 2019 36 minutes ago, 8Observer8 said: But there are a little problem when I compile, bundle with Browserify and minify with UglifyJS. Because I renamed "pixi.js" to "pixijs" here in the "node_modules/pixi.js.d.ts" file: declare module "pixijs" { export = PIXI; } I solved this problem too. I just renamed "node_modules/pixi.js" to "node_modules/pixijs" I think I made a good job. Now people can public examples on Sandbox to ask question using TypeScript. My example shows a version of Pixi.js. You can run it on the Sandbox: click run run. I have written an instruction how to run it locally: If you have question, please, ask me. If you do not understand something and you have errors ask me. I will improve my instruction on GitHub. Quote Link to comment Share on other sites More sharing options...
meiciuc Posted June 24, 2020 Share Posted June 24, 2020 Maybe there is a way to "rewrite" type definition? As an idea (I am poorly versed in the topic): declare module 'pixijs' { import PIXI from 'pixi.js' export = PIXI; } Quote Link to comment Share on other sites More sharing options...
8Observer8 Posted June 25, 2020 Author Share Posted June 25, 2020 Read my instruction and build my example here: https://github.com/8Observer8/getting-started-with-pixijs-and-typescript Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.