diff --git a/src/extension-support/extension-manager.js b/src/extension-support/extension-manager.js index eed64ce9b..4d4e2d283 100644 --- a/src/extension-support/extension-manager.js +++ b/src/extension-support/extension-manager.js @@ -7,32 +7,21 @@ const BlockType = require('./block-type'); // These extensions are currently built into the VM repository but should not be loaded at startup. // TODO: move these out into a separate repository? // TODO: change extension spec so that library info, including extension ID, can be collected through static methods -const Scratch3PenBlocks = require('../extensions/scratch3_pen'); -const Scratch3WeDo2Blocks = require('../extensions/scratch3_wedo2'); -const Scratch3MusicBlocks = require('../extensions/scratch3_music'); -const Scratch3MicroBitBlocks = require('../extensions/scratch3_microbit'); -const Scratch3Text2SpeechBlocks = require('../extensions/scratch3_text2speech'); -const Scratch3TranslateBlocks = require('../extensions/scratch3_translate'); -const Scratch3VideoSensingBlocks = require('../extensions/scratch3_video_sensing'); -const Scratch3Speech2TextBlocks = require('../extensions/scratch3_speech2text'); -const Scratch3Ev3Blocks = require('../extensions/scratch3_ev3'); -const Scratch3MakeyMakeyBlocks = require('../extensions/scratch3_makeymakey'); -// todo: only load this extension once we have a compatible way to load its -// Vernier module dependency. -// const Scratch3GdxForBlocks = require('../extensions/scratch3_gdx_for'); const builtinExtensions = { - pen: Scratch3PenBlocks, - wedo2: Scratch3WeDo2Blocks, - music: Scratch3MusicBlocks, - microbit: Scratch3MicroBitBlocks, - text2speech: Scratch3Text2SpeechBlocks, - translate: Scratch3TranslateBlocks, - videoSensing: Scratch3VideoSensingBlocks, - speech2text: Scratch3Speech2TextBlocks, - ev3: Scratch3Ev3Blocks, - makeymakey: Scratch3MakeyMakeyBlocks - // gdxfor: Scratch3GdxForBlocks + pen: () => require('../extensions/scratch3_pen'), + wedo2: () => require('../extensions/scratch3_wedo2'), + music: () => require('../extensions/scratch3_music'), + microbit: () => require('../extensions/scratch3_microbit'), + text2speech: () => require('../extensions/scratch3_text2speech'), + translate: () => require('../extensions/scratch3_translate'), + videoSensing: () => require('../extensions/scratch3_video_sensing'), + speech2text: () => require('../extensions/scratch3_speech2text'), + ev3: () => require('../extensions/scratch3_ev3'), + makeymakey: () => require('../extensions/scratch3_makeymakey') + // todo: only load this extension once we have a compatible way to load its + // Vernier module dependency. + // gdxfor: () => require('../extensions/scratch3_gdx_for') }; /** @@ -133,7 +122,7 @@ class ExtensionManager { return Promise.reject(new Error(message)); } - const extension = builtinExtensions[extensionURL]; + const extension = builtinExtensions[extensionURL](); const extensionInstance = new extension(this.runtime); return this._registerInternalExtension(extensionInstance).then(serviceName => { this._loadedExtensions.set(extensionURL, serviceName);