mirror of
https://github.com/google/blockly.git
synced 2026-01-06 16:40:07 +01:00
refactor: Rename Blockly.Blocks, migrate to named exports (#5515)
* Rename Blockly.Blocks to Blockly.blocks Because it does not export a type as its default export. Part of #5073. * Name default export of Blockly.blocks Blocks. Use named exports in Blockly.blocks by giving the former default export the name Blocks. Part of #5153. * Reexport Blockly.blocks from blockly.js * Document the format of renamings.js better.
This commit is contained in:
committed by
GitHub
parent
f931b2eb36
commit
16b6d4526a
@@ -20,6 +20,64 @@
|
||||
* @type {Object<string, ?>}
|
||||
*/
|
||||
const renamings = {
|
||||
// Example entry:
|
||||
'0.0.0': { // These renaming were made after version 0.0.0 was published.
|
||||
// Each entry is keyed by the original module name.
|
||||
'module.name.Old': {
|
||||
// If the module has been renamed, its new name will be listed.
|
||||
module: 'module.name.new',
|
||||
|
||||
// Modules which had a default export that has been turned into
|
||||
// a named export the new name will be given.
|
||||
export: 'defaultName',
|
||||
|
||||
// For backward-compatibility reasons, we may choose to continue
|
||||
// to reexport default exports in the same place in the Blockly
|
||||
// tree that they were previously (or nearby). If so, the full
|
||||
// path to the former default export will be listed. This path
|
||||
// is only relevant to code that accesses the export via the
|
||||
// namespace tree rather than by a named import.
|
||||
//
|
||||
// The given example implies that:
|
||||
// module.name.Old ===
|
||||
// goog.require('module.name.new').defaultExport
|
||||
// which may not be what what one expects but is very handy.
|
||||
path: 'module.name.Old',
|
||||
// If path is not given explicitly then it can be assumed to be
|
||||
// `${module}.${export}`.
|
||||
|
||||
// Modules which already had named exports can instead list
|
||||
// information about exports which have been renamed or moved in
|
||||
// the exports subsection, which is a map from old export name
|
||||
// to object with info about the new export name.
|
||||
exports: {
|
||||
oldExportName: { // No need to quote this.
|
||||
|
||||
// If the export has been moved to a different module, that
|
||||
// module is listed.
|
||||
module: 'module.name.other',
|
||||
|
||||
// If the export has been given a new name, that is listed.
|
||||
export: 'newExportName',
|
||||
|
||||
// As with default exports, if a named export has been
|
||||
// reexported on the namespace tree somewhere other than at
|
||||
// `${module}.${export}` then that can specified explicitly.
|
||||
path: 'module.name.Old.oldExportName',
|
||||
// This given example implies that code that previously
|
||||
// accessed this export via module.name.Old.oldExportName
|
||||
// can continue to do so; only code using named requires
|
||||
// needs to update from
|
||||
// goog.require('module.name.Old').oldExportName
|
||||
// to
|
||||
// goog.require('module.name.new').newExportName
|
||||
},
|
||||
// More individual exports in this module can be listed here.
|
||||
},
|
||||
},
|
||||
// More modules with renamings can be listed here.
|
||||
},
|
||||
|
||||
'4.20201217.0': {
|
||||
'Blockly': {
|
||||
exports: {
|
||||
@@ -93,6 +151,11 @@ const renamings = {
|
||||
},
|
||||
},
|
||||
},
|
||||
'Blockly.Blocks': {
|
||||
module: 'Blockly.blocks',
|
||||
export: 'Blocks', // Previous default export now named.
|
||||
path: 'Blockly.Blocks', // But still on tree with original name.
|
||||
},
|
||||
'Blockly.ContextMenu': {
|
||||
exports: {
|
||||
currentBlock: {get: 'getCurrentBlock', set: 'setCurrentBlock'},
|
||||
|
||||
Reference in New Issue
Block a user