Blockly v11 Beta Program: v11.0.0-beta.4

18 views
Skip to first unread message

Christopher Allen

unread,
Mar 18, 2024, 8:20:03 PM3/18/24
to blo...@googlegroups.com
This is the third in what we expect will be a series of beta releases for the future v11 of Blockly. See information about the Blockly v11 Beta Program.

Wait, -beta.4? What happened to .2 and .3?

The keen npmjs.com watches amongst you (hi, @dependabot!) will have noted that, since the last publicly-announce beta, v11.0.0-beta.1, there have been two additional betas published to npmjs.com. These were created to facilitate development and testing of work in the blockly-samples repository, and all the changes from those two unpublicised releases are rolled into the changelist below.

Highlights in v11.0.0-beta.4

Valid entrypoints specified by exports directive in package.json

The most important change in v11.0.0-beta.4 is actually a change to the packaging, rather than the contents of the package.

Specifically, we have added an exports directive, to the package.json file, which definitively enumerates the valid entrypoints for the package. The purpose of this change is to prepare for the publication of ES module entrypoints, that will supplement (and ultimately supplant) the existing CommonJS module entrypoints, in future versions of Blockly.

Adding an exports section:

  • Allows us to definitively enumerate the permitted entrypoints for the package, disallowing direct importation of any other files.
  • Allows us to change which file each individual entrypoint actually loads without it necessarily being a breaking change.
  • Allows us to specify separate ESM entrypoints for subpaths (like blockly/javascript); without exports all subpath entrypoints must be either ESM or CJS and it is not possible to provide both.

Aside: module resolution

Module resolution is ultimately at the discretion of each JS runtime or build tool. Browsers, node.js, Webpack, Closure Compiler, etc. each have their own module resolution and loading implementations. The package.json file was originally for the benefit of npm in its role of installing packages and their dependencies, but now contains additional information (like the browserexportsmainumd, and unpkg directives) that are honoured to varying degrees by different tools. It is therefore hard to say categorically what file(s) will be loaded by which tools without consulting each tool's documentation (and/or implementation), but amongst tools that have some kind of support for NPM packages, the exports directive appears to be widely and consistently supported.

Here is some of the relevant documentation for tools we expect Blockly developers are likely to use:

Valid entrypoints and what they provide

BREAKING CHANGE: The introduction of an exports directive means that correctly-behaved tools (node.js, bundlers like webpack, etc.) will only allow importing of the specified entrypoints. Here is the full list of permitted entrypoints that can be imported or required:

  • blockly
  • blockly/core
  • blockly/blocks
  • blockly/dart
  • blockly/lua
  • blockly/javascript
  • blockly/php
  • blockly/python
  • blockly/msg/<lang>, for all supported language codes <lang> (e.g blockly/msg/enblockly/msg/frblockly/msg/de, etc.)

If you previously imported any other paths from the blockly package you will need to update your imports. Here are the most common paths that may have been used, and their correct replacements:

If you previously imported:Import instead:
blockly/index.jsblockly
blockly/node.jsblockly
blockly/browser.jsblockly
blockly/blockly.minThis file should only be loaded as a <script>.
blockly/core.jsblockly/core
blockly/core-browser.jsblockly/core
blockly/blockly_compressed.jsblockly/core
blockly/blocks.jsblockly/blocks
blockly/blocks_compressed.jsblockly/blocks
blockly/dart.jsblockly/dart
blockly/dart_compressed.jsblockly/dart
blockly/lua.jsblockly/lua
blockly/lua_compressed.jsblockly/lua
blockly/javascript.jsblockly/javascript
blockly/javascript_compressed.jsblockly/javascript
blockly/php.jsblockly/php
blockly/php_compressed.jsblockly/php
blockly/python.jsblockly/python
blockly/python_compressed.jsblockly/python
blockly/msg/en.jsblockly/msg/en

If you are loading Blockly as a script you should continue to load the compiled chunks (blockly_compressed.jsblocks_compressed.jsjavascript_compressed.js, etc.) directly, or load blockly.min.js which is just a concatenation of blockly_compressed.jsmsg/en.jsblocks_compressed.js, and javascript_generator.js.

(Prior to v11 there were various entrypoint wrappers provided in the form of UMD modules (e.g. blockly.jsjavascript.js, etc.) but loading these as as scripts never did anything useful and, as they are no longer needed, they have been deleted.)

BREAKING CHANGE: Prior to v11, importing the main blockly package would import blockly/coreblockly/blocksblockly/msg/en and blockly/javascript—and additionally, in node.js, also blockly/dartblockly/luablockly/php and blockly/python.

Now the main blockly package entrypoint never loads any of the generators.

This change has been made because of changes to generator exports made in blockly v9.0.0 that make necessary to always separately import generator modules in order to use them.

Note that this change does not affect loading the blockly package via <script src="https://unpkg.com/blockly">; that continues to load to blockly.min.js, which continues to include javascript_compressed.js which (when loaded as a script) makes itself available via Blockly.JavaScript for backwards compatibility.

Field, block and generator changes

BREAKING CHANGE: The angle, colour and multiline input fields (FieldAngleFieldColour and FieldMultilineInput respectively) have been deleted from Blockly. All three are now provided as plugins. The blocks associated with the colour field and multiline text field have been moved to the field plugins, which now provide documentation on how to install the blocks.

BREAKING CHANGE: Code emitted by the LuaGenerator now uses nil instead of None. This may break some user's downstream block programs if they are assigning to a variable called None and then initializing lists with empty inputs expecting them to contain the value assigned to None.

Other changes

There were also breaking changes to block disposal and to certain CSS classes, as well as other changes made for v11 and/or rolled up from v10; see below for the complete list.

What's Changed

Breaking changes 🛠

  • fix!: have Lua generators use 'nil' instead of 'None' by @BeksOmega in #7837
  • fix!: have disposing be true from start of dispose by @BeksOmega in #7891
  • feat!: delete angle, colour, and multiline input fields and blocks by @rachel-fenichel in #7932
  • fix!: classes on text input bubble to match comment view by @BeksOmega in #7935
  • feat(build)!: Introduce exports section in package.json by @cpcallen in #7822

New features ✨

Bug fixes 🐛

  • fix: prevent console logging duplicate deprecation warnings by @ebrahim95 in #7733
  • fix: triggering flyout show from field render causing infinite loop by @BeksOmega in #7784
  • fix: cancelling all renders on triggering queued renders by @BeksOmega in #7787
  • fix: first block dragged from flyout will have same id by @maribethb in #7788
  • fix: prevent block change event firing if editing is cancelled by using keypress by @ebrahim95 in #7794
  • fix: shadow blocks with variable fields are allowed to be deserialized from XML by @ebrahim95 in #7802
  • fix: export save and load procedure by @BeksOmega in #7806
  • fix: manually add typings for generator classes by @maribethb in #7824
  • fix: destroy connection highlight when the connection is disposed by @BeksOmega in #7830
  • fix: fix reference docs toc generation by @maribethb in #7832
  • fix: insertion marker previewer finding wrong connection for different conn counts by @BeksOmega in #7833
  • fix: disposing of connection previewer by @BeksOmega in #7834
  • fix: connection previewer disposing too early by @BeksOmega in #7859
  • fix: typo in Click event class docs by @elvisvoer in #7854
  • fix: insertion marker drag scaling by @BeksOmega in #7874
  • fix: restore respecting snap radius by @BeksOmega in #7873
  • fix: libraryBlocks exports by @devilhyt in #7886
  • fix: shouldPreventMove not being respected by @BeksOmega in #7894
  • fix: connection dancing by @BeksOmega in #7899
  • fix: comment min size by @BeksOmega in #7915
  • fix: updated field_dropdown to properly infer its Field type with TS 5.3.3 by @btw17 in #7939
  • fix(generators): Make scrub_ public by @cpcallen in #7940

Other changes

New Contributors

Full Changelogblockly-v11.0.0-beta.1...blockly-v11.0.0-beta.4
All changes to date in v11:blockly-v10.4.3...blockly-v11.0.0-beta.4

Reply all
Reply to author
Forward
0 new messages