浏览代码

Merge pull request #2922 from saulshanabrook/add-ts-sourcemaps

Add Typescript Sourcemaps
Steven Silvester 7 年之前
父节点
当前提交
06b19ce2ed

+ 6 - 3
CONTRIBUTING.md

@@ -25,7 +25,7 @@ All source code is written in [TypeScript](http://www.typescriptlang.org/Handboo
 
 ### Installing Node.js and npm
 
-Building the JupyterLab from its GitHub source code requires Node.js version 
+Building the JupyterLab from its GitHub source code requires Node.js version
 6+ and Node's package manager, ``npm``.
 
 If you use ``conda``, you can get them with:
@@ -90,6 +90,10 @@ jupyterlab_launcher` to get the latest version.
 
 * To install JupyterLab in isolation for a single conda/virtual environment, you can add the `--sys-prefix` flag to the extension activation above; this will tie the installation to the `sys.prefix` location of your environment, without writing anything in your user-wide settings area (which are visible to all your envs):
 
+* You can run `npm run build:main:prod` to build more accurate sourcemaps that show the original
+  Typescript code when debugging. However, it takes a bit longer to build the sources, so is used only to build for production
+  by default.
+
 ```
 jupyter serverextension enable --py --sys-prefix jupyterlab
 ```
@@ -102,7 +106,7 @@ Start JupyterLab in development mode:
 jupyter lab --dev-mode
 ```
 
-Development mode ensures that you are running the JavaScript assets that are 
+Development mode ensures that you are running the JavaScript assets that are
 built in the dev-installed Python package.  When running from source in development
 mode, the page will have a red stripe at the top to indicate it is an unreleased version.
 
@@ -206,4 +210,3 @@ https://jupyterlab-tutorial.readthedocs.io/en/latest/index.html.
 
 - The npm modules are fully compatible with Node/Babel/ES6/ES5. Simply
 omit the type declarations when using a language other than TypeScript.
-

+ 2 - 2
jupyterlab/make-release.js

@@ -19,8 +19,8 @@ fs.writeFileSync('./package.app.json', text);
 // Update our app index file.
 fs.copySync('./index.js', './index.app.js')
 
-// Run a standard build.
-childProcess.execSync('npm run build');
+// Run a standard build with Typescript source maps working.
+childProcess.execSync('npm run build:prod');
 
 // Add  the release metadata.
 var release_data = { version: version };

+ 2 - 0
jupyterlab/package.app.json

@@ -3,6 +3,7 @@
   "version": "0.10.2",
   "scripts": {
     "build": "webpack",
+    "build:prod": "webpack --devtool source-map",
     "publish": "node make-release.js"
   },
   "dependencies": {
@@ -80,6 +81,7 @@
     "json-loader": "^0.5.4",
     "raw-loader": "^0.5.1",
     "sort-package-json": "^1.7.0",
+    "source-map-loader": "0.2.1",
     "style-loader": "^0.13.1",
     "url-loader": "^0.5.7",
     "webpack": "^2.2.1"

+ 2 - 0
jupyterlab/package.json

@@ -3,6 +3,7 @@
   "version": "0.10.2",
   "scripts": {
     "build": "node update-core.js && webpack",
+    "build:prod": "node update-core.js && webpack --devtool source-map",
     "publish": "node make-release.js"
   },
   "dependencies": {
@@ -80,6 +81,7 @@
     "json-loader": "^0.5.4",
     "raw-loader": "^0.5.1",
     "sort-package-json": "^1.7.0",
+    "source-map-loader": "0.2.1",
     "style-loader": "^0.13.1",
     "url-loader": "^0.5.7",
     "webpack": "^2.2.1"

+ 1 - 0
jupyterlab/webpack.config.js

@@ -43,6 +43,7 @@ module.exports = {
       { test: /\.json$/, use: 'json-loader' },
       { test: /\.html$/, use: 'file-loader' },
       { test: /\.md$/, use: 'raw-loader' },
+      { test: /\.js$/, use: ['source-map-loader'], enforce: 'pre', exclude: /vega-lite/},
       { 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' },

+ 2 - 1
package.json

@@ -6,6 +6,7 @@
     "build:examples": "lerna run build --scope \"@jupyterlab/example-*\"",
     "build": "npm run build:packages && cd jupyterlab && npm run build",
     "build:main": "npm run build",
+    "build:main:prod": "npm run build:packages && cd jupyterlab && npm run build:prod",
     "build:src": "lerna run build --scope \"@jupyterlab/!(test-|example-)*\"",
     "build:test": "lerna run build:test",
     "clean": "node scripts/clean-packages.js examples packages",
@@ -17,7 +18,7 @@
     "docs": "lerna run docs",
     "get:dependency": "node scripts/get-dependency.js",
     "integrity": "node scripts/package-integrity.js",
-    "publish": "npm update && npm install && npm run clean && npm run build && lerna publish -m \"Publish\"",
+    "publish": "npm update && npm install && npm run clean && npm run build:packages && lerna publish -m \"Publish\"",
     "test": "cd test && npm test",
     "test:services": "cd packages/services && npm test && npm run test:integration && cd examples/node && python main.py",
     "test:chrome": "lerna run test:chrome --stream",

+ 3 - 1
packages/all-packages/tsconfig.json

@@ -21,6 +21,8 @@
       ]
     },
     "jsx": "react",
-    "jsxFactory": "h"
+    "jsxFactory": "h",
+    "inlineSources": true,
+    "sourceMap": true
   }
 }