我问过这个问题,但我仍然无法解决问题。我收到类似的错误required "Blockly" namespace never provided
。
我按照Google bLockly
高级编译教程进行尝试。我没有在 Blockly 根目录中创建新目录进行测试,而是在项目中使用blockly
和closure-library
作为子目录(子模块),如下所示:
project
├─blockly
├─closure-library
├─closure-compiler.jar
├─index.html
└─main.js
然后使用如下命令编译文件:
java -jar closure-compiler.jar --js='main.js' ^
--js='./blockly/**.js' ^
--js='!./blockly/externs/**.js' ^
--js='!./blockly/msg/messages.js' ^
--js='./closure-library/closure/goog/**.js' ^
--js='./closure-library/third_party/closure/goog/**.js' ^
--generate_exports ^
--externs ./blockly/externs/svg-externs.js ^
--compilation_level ADVANCED_OPTIMIZATIONS ^
--dependency_mode=STRICT --entry_point=Main ^
--js_output_file main_compressed.js
堆栈跟踪
main.js:3: ERROR - required "Blockly.Msg.en" namespace never provided
goog.require('Blockly.Msg.en');
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
main.js:5: ERROR - required "Blockly" namespace never provided
goog.require('Blockly');
^^^^^^^^^^^^^^^^^^^^^^^
main.js:7: ERROR - required "Blockly.Constants.Logic" namespace never provided
goog.require('Blockly.Constants.Logic');
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
main.js:8: ERROR - required "Blockly.Constants.Loops" namespace never provided
goog.require('Blockly.Constants.Loops');
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
main.js:9: ERROR - required "Blockly.Constants.Math" namespace never provided
goog.require('Blockly.Constants.Math');
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
main.js:10: ERROR - required "Blockly.Constants.Text" namespace never provided
goog.require('Blockly.Constants.Text');
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6 error(s), 0 warning(s)
操作系统
OS: Windows 7
java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)
Closure Compiler Version: v20180204
PS即使我按照教程中的所有步骤操作,我也会遇到相同的错误(与教程相同的目录结构)