I’m having issues updating the version of Phaser to include the Facebook instant game plugin using Webpack. The current (old) version of Phaser I’m running is v3.20.1 and when I check the console log I can see the Facebook plugin is active via the -FB suffix.
Phaser v3.20.1-FB (WebGL | Web Audio)
However, when I update to the latest version of Phaser it no longer is loading the Facebook plugin
Phaser v3.55.2 (WebGL | Web Audio)
So obviously any call to this.facebook is resulting in the below error:
Uncaught TypeError: Cannot read property 'on' of undefined
I’ve made sure Webpack has the plugin active as detailed here phaser/readme.md at master · photonstorm/phaser · GitHub so I’m at a bit of a loss as to why this no longer loads. I’m sure it must be something simple that I’ve missed but I can’t seem to find any advice on this issue.
I have been able to find a fix for this but it seems a bit of a bodge. It seems since v3.24 a ‘browser’ property was added to package.json (phaser/package.json at 3dc66c3a4331a1a96584019da2cbe5c977471640 · photonstorm/phaser · GitHub) which is overriding the ‘main’ property. This means imports are using ‘./dist/phaser.js’ rather than ‘./src/phaser.js’ so the plugin if statements are never triggered.
I fixed this by changing my Phaser imports on file from:
import Phaser from "phaser";
To
import Phaser from "phaser/src/phaser.js";
Is this how Phaser should be imported now or am I missing something?