4

Context:
I'm creating a Cocos2d-JS Game. I have already created the Project and am in development phase.

I can run cocos run -p web or cocos run -p web --source-map from the project directory in the Console. These commands work and allow me to run and test my project.


Problem:
Simply: Code changes I make are not being picked up by the cocos2d-JSB compiler. Old code that I've recently changed still exists in newly compiled cocos2d projects. I cannot detect changes I've made to class files that have already been compiled.


Technical:
The problem technically: Modified .js files are not being copied correctly by the cocos2d-js compiler (from the Terminal/Console). The previous version of the .js file are retained somehow in the localhost-web-server. The localhost is maintained by the Python script that runs the cocos2d app.

(I am writing most of my code using Typescript .ts and compiling down into Javascript .js with a .js.map. I am definitely compiling down the Typescript to Javascript before running the cocos compiler)


More:
I can see my .ts files are visible from the localhost when using Javascript Console in my Chrome Browser. I can also see my .js files this way, and can confirm that the code has not been updated.


Question:
How can I 'Force' the cocos compile or cocos run commands to overwrite old any .js files, instead of 'intelligently' retaining old files?

Is it possible that --source-map makes the run command force a fresh build?

I want to make a 'Clean Build' like in Apple's Xcode, but for cocos2d-js. How can I do this?

If none of that is possible, where can I locate the build/run directory used by the localhost so I can manually update the .js files myself?

CodeSmile
  • 64,284
  • 20
  • 132
  • 217
Jono Tho'ra
  • 1,476
  • 3
  • 18
  • 28

4 Answers4

7

Fix it: .js files were being Cached by my Browser.

Issue:
Chrome Browser was Caching the .js files. I solved this problem by turning off Caching. I did not realize that the localhost was indeed pointing to the project directory.


Solution: Disable Caching in Chrome:
Menu (top right icon) -> Tools -> Developer Tools -> Settings (Gear Icon) -> Checked the box for Disabling Caching (when DevTools is open)

Jono Tho'ra
  • 1,476
  • 3
  • 18
  • 28
0

You should know, Chrome is tenacious about caching.
You can turn it off every way they offer, and it will still retain js files you don't want it to.

My advice is to restart your entire browser--not just the tab you're debugging--at least once an hour.

0

Yes it was as simple as this, just open the dev tools with F12, then go to settings, do the cache thing, and when you run your game , activate the dev tools again (F12) and refresh the page

0

You can set noCache to true in your project.json file if you don't want caching anymore

Here is the sample code.

    {
      "project_type": "javascript",
      "debugMode": 1,
      "showFPS": false,
      "frameRate": 60,
      "noCache": true,
      "id": "gameCanvas",
      "renderMode":1,
      "engineDir": "frameworks/cocos2d-html5",
      "modules": [
        "cocos2d",
        "cocostudio",
        "editbox"
      ],