phaser-input icon indicating copy to clipboard operation
phaser-input copied to clipboard

Phaser 2 Webpack build error

Open dougSmall31 opened this issue 6 years ago • 2 comments

Hello,

I'm getting this error only on the production build, when I'm running on my local dev environment everything works fine.

Uncaught TypeError: Cannot set property 'game' of undefined
    at n.PluginManager.add (vendor.bundle.js?b6ee61c795d18e338b66:1)
    at n.GameObjectFactory.plugin (vendor.bundle.js?b6ee61c795d18e338b66:1)
    at e.value (bundle.js?b6ee61c795d18e338b66:1)
    at n.StateManager.preUpdate (vendor.bundle.js?b6ee61c795d18e338b66:1)
    at e.updateLogic (vendor.bundle.js?b6ee61c795d18e338b66:1)
    at e.update (vendor.bundle.js?b6ee61c795d18e338b66:1)
    at n.RequestAnimationFrame.updateRAF (vendor.bundle.js?b6ee61c795d18e338b66:1)
    at window.requestAnimationFrame.forceSetTimeOut._onLoop (vendor.bundle.js?b6ee61c795d18e338b66:1)

When I completely remove the phaser-input field from that state the game runs fine in the production build. That leads me to believe it's an issue with phaser-input and webpack. I followed the instructions on issue #7 but am still having issues.

module: {
    rules: [
      {
        test: /\.js$/,
        use: ["babel-loader"],
        include: path.join(__dirname, "src")
      },
      { test: /pixi\.js/, use: ["expose-loader?PIXI"] },
      { test: /phaser-split\.js$/, use: ["expose-loader?Phaser"] },
      { test: /p2\.js/, use: ["expose-loader?p2"] },
      //added for phaser-input
      {
        test: /phaser\-input\.js$/,
        use: "exports-loader?PhaserInput=PhaserInput"
      },
      { test: /\.ts$/, enforce: "pre", loader: "tslint-loader" },
      { test: /\.ts$/, loader: "ts-loader" }
    ]
  },
  node: {
    fs: "empty",
    net: "empty",
    tls: "empty"
  },
  resolve: {
    extensions: [".ts", ".js"],
    alias: {
      phaser: phaser,
      pixi: pixi,
      p2: p2,
      "phaser-input": path.join(
        __dirname,
        "/node_modules/@orange-games/phaser-input/build/phaser-input.js"
      )
    }
  }

Any help is much appreciated.

dougSmall31 avatar Oct 20 '18 23:10 dougSmall31

@AleBles

dougSmall31 avatar Oct 24 '18 02:10 dougSmall31

The things I can think of is that you import the wrong thing (should be import 'phaser-input';) or that the exports loader is the wrong thing for the job.

You're best off with someone rather proficient in webpack, and I'm not that guy. Sorry

AleBles avatar Oct 24 '18 06:10 AleBles