Yuki Posted October 31, 2017 Share Posted October 31, 2017 I've just tried to import phaser.js along this MDN document. But it raises errors no matter how the import statement is applied. import Phaser from './phaser.js'; => Uncaught SyntaxError: The requested module does not provide an export named 'default' import {Phaser} from './phaser.js'; => Uncaught SyntaxError: The requested module does not provide an export named 'Phaser' import * as phaser from './phaser.js'; => Uncaught TypeError: Cannot set property 'PIXI' of undefined It seems phaser.js doesn't have the export statements. So, could someone advise me how to add an export statement to phaser.js so that it can be imported by other modules? Link to comment Share on other sites More sharing options...
mattstyles Posted October 31, 2017 Share Posted October 31, 2017 Search for a couple of boilerplates, there have been (at least) a couple of threads, try searching for Phaser boilerplate or Phaser module boilerplate or even Phaser ES6 boilerplate on the forums here. Personally, I couldn't get it to work cleanly and stopped fighting with it and accepted that the Phaser object is a global, this has the advantage that any plugins you want to work will work without issue i.e. you're using it as intended rather than trying to fight with it to get it to work differently. Link to comment Share on other sites More sharing options...
Yuki Posted November 5, 2017 Author Share Posted November 5, 2017 Thanks for your reply. I searched some boilerplates you mentioned. And I found phaser-es6-webpack seems good to me since it has ES6 syntax and provides a kind of convention of phaser game. And also, the project seems still active. I would explore this and if I feel it too complex, I shall take Phaser global as you recommended. Thanks a lot! mattstyles 1 Link to comment Share on other sites More sharing options...
kailcor Posted November 3, 2018 Share Posted November 3, 2018 I just got the same problem, did you find a solution? Link to comment Share on other sites More sharing options...
samme Posted November 3, 2018 Share Posted November 3, 2018 https://github.com/photonstorm/phaser-ce/blob/master/README.md#browserify--commonjs Link to comment Share on other sites More sharing options...
Recommended Posts