2

I asked at this issue, but I still can't solve a problem. I get error like required "Blockly" namespace never provided .

I follow Google bLockly Advanced Compilation tutorial to try. I did not create a new directory in the Blockly root directory to test, but instead used blockly and closure-library as subdirectories (submodules) in project as below :

project
├─blockly
├─closure-library
├─closure-compiler.jar
├─index.html
└─main.js

Then compile files using the commend as below :

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

Stack Traces

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)

Operating System

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

P.S. I get same errors even I follow all step in the tutorial (same directory structure as tutorial)

1 Answers1

0

Usually the 'Namespace never provided' error is caused by not passing the file that provides that namespace to the compiler. Your directory layout is perfectly fine, but for the actual command I find it's always better to specify what files you want specifically rather than using the ! operator. I see a lot of people having issues with that. I would try the following:

`java -jar closure-compiler.jar --js='main.js' \
  --js='blockly/blocks/**.js' \
  --js='blockly/core/**.js' \
  --js='blockly/generators/**.js' \
  --js='blockly/msg/js/**.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 \
  --output_manifest manifest.MF
  --js_output_file main_compressed.js`

Note that this will allow you see what files are actually being compiled by listing them in manifest.MF.

Alex Dawson
  • 96
  • 2
  • 6