Facebook instant game plugin not bundled after update

Hi,

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.

Any help on this would be great.

:wave:

How are you including Phaser in your project?

Hello! I have same question before, but I found the link of 3.55.2 FB version here : phaser CDN by jsDelivr - A CDN for npm and GitHub

I don’t know why the full version doesn’t include facebook functions, but It’s work for me.
Hope this can help you :slight_smile:

Thank you for looking at this.

I’m using Node to build the files so it’s just imported at the top of the classes - I used this as the template GitHub - photonstorm/phaser3-project-template: A Phaser 3 Project Template

Something must have changed between the versions on how to include the Facebook plug-in but I can’t find anything.

Thank you for this, I’ll take a look.

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?

Awesome, that did the trick. Thank you for this.