Javascript 6 class declaration (redeclaration?) behavior

Hello, and first post - please forgive any transgressions.

I’m making a game for Phaser v2.6.2 using PhaserEditor 1.5.4, in ES6 Javascript / Javascript 6.

I’m running into some odd behavior. I have a Canvas called Ball which I am planning to use as a prefab. class Ball extends Phaser.Sprite and it’s all boilerplate from there, so far.

I added that prefab to my Level canvas. Then I run the game in my browser.

This works fine the first time. However, if I refresh the game, I get an error in the console.


SyntaxError: redeclaration of let Ball line 75096 > scriptElement:1:1
    <anonymous> http://localhost:1982/projects/cej/WebContent/ line 75096 > scriptElement:1
    fileComplete http://localhost:1982/projects/cej/WebContent/lib/phaser.js:75096
    onload http://localhost:1982/projects/cej/WebContent/lib/phaser.js:74672


Uncaught SyntaxError: Identifier 'Ball' has already been declared
    at <anonymous>:1:1
    at Phaser.Loader.fileComplete (phaser.js:75096)
    at XMLHttpRequest.xhr.onload (phaser.js:74672)

If I close the browser window and open it again, it works again. So I am getting the sense that the ball definition is persisting between page refreshes, but the code to define it is run again. In Phaser.Loader.fileComplete, this is done with a call to document.head.appendChild.

Since this happened so early in the development process I have to figure I’m doing something wrong. But generally I would expect all that kind of data to be flushed on refreshing the page, is there any way I can get this to behave as I expect? Or, how should I approach it differently?

Clarifying edit:
I investigated some more and it seems this happens with any class definition that occurs inside a javascript file that I add to the pack.json. I added var and const declarations at the same scope and they did not cause errors. But, interestingly, a let declaration did cause the same error.