Parcourir la source

More consolidation

Steven Silvester il y a 8 ans
Parent
commit
526a1995f0
3 fichiers modifiés avec 18 ajouts et 22 suppressions
  1. 1 1
      jupyterlab/lab.html
  2. 14 8
      jupyterlab/webpack.config.js
  3. 3 13
      scripts/extension_helpers.js

+ 1 - 1
jupyterlab/lab.html

@@ -32,9 +32,9 @@ Distributed under the terms of the Modified BSD License.
 }</script>
 
 <script src="{{static_prefix}}/codemirror.bundle.js" type="text/javascript" charset="utf-8"></script>
-<script src="{{static_prefix}}/vendor.bundle.js" type="text/javascript" charset="utf-8"></script>
 <script src="{{static_prefix}}/phosphor.bundle.js" type="text/javascript" charset="utf-8"></script>
 <script src="{{static_prefix}}/services.bundle.js" type="text/javascript" charset="utf-8"></script>
+<script src="{{static_prefix}}/vendor.bundle.js" type="text/javascript" charset="utf-8"></script>
 <script src="{{static_prefix}}/lab.bundle.js" type="text/javascript" charset="utf-8"></script>
 <script src="{{static_prefix}}/plugins.bundle.js" type="text/javascript" charset="utf-8"></script>
 

+ 14 - 8
jupyterlab/webpack.config.js

@@ -8,10 +8,14 @@ require('es6-promise').polyfill();
 var fs = require('fs');
 var webpack = require('webpack');
 var ExtractTextPlugin = require('extract-text-webpack-plugin');
+var findImports = require('find-imports');
+var helpers = require('jupyterlab/scripts/extension_helpers');
 
 
 console.log('Generating config...');
-var helpers = require('jupyterlab/scripts/extension_helpers');
+
+// Get the list of vendor files.
+var VENDOR_FILES = findImports('../lib/**/*.js', { flatten: true });
 
 // Create the Phosphor and JupyterLab shims.
 // First make sure the build folder exists.
@@ -25,7 +29,6 @@ try {
 fs.writeFileSync('./build/phosphor-shim.js', helpers.createShim('phosphor'));
 fs.writeFileSync('./build/jupyterlab-shim.js', helpers.createShim('jupyterlab'));
 
-
 // The default `module.loaders` config.
 var loaders = [
   { test: /\.css$/, loader: ExtractTextPlugin.extract('style-loader', 'css-loader') },
@@ -42,6 +45,9 @@ var loaders = [
 ]
 
 
+console.log('Generating bundles...');
+
+
 // The parallel Webpack build configurations.
 module.exports = [
 // Application bundles
@@ -74,10 +80,10 @@ module.exports = [
 {
   entry: {
     lab: './build/jupyterlab-shim.js',
-    vendor: helpers.VENDOR_FILES
+    vendor: VENDOR_FILES
   },
   output: {
-      filename: 'lab.bundle.js',
+      filename: '[name].bundle.js',
       path: './build',
       publicPath: './',
       library: ['jupyter', '[name]']
@@ -86,8 +92,8 @@ module.exports = [
     loaders: loaders
   },
   plugins: [
-    new ExtractTextPlugin("[name].css"),
-    new webpack.optimize.CommonsChunkPlugin("vendor", "vendor.bundle.js")
+    new ExtractTextPlugin('[name].css'),
+    new webpack.optimize.CommonsChunkPlugin('vendor', 'vendor.bundle.js')
   ],
   bail: true,
   devtool: 'source-map',
@@ -100,7 +106,7 @@ module.exports = [
     'codemirror': ['codemirror/lib/codemirror.css', 'codemirror']
   },
   output: {
-      filename: 'codemirror.bundle.js',
+      filename: '[name].bundle.js',
       path: './build',
       publicPath: './',
       library: 'CodeMirror'
@@ -109,7 +115,7 @@ module.exports = [
     loaders: loaders
   },
   plugins: [
-    new ExtractTextPlugin("[name].css")
+    new ExtractTextPlugin('[name].css')
   ],
   bail: true,
   devtool: 'source-map'

+ 3 - 13
scripts/extension_helpers.js

@@ -2,18 +2,9 @@
 // Distributed under the terms of the Modified BSD License.
 
 var path = require('path');
-var findImports = require('find-imports');
 var walkSync = require('walk-sync');
 
 
-// Get the list of vendor files, with CodeMirror files being separate.
-var VENDOR_FILES = findImports('../lib/**/*.js', { flatten: true });
-VENDOR_FILES = VENDOR_FILES.filter(function (importPath) {
-  return (importPath.lastIndexOf('phosphor', 0) !== 0 &&
-          importPath.lastIndexOf('jupyter-js-services', 0) !== 0);
-});
-
-
 /**
   Helper scripts to be used by extension authors (and extension extenders) in a
   webpack.config.json to create builds that do not include upstream extensions.
@@ -87,13 +78,13 @@ var BASE_EXTERNALS = [
     'jquery-ui': '$'
   },
   function(context, request, callback) {
-    // All phosphor imports get mangled to use the external bundle.
+    // All phosphor imports get mangled to use an external bundle.
     lib = parseShimmed('phosphor/lib/', 'jupyter.phosphor', request);
     if (lib) {
       return callback(null, lib);
     }
 
-    // CodeMirror imports use the external bundle.
+    // CodeMirror imports get mangled to use an external bundle.
     var codeMirrorPaths = [
       'codemirror/mode/meta',
       'codemirror', '../lib/codemirror',  '../../lib/codemirror',
@@ -117,7 +108,7 @@ var DEFAULT_EXTERNALS = BASE_EXTERNALS.concat([
     'jupyter-js-services': 'jupyter.services',
   },
   function(context, request, callback) {
-    // JupyterLab imports get mangled to use the external bundle.
+    // JupyterLab imports get mangled to use an external bundle.
     var lib = parseShimmed('jupyterlab/lib/', 'jupyter.lab', request);
     if (lib) {
       return callback(null, lib);
@@ -256,5 +247,4 @@ module.exports = {
   parseShimmed: parseShimmed,
   BASE_EXTERNALS: BASE_EXTERNALS,
   DEFAULT_EXTERNALS: DEFAULT_EXTERNALS,
-  VENDOR_FILES: VENDOR_FILES
 };