Commit b5646188 authored by Philipp Nowinski's avatar Philipp Nowinski
Browse files

[BUGFIX] fix sourcemap generation

parent 946cd548
...@@ -6,6 +6,7 @@ const globby = require('globby'); ...@@ -6,6 +6,7 @@ const globby = require('globby');
const browserify = require('browserify'); const browserify = require('browserify');
const babelify = require('babelify'); const babelify = require('babelify');
const CLIEngine = require("eslint").CLIEngine; const CLIEngine = require("eslint").CLIEngine;
const exorcist = require('exorcist');
/** /**
* The JS task takes care of compiling JavaScript and running qa on it * The JS task takes care of compiling JavaScript and running qa on it
...@@ -75,7 +76,7 @@ module.exports = class Js extends Task { ...@@ -75,7 +76,7 @@ module.exports = class Js extends Task {
*/ */
_getSourceMapsPath(_fileName) { _getSourceMapsPath(_fileName) {
let fileName = path.basename(_fileName).replace('.js', '.js.map'); let fileName = path.basename(_fileName).replace('.js', '.js.map');
return this._getFullPath(`${this._config.directories.javascriptSrcSourceMaps}/${fileName}`); return this._getFullPath(`${this._config.directories.javascriptSourceMaps}/${fileName}`);
} }
/** /**
...@@ -86,8 +87,11 @@ module.exports = class Js extends Task { ...@@ -86,8 +87,11 @@ module.exports = class Js extends Task {
*/ */
async _compile(_input, _output) { async _compile(_input, _output) {
try { try {
let sourceMapPath = this._getSourceMapsPath(_output);
let relativeSourceMapPath = path.join(path.dirname(sourceMapPath), path.basename(sourceMapPath));
browserify(_input, { browserify(_input, {
paths: this._config.js.libraryPaths paths: this._config.js.libraryPaths,
debug: true
}) })
.transform(babelify, { .transform(babelify, {
presets: [ presets: [
...@@ -95,6 +99,10 @@ module.exports = class Js extends Task { ...@@ -95,6 +99,10 @@ module.exports = class Js extends Task {
] ]
}) })
.bundle() .bundle()
.pipe(exorcist(
this._getSourceMapsPath(_output),
path.relative(path.dirname(_output), relativeSourceMapPath)
))
.pipe(fs.createWriteStream(_output)); .pipe(fs.createWriteStream(_output));
this._logger.success(`Written ${chalk.white(path.basename(_output))}`); this._logger.success(`Written ${chalk.white(path.basename(_output))}`);
......
...@@ -3840,6 +3840,24 @@ ...@@ -3840,6 +3840,24 @@
"clone-regexp": "^1.0.0" "clone-regexp": "^1.0.0"
} }
}, },
"exorcist": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/exorcist/-/exorcist-1.0.1.tgz",
"integrity": "sha1-eTFuPEiFhFSQ97tAXA5bXbEWfFI=",
"requires": {
"is-stream": "~1.1.0",
"minimist": "0.0.5",
"mkdirp": "~0.5.1",
"mold-source-map": "~0.4.0"
},
"dependencies": {
"minimist": {
"version": "0.0.5",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.5.tgz",
"integrity": "sha1-16oye87PUY+RBqxrjwA/o7zqhWY="
}
}
},
"expand-brackets": { "expand-brackets": {
"version": "2.1.4", "version": "2.1.4",
"resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz",
...@@ -5569,6 +5587,22 @@ ...@@ -5569,6 +5587,22 @@
} }
} }
}, },
"mold-source-map": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/mold-source-map/-/mold-source-map-0.4.0.tgz",
"integrity": "sha1-z2fgsxxHq5uttcnCVlGGISe7gxc=",
"requires": {
"convert-source-map": "^1.1.0",
"through": "~2.2.7"
},
"dependencies": {
"through": {
"version": "2.2.7",
"resolved": "https://registry.npmjs.org/through/-/through-2.2.7.tgz",
"integrity": "sha1-bo4hIAGR1OtqmfbwEN9Gqhxusr0="
}
}
},
"ms": { "ms": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment