From 5e26feaf8c5849af71fb2290083f1e37fae92e36 Mon Sep 17 00:00:00 2001 From: Jare Guo Date: Thu, 18 May 2017 17:24:50 +0800 Subject: [PATCH 1/2] remove unused code for moduleConfig.json --- CCBoot.js | 62 ++++----------------------------------- cocos2d/core/CCGame.js | 4 +-- jsb/jsb-game.js | 4 +-- test/visual-tests/main.js | 2 +- 4 files changed, 10 insertions(+), 62 deletions(-) diff --git a/CCBoot.js b/CCBoot.js index c49be5bbbf..659a6301b5 100644 --- a/CCBoot.js +++ b/CCBoot.js @@ -64,11 +64,9 @@ cc._gameDiv = null; require('./cocos2d/core/utils'); require('./cocos2d/core/platform/CCSys'); +// INIT ENGINE -(function () { - -var _jsAddedCache = {}, //cache for js and module that has added into jsList to be loaded. - _engineInitCalled = false, +var _engineInitCalled = false, _engineLoadedCallback = null; cc._engineLoaded = false; @@ -105,26 +103,6 @@ function _determineRenderType(config) { } } -function _getJsListOfModule(moduleMap, moduleName, dir) { - if (_jsAddedCache[moduleName]) return null; - dir = dir || ""; - var jsList = []; - var tempList = moduleMap[moduleName]; - if (!tempList) throw new Error("can not find module [" + moduleName + "]"); - var ccPath = cc.path; - for (var i = 0, li = tempList.length; i < li; i++) { - var item = tempList[i]; - if (_jsAddedCache[item]) continue; - var extname = ccPath.extname(item); - if (!extname) { - var arr = _getJsListOfModule(moduleMap, item, dir); - if (arr) jsList = jsList.concat(arr); - } else if (extname.toLowerCase() === ".js") jsList.push(ccPath.join(dir, item)); - _jsAddedCache[item] = 1; - } - return jsList; -} - function _afterEngineLoaded() { cc._engineLoaded = true; if (CC_EDITOR) { @@ -136,37 +114,9 @@ function _afterEngineLoaded() { if (_engineLoadedCallback) _engineLoadedCallback(); } -function _load(config) { - var CONFIG_KEY = cc.game.CONFIG_KEY, engineDir = config[CONFIG_KEY.engineDir], loader = cc.loader; - - if (cc._Class) { - // Single file loaded - _afterEngineLoaded(); - } else { - // Load cocos modules - var ccModulesPath = cc.path.join(engineDir, "moduleConfig.json"); - loader.load(ccModulesPath, function (err, modulesJson) { - if (err) throw new Error(err); - var modules = config["modules"] || []; - var moduleMap = modulesJson["module"]; - var jsList = []; - if (cc.sys.capabilities["opengl"] && modules.indexOf("base4webgl") < 0) modules.splice(0, 0, "base4webgl"); - else if (modules.indexOf("core") < 0) modules.splice(0, 0, "core"); - for (var i = 0, li = modules.length; i < li; i++) { - var arr = _getJsListOfModule(moduleMap, modules[i], engineDir); - if (arr) jsList = jsList.concat(arr); - } - loader.load(jsList, function (err) { - if (err) throw new Error(JSON.stringify(err)); - _afterEngineLoaded(); - }); - }); - } -} - -function _windowLoaded() { +function _windowLoaded () { window.removeEventListener('load', _windowLoaded, false); - _load(cc.game.config); + _afterEngineLoaded(); } cc.initEngine = function (config, cb) { @@ -193,8 +143,6 @@ cc.initEngine = function (config, cb) { _determineRenderType(config); - document.body ? _load(config) : window.addEventListener('load', _windowLoaded, false); + document.body ? _afterEngineLoaded() : window.addEventListener('load', _windowLoaded, false); _engineInitCalled = true; }; - -})(); diff --git a/cocos2d/core/CCGame.js b/cocos2d/core/CCGame.js index e3f1b58f6c..d797f492d8 100644 --- a/cocos2d/core/CCGame.js +++ b/cocos2d/core/CCGame.js @@ -89,7 +89,7 @@ var game = { CONFIG_KEY: { width: "width", height: "height", - engineDir: "engineDir", + // engineDir: "engineDir", debugMode: "debugMode", exposeClassName: "exposeClassName", showFPS: "showFPS", @@ -611,7 +611,7 @@ var game = { config[CONFIG_KEY.registerSystemEvent] = true; } config[CONFIG_KEY.showFPS] = (CONFIG_KEY.showFPS in config) ? (!!config[CONFIG_KEY.showFPS]) : true; - config[CONFIG_KEY.engineDir] = config[CONFIG_KEY.engineDir] || 'frameworks/cocos2d-html5'; + // config[CONFIG_KEY.engineDir] = config[CONFIG_KEY.engineDir] || 'frameworks/cocos2d-html5'; // Scene parser this._sceneInfos = config[CONFIG_KEY.scenes] || []; diff --git a/jsb/jsb-game.js b/jsb/jsb-game.js index c6a1720371..4e5294332d 100644 --- a/jsb/jsb-game.js +++ b/jsb/jsb-game.js @@ -72,7 +72,7 @@ cc.game = { CONFIG_KEY: { width: 'width', height: 'height', - engineDir: 'engineDir', + // engineDir: 'engineDir', modules: 'modules', debugMode: 'debugMode', showFPS: 'showFPS', @@ -299,7 +299,7 @@ cc.game = { config[CONFIG_KEY.renderMode] = 0; } config[CONFIG_KEY.showFPS] = (CONFIG_KEY.showFPS in config) ? (!!config[CONFIG_KEY.showFPS]) : true; - config[CONFIG_KEY.engineDir] = config[CONFIG_KEY.engineDir] || 'frameworks/cocos2d-html5'; + // config[CONFIG_KEY.engineDir] = config[CONFIG_KEY.engineDir] || 'frameworks/cocos2d-html5'; // Group List and Collide Map this.groupList = config.groupList || []; diff --git a/test/visual-tests/main.js b/test/visual-tests/main.js index 31428321e2..0df72568db 100644 --- a/test/visual-tests/main.js +++ b/test/visual-tests/main.js @@ -56,7 +56,7 @@ // 2 - Forced to use WebGL renderer, but this will be ignored on mobile browsers "engineDir" : "../../frameworks/cocos2d-html5/", - // In debug mode, if you use the whole engine to develop your game, you should specify its relative path with "engineDir", + // (Deprecated) In debug mode, if you use the whole engine to develop your game, you should specify its relative path with "engineDir", // but if you are using a single engine file, you can ignore it. "modules" : ["cocos2d", "extensions", "external"], From 35da9b51917e0581f16531bf7583bfc30856ebc0 Mon Sep 17 00:00:00 2001 From: Jare Guo Date: Fri, 16 Jun 2017 14:50:42 +0800 Subject: [PATCH 2/2] fix ci --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 4d691befe5..d77070e198 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,7 @@ "gulp-util": "3.0.6", "jshint-stylish": "2.1.0", "multipipe": "0.3.0", + "persistify": "^1.1.1", "require-dir": "0.3.0", "uglify-js-harmony": "2.7.7", "vinyl": "1.1.0",