Development tools

Blockly uses some tools and libraries for development, including Git, npm, and the Closure Compiler. This section will provide some basic descriptions of each tool, as well as links to where you can find more information about each tool.

We use many of these tools through scripts. You may not need to ever run them directly. Knowing the names may still be helpful for debugging or filing issues or feature requests.

Git

Git is a version control system that we use to track and manage changes to files.

GitHub

GitHub is a hosting platform for version control, collaboration, and distribution of open-source code. Git tracks the files; GitHub provides smooth interfaces for reviewing code, tracking issues, and viewing change history.

Getting started: If you're new to Git and GitHub, work through GitHub's quickstart tutorials to get comfortable with the basics.

Node

Node.js is a way to run JavaScript on the server (rather than in a browser). npm (see below) runs on Node.

npm

npm is two things:

  • A command-line tool that we use to install dependencies and run scripts.
  • An online registry where we publish our code, which makes it easy for other developers to use Blockly.

Getting started: Install Node and npm.

Closure Compiler

The Closure Compiler is a tool for making JavaScript download and run faster. We use it to combine all of our JavaScript files into a single library; we also use it to check syntax and types.

Getting started: You don't need to install or run the Closure Compiler directly: we install and run it through npm.

Read more: Closure compiler documentation on JavaScript types and type annotations.

ESLint

ESLint is a static analyzer that finds problems with JavaScript code. We use it to define and enforce a consistent style across our codebase. Small problems with code (missing semicolons, inconsistent spacing, etc.) are often called lint. ESLint automatically runs when you send us a pull request. You can also run it locally.

Getting started: In both Blockly core and blockly-samples, you can run ESLint with npm run lint. Many code editors also have ESLint integrations to show problems as you type.

Read more: Each ESLint rule has a documentation page that describes the rule and gives examples of correct and incorrect code.

Mocha

Mocha is a JavaScript test framework. We use it to run tests in the browser and on Node.js (for headless use cases).

Getting started: In both Blockly core and blockly-samples, you can run our Mocha tests with npm run test. In Blockly core this will also run other tests. Blockly core's Mocha tests are defined in the tests/mocha directory.

Read more: Mocha allows developers to define hooks, which allow you to define centralized setup and teardown functions for your tests.

Chai

Chai is an assertion library that we use in our Mocha tests.

Read more: Chai has multiple "flavors" of syntax, to make it easy to integrate with existing projects. Blockly uses the assert flavor.