Required namespace "goog.events.EventWrapper" never defined.
FATAL ERROR Required namespace "goog.events.EventWrapper" never defined. ??? at line 55: goog.requireType('goog.events.EventWrapper');
I am getting this error when I compile remotely! Actually, this is from scratch-blocks! However, I am not sure where is the error coming from!
Operating System and Browser Mac OS 10.15.4 Chrome 83.0.4103.116
@niloc132 It would be so helpful if you can look into this issue. Thank you!
Hi Brijesh! Can you please link us to a repro if you have one, or describe how you are building your code? It's possible that the file defining that namespace was not included in the build.
Hello @rrdelaney
Thank you for replying!
Things I am using:
google-closure-library: 20180402.0.0
google-closure-compiler: 20180204.0.0
I am using scratch blocks, https://github.com/LLK/scratch-blocks.git My build.py, https://github.com/LLK/scratch-blocks/blob/develop/build.py is using remote google closure compiler
And I think there were some changes in closure-lirabry according to this issue, https://github.com/google/closure-library/issues/1076
Are you saying this is the error you get when trying to compile that project after installing all the npm dependencies? By "remote google closure compiler" do you mean the hosted web service? If that is failing, can you provide us with the request you are sending that fails to compile?
This function at https://github.com/LLK/scratch-blocks/blob/ad0dc1d38c05295cb26cd71f0ae59315d6667447/build.py#L344 sends the request to closure-compiler.appspot.com
It will be so helpful if you can have a look! Thank you!
I am not sure how that build script works, but I can help debug issues with the Closure Compiler. Can you please paste the request being sent?
@rrdelaney Thank you so much for making me look at the things where I was not looking! And scratch-blocks at https://github.com/LLK/scratch-blocks also been updated!
Again Thank you so much! This error took three days!
@Brijeshlakkad I'm having the same error with this https://github.com/sensebox/ardublockly-1/blob/master/blockly/build.py build script. Seems that you solved the issue can you explain how?
Thank you!
@mariopesch
I am able to solve it by doing these things specifically! I am pretty sure that these things solved the issue because, in the second machine of mine, I solved this issue:
Steps:
- installed the google closure compiler locally using,
npm i google-closure-compiler -g - In mac, I changed the xcode-select path to /Library/Developer/CommandLineTools
- remove closure-library at the root of the project (In Scratch, Project I was putting the closure-library (google-closure-library, at the outside of scratch-blocks, at the root of the project in short))
And It seems that your build.py only does remote compilation! It is better that there will be a way to compile locally! Steps 1 to 3 will make your compiling of the files locally and don't forget to update your build.py like https://github.com/LLK/scratch-blocks/blob/develop/build.py
Happy coding :)
@rrdelaney Issue still exists for me when compiling with the online compiler. Why is it closed when @Brijeshlakkad simply changed to using the local compiler without actually resolving the error on the online compiler?
HTTPS POSTS request was made to closure-compiler.appspot.com/compile with the following body: compilation_level=SIMPLE_OPTIMIZATIONS&
use_closure_library=true&
output_format=json&
output_info=compiled_code&
output_info=warnings&
output_info=errors&
output_info=statistics&
language=ECMASCRIPT6
code to be compressed is inline using js_code param which is the list of files from https://github.com/BlocklyDuino/BlocklyDuino/tree/gh-pages/blockly/core
blocks.js workspace.js bubble.js icon.js comment.js connection.js field.js tooltip.js field_label.js input.js scrollbar.js trashcan.js xml.js workspace_svg.js mutator.js warning.js block.js contextmenu.js block_svg.js msg.js field_textinput.js field_angle.js field_checkbox.js field_colour.js field_dropdown.js field_image.js variables.js field_variable.js generator.js names.js procedures.js realtime-client-utils.js realtime.js flyout.js toolbox.js css.js widgetdiv.js inject.js utils.js blockly.js
Ok I modified the build file to use code_url instead of js_code. First build came back with File too large error.
But next build had FATAL ERROR Parse error. primary expression expected ??? at line 6:
The request body was: compilation_level=SIMPLE_OPTIMIZATIONS& output_format=json& output_info=compiled_code& output_info=warnings& output_info=errors& output_info=statistics& js_code=goog.provide%28%27Blockly.Blocks%27%29%3B& code_url=https%3A%2F%2Fgithub.com%2FBlocklyDuino%2FBlocklyDuino%2Ftree%2Fgh-pages%2Fblockly%2Fblocks%2Fbase.js& code_url=https%3A%2F%2Fgithub.com%2FBlocklyDuino%2FBlocklyDuino%2Ftree%2Fgh-pages%2Fblockly%2Fblocks%2Fcolour.js& code_url=https%3A%2F%2Fgithub.com%2FBlocklyDuino%2FBlocklyDuino%2Ftree%2Fgh-pages%2Fblockly%2Fblocks%2Fgrove.js& code_url=https%3A%2F%2Fgithub.com%2FBlocklyDuino%2FBlocklyDuino%2Ftree%2Fgh-pages%2Fblockly%2Fblocks%2Flists.js& code_url=https%3A%2F%2Fgithub.com%2FBlocklyDuino%2FBlocklyDuino%2Ftree%2Fgh-pages%2Fblockly%2Fblocks%2Flogic.js& code_url=https%3A%2F%2Fgithub.com%2FBlocklyDuino%2FBlocklyDuino%2Ftree%2Fgh-pages%2Fblockly%2Fblocks%2Floops.js& code_url=https%3A%2F%2Fgithub.com%2FBlocklyDuino%2FBlocklyDuino%2Ftree%2Fgh-pages%2Fblockly%2Fblocks%2Fmath.js& code_url=https%3A%2F%2Fgithub.com%2FBlocklyDuino%2FBlocklyDuino%2Ftree%2Fgh-pages%2Fblockly%2Fblocks%2Fprocedures.js& code_url=https%3A%2F%2Fgithub.com%2FBlocklyDuino%2FBlocklyDuino%2Ftree%2Fgh-pages%2Fblockly%2Fblocks%2Ftext.js& code_url=https%3A%2F%2Fgithub.com%2FBlocklyDuino%2FBlocklyDuino%2Ftree%2Fgh-pages%2Fblockly%2Fblocks%2Fvariables.js& language=ECMASCRIPT6
@leongwaikay this is most likely an issue with the code being sent to the compiler, rather than with the compiler itself. Can you provide a minimal reproduction of this outside of your build system?
Hi there,
I was able to fix the Required namespace "goog.events.EventWrapper" never defined error by simply adding the imports
goog.require('goog.debug.ErrorHandler');
goog.require('goog.events.EventWrapper');
to the core file ( blockly/core/blockly.js in my case ).
As mentioned in this issue, some requires were added in the closure compiler, so, in order to fix the error, you have to require them in your project as well.
Thanks. I found a fork with a build.py that uses a local compiler. I did try to add the two lines you mentioned using js-code flag but it didn't seem to work.