Hi block builders!
The Q4 2021 Blockly release is here, and it’s a big one. (Full release notes are on Github.) Over the past two quarters we overhauled the core codebase and changed every file in core to use ES6 syntax and Closure modules. The migration touched every file in core but left our external-facing APIs mostly unchanged. The devil is in the details here, so read through the Breaking Changes section at the end of the email to learn more.
TypeScript and Blockly
ES6 and Closure modules were both stepping stones on the path to TypeScript. Next quarter we will start integrating the TypeScript compiler and tooling. The optimistic timeline for converting to Typescript is Q1 2022; the pessimistic timeline is Q2 2022.
The good news: We have TypeScript declaration files ready this quarter. The bad news: changing to Closure modules broke our previous workflow for generating TypeScript declaration files, so these files are heavily hand-edited to ensure they compile. If you find problems, we’re accepting manual changes and may release patch versions as needed.
Why all the big changes?
We are moving Blockly and the Blockly community toward a plugin model, as I laid out in the roadmap last year. Modernizing our codebase lets us clarify our APIs and keep private properties private. It also makes your lives easier when you want to contribute: you no longer have to keep track of which language features are supported in Internet Explorer when you make a PR. This also helps us to make core Blockly more modular, which means that developers can extend Blockly in interesting ways without needing to fork the library. In turn, we hope this leads to a stronger developer community and more code sharing and reuse through plugins.
I'm incredibly proud of the team for their work: a migration on this scale feels like changing a tire while driving, and we did it while (still) working remotely.
Finally, thank you to everyone who contributed this quarter; to everyone who helped us test; and to those of you who have been active on the forum and helping each other.
Cheers,
Rachel
🔨 Breaking Changes in Core 🔨
Overriding private properties or methods on a namespace will probably not work now. Ideally, you haven’t been doing this as we’ve announced that private properties and methods are subject to change. Overriding them will no longer work because private properties are often not exported from a module at all. Overriding an entire class (e.g. `Blockly.WorkspaceSvg = MyCustomWorkspace`) may still work, but is not officially supported and may not continue to work. If you’re doing this, please get in touch with us on the forum to help us understand your use case and figure out a workaround. Some classes can register their own replacement (e.g. rather than override the MetricsManager, you can register a class for us to use) and in other cases we may need to add or have already added public APIs to accomplish your goals.
All themes other than classic and zelos have been moved out of core. They can be found on npm.
Breaking changes related to the JSON Serializer:
Removing Flyout.createBlock_ from the public API
Removing Flyout.clearOldBlocks_ from the public API
Blockly.Events.BlockChange newValue/oldValue can now be stringified JSON if the block provides JSON hooks
This is breaking because core blocks now provide JSON hooks
Node 10 is no longer supported.
Many functions have been moved or renamed, particularly those in blockly.js (i.e. top-level properties of the Blockly namespace such as Blockly.selected). While this is not currently a breaking change as these functions have all been aliased and deprecated, they will be removed in a future release and we encourage you to update usages.
See scripts/migration/renamings.js for a full list of renamings.
Watch out for
Type declaration issues.
Size: blockly-compressed grew significantly. We have some mitigations planned, but keep it in mind if you are size-constrained.
Deprecation warnings: check the console. Where possible we included a pointer to the replacement.