Skip to content

Commit

Permalink
Fix production build
Browse files Browse the repository at this point in the history
With the `TerserPlugin` enabled, the build fails with:

```
~/.local/share/virtualenvs/project-QesvCi_o/share/jupyter/lab/staging
❯ node yarn.js webpack --config webpack.prod.config.js --progress
yarn run v1.15.2
$ /Users/me/.local/share/virtualenvs/project-QesvCi_o/share/jupyter/lab/staging/node_modules/.bin/webpack --config webpack.prod.config.js --progress
 97% [0] chunk asset optimization TerserPlugin
<--- Last few GCs --->

[88233:0x108000000]    26766 ms: Scavenge 1392.5 (1420.9) -> 1391.9 (1421.9) MB, 2.2 / 0.0 ms  (average mu = 0.067, current mu = 0.029) allocation failure

<--- JS stacktrace --->

==== JS stack trace =========================================

    0: ExitFrame [pc: 0x2b3e51fdbe3d]
Security context: 0x1b222981e6e9 <JSObject>
    1: _walk [0x1b2248a66fc1] [/Users/me/.local/share/virtualenvs/project-QesvCi_o/share/jupyter/lab/staging/node_modules/terser/dist/bundle.min.js:~1] [pc=0x2b3e5223920d](this=0x1b225aef3559 <AST_String map = 0x1b22fdfd8419>,e=0x1b22c00c09c1 <En map = 0x1b22fdfe44f1>)
    2: /* anonymous */ [0x1b22d2ca1001] [/Users/me/.local/share/virtualenvs/chouke...

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 0x10003cf99 node::Abort() [/Users/me/.asdf/installs/nodejs/10.16.0/bin/node]
 2: 0x10003d1a3 node::OnFatalError(char const*, char const*) [/Users/me/.asdf/installs/nodejs/10.16.0/bin/node]
 3: 0x1001b7835 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/Users/me/.asdf/installs/nodejs/10.16.0/bin/node]
 4: 0x100585682 v8::internal::Heap::FatalProcessOutOfMemory(char const*) [/Users/me/.asdf/installs/nodejs/10.16.0/bin/node]
 5: 0x100588155 v8::internal::Heap::CheckIneffectiveMarkCompact(unsigned long, double) [/Users/me/.asdf/installs/nodejs/10.16.0/bin/node]
 6: 0x100583fff v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/Users/me/.asdf/installs/nodejs/10.16.0/bin/node]
 7: 0x1005821d4 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/Users/me/.asdf/installs/nodejs/10.16.0/bin/node]
 8: 0x10058ea6c v8::internal::Heap::AllocateRawWithLigthRetry(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/Users/me/.asdf/installs/nodejs/10.16.0/bin/node]
 9: 0x10058eaef v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/Users/me/.asdf/installs/nodejs/10.16.0/bin/node]
10: 0x10055e434 v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationSpace) [/Users/me/.asdf/installs/nodejs/10.16.0/bin/node]
11: 0x1007e6714 v8::internal::Runtime_AllocateInNewSpace(int, v8::internal::Object**, v8::internal::Isolate*) [/Users/me/.asdf/installs/nodejs/10.16.0/bin/node]
12: 0x2b3e51fdbe3d
13: 0x2b3e5223920d
14: 0x2b3e51f918d5
15: 0x2b3e5223a1f7
```

Even on powerful laptops such as a MacBook Pro with a 2,3 GHz Intel Core i9 and 32 GB 2400 MHz DDR4.

The Node.js process would never exit and thus commands like:

```
jupyter labextension install @jupyterlab/plotly-extension --dev-build False
```

would never exit too but without telling why (see jupyterlab#4276).

I've tried a bunch of different terser options but I could not find a combination that would succeed when installing relatively big JupyterLab extensions.
So I resort to disabling minification altogether. I think it's better to have a fat production build than no production build at all.
  • Loading branch information
tibdex authored and telamonian committed Jul 31, 2019
1 parent 75166c6 commit c1a5803
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 20 deletions.
1 change: 0 additions & 1 deletion jupyterlab/staging/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@
"svg-url-loader": "~2.3.2",
"svgo": "~1.2.1",
"svgo-loader": "~2.2.0",
"terser-webpack-plugin": "^1.3.0",
"url-loader": "~1.1.2",
"webpack": "^4.32.2",
"webpack-cli": "^3.3.0",
Expand Down
22 changes: 4 additions & 18 deletions jupyterlab/staging/webpack.prod.config.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,14 @@
const TerserPlugin = require('terser-webpack-plugin');
var merge = require('webpack-merge');
var config = require('./webpack.config');

config[0] = merge(config[0], {
mode: 'production',
devtool: 'source-map',
optimization: {
minimizer: [
new TerserPlugin({
parallel: true,
sourceMap: true,
terserOptions: {
compress: false,
ecma: 6,
mangle: true,
output: {
beautify: false,
comments: false
},
safari10: true
},
cache: process.platform !== 'win32'
})
]
// As of terser-webpack-plugin@1.3.0,
// the JupyterLab codebase plus its optional extensions is too big to be minified.
// Even with sourceMap and mangling disabled. And even with `node --max_old_space_size=4096`.
minimize: false
}
});

Expand Down
2 changes: 1 addition & 1 deletion jupyterlab/staging/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5700,7 +5700,7 @@ tar@^4:
safe-buffer "^5.1.2"
yallist "^3.0.3"

terser-webpack-plugin@^1.1.0, terser-webpack-plugin@^1.3.0:
terser-webpack-plugin@^1.1.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/terser-webpack-plugin/-/terser-webpack-plugin-1.3.0.tgz#69aa22426299f4b5b3775cbed8cb2c5d419aa1d4"
integrity sha512-W2YWmxPjjkUcOWa4pBEv4OP4er1aeQJlSo2UhtCFQCuRXEHjOFscO8VyWHj9JLlA0RzQb8Y2/Ta78XZvT54uGg==
Expand Down

0 comments on commit c1a5803

Please sign in to comment.