mirror of
https://github.com/google/blockly.git
synced 2026-01-07 00:50:27 +01:00
fix!: Export loopTypes from Blockly.blocks.loops (#5900)
* refactor(blocks): Make loopTypes a Set
This is likely to slightly improve performance, especially if there
are many entries.
* refactor(blocks): Re-export individual block modules from Blockly.blocks.all
* fix!(blocks): Have blocks_compressed.js export Blockly.blocks.all
Previously the value obtained by
const blocks = require('blockly/blocks'); // Node.js
or
import blocks from 'blockly/blocks.js'; // ES Modules
would be the block definitions dictionary (Blockly.Blocks).
Change this so that it is instead the export object from
Blockly.blocks.all.
This means you can now access loopTypes via:
import blocks from 'blockly/blocks.js';
blocks.loops.loopTypes.add('my_loop_blocktype');
This is a breaking change for any code which depended on the value
that was exported by blocks_compressed.js.
BREAKING CHANGE: the exports provided by blocks_compressed.js (and
therefore by `import ... from 'blockly/blocks'`) have changed; see above.
This commit is contained in:
committed by
GitHub
parent
9b06fc8853
commit
74ef1cbf52
@@ -108,7 +108,7 @@ const chunks = [
|
||||
{
|
||||
name: 'blocks',
|
||||
entry: 'blocks/all.js',
|
||||
exports: 'Blockly.Blocks',
|
||||
exports: 'Blockly.blocks.all',
|
||||
importAs: 'BlocklyBlocks',
|
||||
},
|
||||
{
|
||||
@@ -321,7 +321,7 @@ function chunkWrapper(chunk) {
|
||||
const cjsDeps = fileNames.map(f => `require(${f})`).join(', ');
|
||||
const browserDeps =
|
||||
chunk.dependencies.map(d => `root.${d.exports}`).join(', ');
|
||||
const imports = chunk.dependencies.map(d => d.importAs).join(', ');
|
||||
const factoryParams = chunk.dependencies.map(d => d.importAs).join(', ');
|
||||
return `// Do not edit this file; automatically generated.
|
||||
|
||||
/* eslint-disable */
|
||||
@@ -333,7 +333,7 @@ function chunkWrapper(chunk) {
|
||||
} else { // Browser
|
||||
root.${chunk.exports} = factory(${browserDeps});
|
||||
}
|
||||
}(this, function(${imports}) {
|
||||
}(this, function(${factoryParams}) {
|
||||
${chunk.factoryPreamble || FACTORY_PREAMBLE}
|
||||
%output%
|
||||
${chunk.factoryPostamble || FACTORY_POSTAMBLE}
|
||||
|
||||
Reference in New Issue
Block a user