Browse Source

Clean up the local build

Steven Silvester 8 years ago
parent
commit
214927cf42

+ 1 - 0
.gitignore

@@ -2,6 +2,7 @@ MANIFEST
 build
 dist
 lib
+jupyterlab/index.js
 
 node_modules
 .cache

+ 3 - 3
jupyterlab/src/index.js → jupyterlab/index.template.js

@@ -11,13 +11,13 @@ function main() {
         namespace: 'jupyterlab',
         version: process.env.JUPYTERLAB_VERSION
     });
-    {% for extension in jupyterlab_extensions %}
+    {{#each jupyterlab_extensions}}
     try {
-        lab.registerPluginModule(require('{{extension}}'));
+        lab.registerPluginModule(require('{{this}}'));
     } catch (e) {
         console.error(e);
     }
-    {% endfor %}
+    {{/each}}
     lab.start();
 }
 

+ 40 - 12
jupyterlab/package.json

@@ -1,14 +1,10 @@
 {
   "private": true,
-  "name": "@jupyterlab/main",
-  "version": "0.2.0",
+  "name": "@jupyterlab/application-top",
   "scripts": {
-    "build": "tsc && webpack",
-    "clean": "rimraf build",
-    "watch": "watch \"npm run build\" ../packages --wait 10 --filter=../scripts/watch-filter.js"
+    "build": "webpack"
   },
   "dependencies": {
-    "@jupyterlab/application": "^0.2.0",
     "@jupyterlab/about-extension": "^0.2.0",
     "@jupyterlab/application-extension": "^0.2.0",
     "@jupyterlab/apputils-extension": "^0.2.0",
@@ -16,7 +12,6 @@
     "@jupyterlab/completer-extension": "^0.2.0",
     "@jupyterlab/console-extension": "^0.2.0",
     "@jupyterlab/csvwidget-extension": "^0.2.0",
-    "@jupyterlab/default-theme": "^0.2.0",
     "@jupyterlab/docmanager-extension": "^0.2.0",
     "@jupyterlab/docregistry-extension": "^0.2.0",
     "@jupyterlab/editorwidget-extension": "^0.2.0",
@@ -36,16 +31,49 @@
     "@jupyterlab/tabmanager-extension": "^0.2.0",
     "@jupyterlab/terminal-extension": "^0.2.0",
     "@jupyterlab/tooltip-extension": "^0.2.0",
+    "@jupyterlab/application": "^0.2.0",
+    "@jupyterlab/default-theme": "^0.2.0",
     "es6-promise": "^4.1.0",
-    "font-awesome": "^4.6.3"
+    "font-awesome": "^4.7.0"
   },
   "devDependencies": {
-    "@jupyterlab/extension-builder": "^0.12.0",
+    "css-loader": "^0.27.3",
+    "extract-text-webpack-plugin": "^2.1.0",
     "file-loader": "^0.10.1",
-    "rimraf": "^2.5.2",
-    "typescript": "^2.2.1",
+    "fs-extra": "^2.1.2",
+    "handlebars": "^4.0.6",
+    "json-loader": "^0.5.4",
+    "style-loader": "^0.13.1",
     "url-loader": "^0.5.7",
-    "watch": "^1.0.2",
     "webpack": "^2.2.1"
+  },
+  "jupyterlab": {
+    "extensions": [
+      "@jupyterlab/about-extension",
+      "@jupyterlab/application-extension",
+      "@jupyterlab/apputils-extension",
+      "@jupyterlab/codemirror-extension",
+      "@jupyterlab/completer-extension",
+      "@jupyterlab/console-extension",
+      "@jupyterlab/csvwidget-extension",
+      "@jupyterlab/docmanager-extension",
+      "@jupyterlab/docregistry-extension",
+      "@jupyterlab/editorwidget-extension",
+      "@jupyterlab/faq-extension",
+      "@jupyterlab/filebrowser-extension",
+      "@jupyterlab/help-extension",
+      "@jupyterlab/imagewidget-extension",
+      "@jupyterlab/inspector-extension",
+      "@jupyterlab/landing-extension",
+      "@jupyterlab/launcher-extension",
+      "@jupyterlab/markdownwidget-extension",
+      "@jupyterlab/notebook-extension",
+      "@jupyterlab/rendermime-extension",
+      "@jupyterlab/running-extension",
+      "@jupyterlab/services-extension",
+      "@jupyterlab/shortcuts-extension",
+      "@jupyterlab/terminal-extension",
+      "@jupyterlab/tooltip-extension"
+    ]
   }
 }

+ 0 - 4
jupyterlab/src/builder.ts

@@ -1,4 +0,0 @@
-// Copyright (c) Jupyter Development Team.
-// Distributed under the terms of the Modified BSD License.
-
-export * from '@jupyterlab/extension-builder';

+ 0 - 30
jupyterlab/src/loader.ts

@@ -1,30 +0,0 @@
-// Copyright (c) Jupyter Development Team.
-// Distributed under the terms of the Modified BSD License.
-
-import {
-  ModuleLoader
-} from '@jupyterlab/application';
-
-
-/**
- * A module loader instance.
- */
-const _loader = new ModuleLoader();
-
-
-/**
- * Define a module that can be synchronously required.
- *
- * @param path - The version-mangled fully qualified path of the module.
- *   For example, "foo@1.0.1/lib/bar/baz.js".
- *
- * @param callback - The callback function for invoking the module.
- */
-export
-function define(path: string, callback: ModuleLoader.DefineCallback): void {
-  _loader.define.call(_loader, path, callback);
-}
-
-
-export
-const loader = _loader;

+ 0 - 48
jupyterlab/src/package.json

@@ -1,48 +0,0 @@
-{
-  "private": true,
-  "name": "@jupyterlab/application-top",
-  "scripts": {
-    "build": "webpack"
-  },
-  "dependencies": {
-    "@jupyterlab/about-extension": "^0.2.0",
-    "@jupyterlab/application-extension": "^0.2.0",
-    "@jupyterlab/apputils-extension": "^0.2.0",
-    "@jupyterlab/codemirror-extension": "^0.2.0",
-    "@jupyterlab/completer-extension": "^0.2.0",
-    "@jupyterlab/console-extension": "^0.2.0",
-    "@jupyterlab/csvwidget-extension": "^0.2.0",
-    "@jupyterlab/docmanager-extension": "^0.2.0",
-    "@jupyterlab/docregistry-extension": "^0.2.0",
-    "@jupyterlab/editorwidget-extension": "^0.2.0",
-    "@jupyterlab/faq-extension": "^0.2.0",
-    "@jupyterlab/filebrowser-extension": "^0.2.0",
-    "@jupyterlab/help-extension": "^0.2.0",
-    "@jupyterlab/imagewidget-extension": "^0.2.0",
-    "@jupyterlab/inspector-extension": "^0.2.0",
-    "@jupyterlab/landing-extension": "^0.2.0",
-    "@jupyterlab/launcher-extension": "^0.2.0",
-    "@jupyterlab/markdownwidget-extension": "^0.2.0",
-    "@jupyterlab/notebook-extension": "^0.2.0",
-    "@jupyterlab/rendermime-extension": "^0.2.0",
-    "@jupyterlab/running-extension": "^0.2.0",
-    "@jupyterlab/services-extension": "^0.2.0",
-    "@jupyterlab/shortcuts-extension": "^0.2.0",
-    "@jupyterlab/terminal-extension": "^0.2.0",
-    "@jupyterlab/tooltip-extension": "^0.2.0"
-  },
-  "devDependencies": {
-    "@jupyterlab/application": "^0.2.0",
-    "@jupyterlab/default-theme": "^0.2.0",
-    "css-loader": "^0.27.3",
-    "es6-promise": "^4.1.0",
-    "extract-text-webpack-plugin": "^2.1.0",
-    "file-loader": "^0.10.1",
-    "font-awesome": "^4.7.0",
-    "fs-extra": "^2.1.2",
-    "json-loader": "^0.5.4",
-    "style-loader": "^0.13.1",
-    "url-loader": "^0.5.7",
-    "webpack": "^2.2.1"
-  }
-}

+ 0 - 9
jupyterlab/src/typings.d.ts

@@ -1,9 +0,0 @@
-// Copyright (c) Jupyter Development Team.
-// Distributed under the terms of the Modified BSD License.
-
-/// <reference path="../../packages/codemirror/typings/codemirror/codemirror.d.ts"/>
-/// <reference path="../../packages/coreutils/typings/path-posix/path-posix.d.ts"/>
-/// <reference path="../../packages/coreutils/typings/url-parse/url-parse.d.ts"/>
-/// <reference path="../../packages/extension-builder/typings/webpack-config/webpack-config.d.ts"/>
-/// <reference path="../../packages/rendermime/typings/ansi_up/ansi_up.d.ts"/>
-/// <reference path="../../packages/terminal/typings/xterm/xterm.d.ts"/>

+ 0 - 74
jupyterlab/src/webpack.config.js

@@ -1,74 +0,0 @@
-
-var childProcess = require('child_process');
-var webpack = require('webpack');
-var path = require('path');
-var fs = require('fs-extra');
-var ExtractTextPlugin = require('extract-text-webpack-plugin');
-
-
-// Get the git description.
-try {
-  var notice = childProcess.execSync('jupyterlab --describe', { encoding: 'utf8' });
-} catch (e) {
-  var notice = 'unknown';
-}
-
-
-// Get the python package version.
-var cwd = process.cwd();
-process.chdir('../..');
-try {
-  var version = childProcess.execSync('jupyterlab --version', { encoding: 'utf8' });
-} catch (e) {
-  var version = 'unknown';
-}
-process.chdir(cwd);
-
-
-// Note that we have to use an explicit local public path
-// otherwise the urls in the extracted CSS will point to the wrong
-// location.
-// See https://github.com/webpack-contrib/extract-text-webpack-plugin/tree/75cb09eed13d15cec8f974b1210920a7f249f8e2
-var cssLoader = ExtractTextPlugin.extract({
-  use: 'css-loader',
-  fallback: 'style-loader',
-  publicPath: './'
-});
-
-
-module.exports = {
-  entry:  './index.js',
-  output: {
-    path: __dirname + '/build',
-    filename: '[name].bundle.js',
-    publicPath: 'lab/'
-  },
-  module: {
-    rules: [
-      { test: /\.css$/, use: cssLoader },
-      { test: /\.json$/, use: 'json-loader' },
-      { test: /\.html$/, use: 'file-loader' },
-      { test: /\.(jpg|png|gif)$/, use: 'file-loader' },
-      { test: /\.js.map$/, use: 'file-loader' },
-      { test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/, use: 'url-loader?limit=10000&mimetype=application/font-woff' },
-      { test: /\.woff(\?v=\d+\.\d+\.\d+)?$/, use: 'url-loader?limit=10000&mimetype=application/font-woff' },
-      { test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, use: 'url-loader?limit=10000&mimetype=application/octet-stream' },
-      { test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, use: 'file-loader' },
-      { test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, use: 'url-loader?limit=10000&mimetype=image/svg+xml' }
-    ],
-  },
-  node: {
-    fs: 'empty'
-  },
-  bail: true,
-  devtool: 'source-map',
-  plugins: [
-      new webpack.DefinePlugin({
-        'process.env': {
-          'GIT_DESCRIPTION': JSON.stringify(notice.trim()),
-          'JUPYTERLAB_VERSION': JSON.stringify(version.trim())
-        }
-      }),
-      new ExtractTextPlugin('[name].css')
-    ]
-}

+ 52 - 56
jupyterlab/webpack.config.js

@@ -1,20 +1,29 @@
-// Copyright (c) Jupyter Development Team.
-// Distributed under the terms of the Modified BSD License.
-
-// Support for Node 0.10
-// See https://github.com/webpack/css-loader/issues/144
-require('es6-promise/auto');
 
 var childProcess = require('child_process');
-var buildExtension = require('./build/packages/extension-builder/src/builder').buildExtension;
 var webpack = require('webpack');
 var path = require('path');
 var fs = require('fs-extra');
+var ExtractTextPlugin = require('extract-text-webpack-plugin');
+var Handlebars = require('handlebars');
+var package_data = require('./package.json');
+
+
+// Ensure a clear build directory.
+fs.removeSync('./build');
+fs.ensureDirSync('./build');
+
+
+// Create the entry point file.
+var source = fs.readFileSync('index.template.js').toString();
+var template = Handlebars.compile(source);
+var data = { jupyterlab_extensions: package_data.jupyterlab.extensions };
+var result = template(data);
+fs.writeFileSync('build/index.out.js', result);
 
 
 // Get the git description.
 try {
-  var notice = childProcess.execSync('git describe', { encoding: 'utf8' });
+  var notice = childProcess.execSync('jupyterlab --describe', { encoding: 'utf8' });
 } catch (e) {
   var notice = 'unknown';
 }
@@ -22,72 +31,59 @@ try {
 
 // Get the python package version.
 var cwd = process.cwd();
-process.chdir('..');
+process.chdir('../..');
 try {
-  var version = childProcess.execSync('python setup.py --version', { encoding: 'utf8' });
+  var version = childProcess.execSync('jupyterlab --version', { encoding: 'utf8' });
 } catch (e) {
   var version = 'unknown';
 }
 process.chdir(cwd);
 
 
-// Build the main extension.
-console.log('Generating bundles...');
-
-// Get the module aliases and copy styles.
-var alias = {};
-var files = fs.readdirSync('./build/packages');
-for (var i = 0; i < files.length; i++) {
-  var package = path.basename(files[i]);
-  var target = path.resolve('./build/packages/' + files[i] + '/src');
-  if (fs.existsSync(path.join('../packages', package, 'style'))) {
-    var source = path.join('../packages', package, 'style');
-    var styleTarget = path.join(target, 'style');
-    fs.copySync(source, styleTarget);
-  }
-  alias['@jupyterlab/' + package] = target;
-}
-
-
-buildExtension({
-  name: 'main',
-  entry: './build/jupyterlab/src/main',
-  outputDir: './build',
-  config: {
-    output: {
-      publicPath: 'lab/',
-    },
-    resolve: {
-      alias
-    },
-    plugins: [
-      new webpack.DefinePlugin({
-        'process.env': {
-          'GIT_DESCRIPTION': JSON.stringify(notice.trim()),
-          'JUPYTERLAB_VERSION': JSON.stringify(version.trim())
-        }
-      })
-    ]
-  }
+// Note that we have to use an explicit local public path
+// otherwise the urls in the extracted CSS will point to the wrong
+// location.
+// See https://github.com/webpack-contrib/extract-text-webpack-plugin/tree/75cb09eed13d15cec8f974b1210920a7f249f8e2
+var cssLoader = ExtractTextPlugin.extract({
+  use: 'css-loader',
+  fallback: 'style-loader',
+  publicPath: './'
 });
 
 
 module.exports = {
-  entry: {
-    loader: './build/jupyterlab/src/loader'
-  },
+  entry:  './build/index.out.js',
   output: {
     path: __dirname + '/build',
     filename: '[name].bundle.js',
-    libraryTarget: 'this',
-    library: 'jupyter'
+    publicPath: 'lab/'
   },
-  resolve: {
-    alias
+  module: {
+    rules: [
+      { test: /\.css$/, use: cssLoader },
+      { test: /\.json$/, use: 'json-loader' },
+      { test: /\.html$/, use: 'file-loader' },
+      { test: /\.(jpg|png|gif)$/, use: 'file-loader' },
+      { test: /\.js.map$/, use: 'file-loader' },
+      { test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/, use: 'url-loader?limit=10000&mimetype=application/font-woff' },
+      { test: /\.woff(\?v=\d+\.\d+\.\d+)?$/, use: 'url-loader?limit=10000&mimetype=application/font-woff' },
+      { test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/, use: 'url-loader?limit=10000&mimetype=application/octet-stream' },
+      { test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, use: 'file-loader' },
+      { test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, use: 'url-loader?limit=10000&mimetype=image/svg+xml' }
+    ],
   },
   node: {
     fs: 'empty'
   },
   bail: true,
-  devtool: 'source-map'
+  devtool: 'source-map',
+  plugins: [
+      new webpack.DefinePlugin({
+        'process.env': {
+          'GIT_DESCRIPTION': JSON.stringify(notice.trim()),
+          'JUPYTERLAB_VERSION': JSON.stringify(version.trim())
+        }
+      }),
+      new ExtractTextPlugin('[name].css')
+    ]
 }