I’m trying to use Phaser on an Ionic 2 app, but I didn’t manage to do it
I’ve installed the NPM package :
npm install --save-dev phaser
Import it on my .ts :
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { Game } from 'phaser';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
constructor(public navCtrl: NavController) {
console.log(Game);
}
}
Error on ionic serve :
Typescript: ...node_modules/phaser/typescript/typings.json, line: 4
L3: "main": "phaser.comments.d.ts",
L4: "files": ["pixi.comments.d.ts", "p2.d.ts"],
';' expected.
File '/node_modules/phaser/typescript/typings.json' is not a module.
L2: import { NavController } from 'ionic-angular';
L3: import { Game } from 'phaser';
Error on chrome :
Runtime Error
PIXI is not defined
Stack
ReferenceError: PIXI is not defined
at Object.<anonymous> (http://localhost:8100/build/main.js:127930:11)
at Object.<anonymous> (http://localhost:8100/build/main.js:207709:4)
at Object.<anonymous> (http://localhost:8100/build/main.js:207715:30)
at __webpack_require__ (http://localhost:8100/build/main.js:20:30)
at Object.<anonymous> (http://localhost:8100/build/main.js:52570:65)
at __webpack_require__ (http://localhost:8100/build/main.js:20:30)
at Object.<anonymous> (http://localhost:8100/build/main.js:93463:75)
at __webpack_require__ (http://localhost:8100/build/main.js:20:30)
at Object.<anonymous> (http://localhost:8100/build/main.js:82205:73)
at __webpack_require__ (http://localhost:8100/build/main.js:20:30)
only because pixi is bundled the phaser package, does not mean it will land in your final package. Webpack crawls through your imports and only bundles what it sees you are using.
try to import pixi as well. I played around with phase + es6 and webpack yesterday, and there you need to import it as well.
I have tried to implemented Phaser + ionic 2 and I get this error as well. Did you find any issue ?
Is it possible to implemented phaser without webpack ?