My project based on google closure (including deriving classes ecosystem and compiler) and I want to start develop on Cocos Creator as a game engine. But it looks as for now support of third party modules is limited. Do you have any plans in near updates to provide better support for goog closure library?
Hi!
Thank you for pointing me to this link! I have read English version but Chinese version has more info.
As I understand I need to merge all goog closure scripts into one large script. But another question how to use classes from it. Closure library has no module.exports for types. Also how I can control load priority of scripts. I need first to load closure after that load my project scripts. When I have added module.exports in base.js and then use const goog = require(“base”); goog.provide(“com.lib.classname”); in my script I receive that goog.provide not a function error in Creator console. When I looking project.dev.js I see that base.js included at the end of the file causing such error. Follow that I have two questions:
Is there any way I can control load priority in Cocos Creator to load base.js and other closure dependencies first?
In development mode Google Closure using dependency writer for creating dependency.js that use for load scripts in right order to the dom. if loading to the dom not the case Google Closure provide the possibility to override CLOSURE_IMPORT_SCRIPT function to populate dependency manually and load it on own way.
It would be nice if Cocos Creator will provide option for control over plugins script loading.
Sorry no other kind of priority for now. In creator, the only way is combine your plugin scripts into one file. I think you should use https://developers.google.com/closure/library/docs/closurebuilder. But if Closure is still to complex to do so, you can just override the static/build-templates/*/*/index.html and load Closure in it.
Thanks for reply! Merging closure library in development mode is uncomfortably.
In my case I use WebStorm for coding and Cocos Creator for UI creation, building project and JSB debugging. Each time before launch dependency writer script provided by closure executed to build right order for script loading. It would be great if Cocos Creator will provide in future possibility to control script loading. For example, this may be done by launching special js script which populate custom order of scripts loading on before build event. In this case it’s possible to use output script from tools like dependency writer provided by closure or put manual logic. Hope that my feedback will be helpful for Cocos Team.