Skip to content

Use wildcard import for top-level Phaser name#10

Merged
gammafp merged 2 commits intophaserjs:mainfrom
enderandpeter:wildcard-import
Apr 21, 2026
Merged

Use wildcard import for top-level Phaser name#10
gammafp merged 2 commits intophaserjs:mainfrom
enderandpeter:wildcard-import

Conversation

@enderandpeter
Copy link
Copy Markdown
Contributor

@enderandpeter enderandpeter commented Apr 21, 2026

These changes are meant to address #9. Although the original message in the issue says that the package.json should be updated for Phaser v4, that does not apply to this repo.

Instead, there was another issue that came up related to Phaser v4 regarding how it does not provide a global import. As a result, references to Phaser throughout the scaffolding templates will result in the error I reported in the issue. Also, I am very certain this Discord comment is referring to the same issue.

The simplest way to resolve the Uncaught ReferenceError is for the template files to have import * as Phaser from 'phaser'; so the original content can be retained.

I only changed a file to refer to Phaser.Math as PhaserMath with an accompanying imported alias so that Math would still be available.

Please review this very carefully. Let me know the best way to test the changes. I believe it's very possible to refer to my local project instead of the NPM project when using npm create or something similar...


Note

Medium Risk
Touches many starter templates and demo entrypoints; while changes are mostly import rewrites, incorrect module interop or tree-shaking differences could break generated projects across bundlers.

Overview
Switches scaffolding templates (Angular/React/Next/Remix/Solid/Vue) and multiple demo entrypoints to use a namespace import (import * as Phaser from 'phaser') so existing Phaser.* references work with module-only Phaser builds.

In phasers-revenge, adjusts Bullet to avoid shadowing the global Math by aliasing the Phaser math import to PhaserMath and updating usages accordingly.

Reviewed by Cursor Bugbot for commit 3e29cb6. Bugbot is set up for automated code reviews on this repo. Configure here.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 53896b2. Configure here.

Comment thread scaffolding/demo/phasers-revenge/src/gameobjects/Bullet.js
  - Great catch by Cursor Bugbot
  regarding how this line should
  refer to Phaser's Math
@gammafp gammafp merged commit 027d476 into phaserjs:main Apr 21, 2026
1 check passed
@gammafp
Copy link
Copy Markdown
Collaborator

gammafp commented Apr 21, 2026

Thank you @enderandpeter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants