phaserjs / phaser

Phaser is a fun, free and fast 2D game framework for making HTML5 games for desktop and mobile web browsers, supporting Canvas and WebGL rendering.
https://phaser.io
MIT License
37.16k stars 7.1k forks source link

Failed to load Phaser @3.80.1 from Skypack #6838

Closed 8Observer8 closed 2 months ago

8Observer8 commented 5 months ago

I don't know is it an issue of Phaser or Skypack. I have created both. Skypack issue: https://github.com/skypackjs/skypack-cdn/issues/371

The following link doesn't work: https://cdn.skypack.dev/phaser@3.80.1

/*
 * [Package Error] "phaser@v3.80.1" could not be built. 
 *
 * No build output found.
 *
 * How to fix:
 *   - If you believe this to be an error in Skypack, file an issue here: https://github.com/skypackjs/skypack-cdn/issues
 *   - If you believe this to be an issue in the package, share this URL with the package authors to help them debug & fix.
 *   - Use https://skypack.dev/ to find a web-friendly alternative to find another package.
 */

console.warn("[Package Error] \"phaser@v3.80.1\" could not be built. ");
throw new Error("[Package Error] \"phaser@v3.80.1\" could not be built. ");
export default null;

For example, Pixi.js 8 and @box2D/core can be loaded from Skypack: https://plnkr.co/edit/1RizUv5yknLrb9w4

    <script type="importmap">
        {
            "imports": {
                "@box2d/core": "https://cdn.skypack.dev/@box2d/core@0.10.0",
                "@box2d/particles": "https://cdn.skypack.dev/@box2d/particles@0.10.0",
                "pixi.js": "https://cdn.skypack.dev/pixi.js@8.1.6"
            }
        }
    </script>

    <script type="module" src="./js/index.js"></script>

index.js

import { b2CircleShape, b2World } from "@box2d/core";
import { b2ParticleGroupDef, b2ParticleSystemDef }  from "@box2d/particles";
import { Application, Graphics } from "pixi.js";

Playground for Phaser: https://plnkr.co/edit/3Vv3dfYhskSvlz52?preview

<!DOCTYPE html>

<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>The Skypack's `phaser@3.80.1` link doesn't work</title>
</head>

<body>
    <p><a href="https://github.com/phaserjs/phaser/issues/6840">Issue for Phaser</a></p>
    <p><a href="https://github.com/phaserjs/phaser/issues/6838">Issue for Skypack</a></p>

    <script type="importmap">
        {
            "imports": {
                "phaser3": "https://cdn.skypack.dev/phaser@3.80.1"
                // "phaser3": "https://8observer8.github.io/libs/phaser@3.80.1/phaser.esm.min.js"
            }
        }
    </script>

    <script type="module" src="./js/index.js"></script>
</body>

</html>

index.js

import { WEBGL, Game } from "phaser3";

const config = {
    type: WEBGL,
    width: 400,
    height: 300,
    scene: { preload, create, update },
    backgroundColor: "#555",
};

const game = new Game(config);

function preload() {
    console.log("preload");
}
function create() {}
function update() {}
photonstorm commented 2 months ago

There's no need to use Skypack with Phaser. We distribute Phaser ready-built and ready-bundled for browsers. There's simply no need to have a 3rd party build or minify it (which it clearly can't do correctly, probably because our entry point is our dist file, not an ES Module, which it appears it requires).