Scratch-blocks: How to build or test locally/offline, to avoid rate-limiting?

Created on 5 Mar 2018  路  6Comments  路  Source: LLK/scratch-blocks

Presently I'm getting this error in my console when I run build.py:

SERVER ERROR: blockly_compressed_vertical.js (for example)
Too many compiles performed recently.  Try again later.

This is a bit annoying. Apparently the only solution is to wait an hour or so until I'm not rate-limited anymore. How can I build scratch-blocks locally, to avoid this?

Apologies if I missed anything in the documentation wiki.

Most helpful comment

  • If you're making changes to only scratch-blocks, you may be able to test locally by opening scratch-blocks/tests/vertical_playground.html in a browser, which will do no compression.
  • If you're making changes only outside scratch-blocks, you can 'npm unlink scratch-blocks' from scratch-gui, and gui will automatically use the latest stable version of scratch-blocks.
  • If you're trying to test changes to gui or vm or other repos and blocks together, you are kind of out of luck. I have hacked around this limit by editing scratch-blocks/dist/vertical.js directly. When you eventually can compile, you have to move all of your changes out of there to the appropriate files, or they will get overwritten.

All 6 comments

Okay, it looks like I can just not build at all and my changes will be reflected. But I'll leave this open, since I'd still like to know if it's at all possible to build compressed versions without being online.

Yeah, unfortunately Closure uses an online compiler that rate limits users, which we can't do much to change, and when you get locked you get locked out for an hour. (from https://developers.google.com/closure/compiler/docs/api-ref).
I'm not totally sure how many compiles it takes to trigger it.

  • If you're making changes to only scratch-blocks, you may be able to test locally by opening scratch-blocks/tests/vertical_playground.html in a browser, which will do no compression.
  • If you're making changes only outside scratch-blocks, you can 'npm unlink scratch-blocks' from scratch-gui, and gui will automatically use the latest stable version of scratch-blocks.
  • If you're trying to test changes to gui or vm or other repos and blocks together, you are kind of out of luck. I have hacked around this limit by editing scratch-blocks/dist/vertical.js directly. When you eventually can compile, you have to move all of your changes out of there to the appropriate files, or they will get overwritten.

@fsih Thanks for the help and clarification! This helps a bunch.

It is definitely possible to build scratch blocks offline--closure has an offline compiler that you can use, and we have instructions + a demo over in Blockly. More on that below.

Separately, you don't need to build to see changes if you're only working in scratch-blocks, as @fsih mentioned above. When you use the uncompressed version, changes are reflected immediately upon a page reload, and you don't need to build unless you're making changes to provides and requires.


Blockly Advanced Compilation/offline compilation instructions.

To compile, follow the instructions in "Download Closure Compiler" and "Install Closure Library". You may already have the closure library if npm is doing everything necessary.

In "Boiler Plate" you don't need to create index.html. You should create main.js and add requires for all of the block types.

In "Compile" you can change the compilation_level to SIMPLE_OPTIMIZATIONS and set the js_output_file to scratch-blocks/dist/vertical.js.

Caveats:

  • I don't know how much you'll have to change to make it work for scratch blocks.
  • I don't know enough about the scratch-blocks + scratch-gui + other repos build process to say exactly how to fit it all together.

I know this is a pain point for development. Blockly team doesn't currently have resources to redo our build process, so unfortunately I can't promise any fast fixes.

Although this is closed because the question was resolved - this is properly fixed in #1471 now :) :tada:

Was this page helpful?
0 / 5 - 0 ratings