Skip to content

Commit

Permalink
Handle CommonJS modules.
Browse files Browse the repository at this point in the history
  • Loading branch information
afshin committed Oct 12, 2017
1 parent 105508a commit d383d68
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 12 deletions.
1 change: 1 addition & 0 deletions jupyterlab/commands.py
Expand Up @@ -753,6 +753,7 @@ def _toggle_extension(extension, value, app_dir=None, logger=None):
"""
app_dir = get_app_dir(app_dir)
extensions = _get_extensions(app_dir)
config = _get_build_config(app_dir)
disabled = config.get('disabledExtensions', [])
if value and extension not in disabled:
disabled.append(extension)
Expand Down
26 changes: 20 additions & 6 deletions jupyterlab/index.app.js
Expand Up @@ -64,8 +64,15 @@ function main() {
}
if (!isDisabled('{{@key}}')) {
var module = require('{{@key}}/{{this}}');
if (Array.isArray(module.default)) {
module.default.forEach(function(plugin) {
var extension = module.default;

// Handle CommonJS exports.
if (!module.hasOwnProperty('__esModule')) {
extension = module;
}

if (Array.isArray(extension)) {
extension.forEach(function(plugin) {
if (isDeferred(plugin.id)) {
ignorePlugins.push(plugin.id);
}
Expand All @@ -74,7 +81,7 @@ function main() {
}
});
} else {
mimeExtensions.push(module);
mimeExtensions.push(extension);
}
}
} catch (e) {
Expand All @@ -100,8 +107,15 @@ function main() {
}
if (!isDisabled('{{@key}}')) {
var module = require('{{@key}}/{{this}}');
if (Array.isArray(module.default)) {
module.default.forEach(function(plugin) {
var extension = module.default;

// Handle CommonJS exports.
if (!module.hasOwnProperty('__esModule')) {
extension = module;
}

if (Array.isArray(extension)) {
extension.forEach(function(plugin) {
if (isDeferred(plugin.id)) {
ignorePlugins.push(plugin.id);
}
Expand All @@ -110,7 +124,7 @@ function main() {
}
});
} else {
lab.registerPluginModule(module);
lab.registerPluginModule(extension);
}
}
} catch (e) {
Expand Down
26 changes: 20 additions & 6 deletions jupyterlab/index.js
Expand Up @@ -64,8 +64,15 @@ function main() {
}
if (!isDisabled('{{@key}}')) {
var module = require('{{@key}}/{{this}}');
if (Array.isArray(module.default)) {
module.default.forEach(function(plugin) {
var extension = module.default;

// Handle CommonJS exports.
if (!module.hasOwnProperty('__esModule')) {
extension = module;
}

if (Array.isArray(extension)) {
extension.forEach(function(plugin) {
if (isDeferred(plugin.id)) {
ignorePlugins.push(plugin.id);
}
Expand All @@ -74,7 +81,7 @@ function main() {
}
});
} else {
mimeExtensions.push(module);
mimeExtensions.push(extension);
}
}
} catch (e) {
Expand All @@ -100,8 +107,15 @@ function main() {
}
if (!isDisabled('{{@key}}')) {
var module = require('{{@key}}/{{this}}');
if (Array.isArray(module.default)) {
module.default.forEach(function(plugin) {
var extension = module.default;

// Handle CommonJS exports.
if (!module.hasOwnProperty('__esModule')) {
extension = module;
}

if (Array.isArray(extension)) {
extension.forEach(function(plugin) {
if (isDeferred(plugin.id)) {
ignorePlugins.push(plugin.id);
}
Expand All @@ -110,7 +124,7 @@ function main() {
}
});
} else {
lab.registerPluginModule(module);
lab.registerPluginModule(extension);
}
}
} catch (e) {
Expand Down

0 comments on commit d383d68

Please sign in to comment.