phaserjs / template-rollup-ts

A Phaser 3 project template that uses TypeScript and Rollup for bundling
MIT License
7 stars 2 forks source link

Error with clean build #1

Open Granadagames opened 6 months ago

Granadagames commented 6 months ago

To reproduce, clone the repo and run pnpm run build.

PS J:\box\template-rollup-ts> pnpm run build

> template-rollup-ts@1.1.1 build J:\box\template-rollup-ts
> rollup --config rollup/rollup.config.prod.mjs

src/main.ts → ./dist/bundle.js...
Building for production...
---------------------------------------------------------
❤️❤️❤️ Tell us about your game! - games@phaser.io ❤️❤️❤️
---------------------------------------------------------
(!) "this" has been rewritten to "undefined"
https://rollupjs.org/troubleshooting/#error-this-is-undefined
node_modules/.pnpm/phaser@3.80.1/node_modules/phaser/dist/phaser.js
 8:   else
 9:     root["Phaser"] = factory();
10: })(this, () => {
       ^
11: return /******/ (() => { // webpackBootstrap
12: /******/    var __webpack_modules__ = ({
[!] RollupError: src/scenes/Boot.ts (1:9): "Scene" is not exported by "node_modules/.pnpm/phaser@3.80.1/node_modules/phaser/dist/phaser.js", imported by "src/scenes/Boot.ts".
https://rollupjs.org/troubleshooting/#error-name-is-not-exported-by-module
src/scenes/Boot.ts (1:9)
1: import { Scene } from 'phaser';
            ^
2: export class Boot extends Scene {
3:     constructor() {
    at getRollupError (J:\box\template-rollup-ts\node_modules\.pnpm\rollup@4.14.3\node_modules\rollup\dist\shared\parseAst.js:282:41)
    at Object.error (J:\box\template-rollup-ts\node_modules\.pnpm\rollup@4.14.3\node_modules\rollup\dist\shared\parseAst.js:278:42)
    at Module.error (J:\box\template-rollup-ts\node_modules\.pnpm\rollup@4.14.3\node_modules\rollup\dist\shared\rollup.js:15122:28)
    at Module.traceVariable (J:\box\template-rollup-ts\node_modules\.pnpm\rollup@4.14.3\node_modules\rollup\dist\shared\rollup.js:15570:29)
    at ModuleScope.findVariable (J:\box\template-rollup-ts\node_modules\.pnpm\rollup@4.14.3\node_modules\rollup\dist\shared\rollup.js:13258:39)
    at ChildScope.findVariable (J:\box\template-rollup-ts\node_modules\.pnpm\rollup@4.14.3\node_modules\rollup\dist\shared\rollup.js:7480:38)
    at Identifier.bind (J:\box\template-rollup-ts\node_modules\.pnpm\rollup@4.14.3\node_modules\rollup\dist\shared\rollup.js:8752:40)
    at ClassDeclaration.bind (J:\box\template-rollup-ts\node_modules\.pnpm\rollup@4.14.3\node_modules\rollup\dist\shared\rollup.js:6208:23)
    at ExportNamedDeclaration.bind (J:\box\template-rollup-ts\node_modules\.pnpm\rollup@4.14.3\node_modules\rollup\dist\shared\rollup.js:11220:27)
    at Program.bind (J:\box\template-rollup-ts\node_modules\.pnpm\rollup@4.14.3\node_modules\rollup\dist\shared\rollup.js:6204:28)

 ELIFECYCLE  Command failed with exit code 1.
noahpodgurski commented 1 week ago

I also struggled with this, you can try instead

// import Phaser from 'phaser';

export class Boot extends Phaser.Scene