mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2024-12-21 06:33:30 +00:00
c422c91b66
JSONStream is a hybrid executable-library that doesn't get along well with webpack: it tries to run its binary code which can throw uncaught exceptions. So we use a custom loader for it - which replaces remove-hashbang-loader, as it only affected JSONStream too. (I tried replacing JSONStream altogether, but turns out dockerode uses it too) Change-Type: patch Signed-off-by: Pablo Carranza Velez <pablo@resin.io>
10 lines
561 B
JavaScript
10 lines
561 B
JavaScript
// JSONStream is a hybrid executable-library
|
|
// and has a #! /usr/bin/env node at the beginning of the file.
|
|
// This webpack loader removes it so that we have valid javascript for webpack to load.
|
|
// Also, JSONStream starts a pipe between stdin and stdout if module.parent is undefined.
|
|
// This pipe can fail throwing an uncaught exception, so we fake a module.parent to prevent this.
|
|
// See https://github.com/dominictarr/JSONStream/issues/129
|
|
module.exports = function (source) {
|
|
return "module.parent = {};\n" + source.toString().replace(/^#! .*\n/, '')
|
|
}
|