From aaa66bf7b04154cc1c2a2d8335ffd664fed348cf Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Mon, 20 Nov 2017 11:02:08 -0600 Subject: [PATCH] Refactor module layout --- js/package.json | 2 +- js/src/index.js | 17 ++++++----------- js/src/{labplugin.js => lab_extension.js} | 0 js/src/{extension.js => nb_extension.js} | 0 js/src/nb_index.js | 12 ++++++++++++ js/webpack.config.js | 4 ++-- 6 files changed, 21 insertions(+), 14 deletions(-) rename js/src/{labplugin.js => lab_extension.js} (100%) rename js/src/{extension.js => nb_extension.js} (100%) create mode 100644 js/src/nb_index.js diff --git a/js/package.json b/js/package.json index d7a876cc..e25cd9c7 100644 --- a/js/package.json +++ b/js/package.json @@ -18,7 +18,7 @@ "watch": "webpack --watch" }, "jupyterlab": { - "extension": "src/labplugin" + "extension": "src/lab_plugin" }, "devDependencies": { "fs-extra": "^4.0.2", diff --git a/js/src/index.js b/js/src/index.js index 6c0b1ea3..d2fe43f1 100644 --- a/js/src/index.js +++ b/js/src/index.js @@ -1,12 +1,7 @@ -// Entry point for the notebook bundle containing custom model definitions. -// -// Setup notebook base URL -// -// Some static assets may be required by the custom widget javascript. The base -// url for the notebook is not known at build time and is therefore computed -// dynamically. -__webpack_public_path__ = document.querySelector('body').getAttribute('data-base-url') + 'nbextensions/jupyter-matplotlib/'; +var MPLCanvasModel = require('./mpl_widget').MPLCanvasModel; +var MPLCanvasView = require('./mpl_widget').MPLCanvasView; -// Export widget models and views, and the npm package version number. -module.exports = require('./mpl_widget.js'); -module.exports['version'] = require('../package.json').version; +module.exports = { + MPLCanvasModel: MPLCanvasModel, + MPLCanvasView: MPLCanvasView +} diff --git a/js/src/labplugin.js b/js/src/lab_extension.js similarity index 100% rename from js/src/labplugin.js rename to js/src/lab_extension.js diff --git a/js/src/extension.js b/js/src/nb_extension.js similarity index 100% rename from js/src/extension.js rename to js/src/nb_extension.js diff --git a/js/src/nb_index.js b/js/src/nb_index.js new file mode 100644 index 00000000..6c0b1ea3 --- /dev/null +++ b/js/src/nb_index.js @@ -0,0 +1,12 @@ +// Entry point for the notebook bundle containing custom model definitions. +// +// Setup notebook base URL +// +// Some static assets may be required by the custom widget javascript. The base +// url for the notebook is not known at build time and is therefore computed +// dynamically. +__webpack_public_path__ = document.querySelector('body').getAttribute('data-base-url') + 'nbextensions/jupyter-matplotlib/'; + +// Export widget models and views, and the npm package version number. +module.exports = require('./mpl_widget.js'); +module.exports['version'] = require('../package.json').version; diff --git a/js/webpack.config.js b/js/webpack.config.js index 61f3d8ea..da2e7c67 100644 --- a/js/webpack.config.js +++ b/js/webpack.config.js @@ -25,7 +25,7 @@ module.exports = [ // "load_ipython_extension" function which is required for any notebook // extension. // - entry: './src/extension.js', + entry: './src/nb_extension.js', output: { filename: 'extension.js', path: staticDir, @@ -37,7 +37,7 @@ module.exports = [ // This bundle contains the implementation for the custom widget views and // models. // - entry: './src/index.js', + entry: './src/nb_index.js', output: { filename: 'index.js', path: staticDir,