Skip to content

Commit

Permalink
Source maps, hardcoded linebreaks, #144
Browse files Browse the repository at this point in the history
  • Loading branch information
erikbarke committed Sep 14, 2017
1 parent 6082e9e commit 6eae8c9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
11 changes: 5 additions & 6 deletions dist/bundler/bundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
var async = require("async");
var fs = require("fs");
var lodash = require("lodash");
var os = require("os");
var path = require("path");
var tmp = require("tmp");
var benchmark_1 = require("../shared/benchmark");
Expand Down Expand Up @@ -132,14 +131,14 @@ var Bundler = (function () {
return (standalone ? "(function(global){" : "") +
"global.wrappers['" + PathTool.fixWindowsPath(bundleItem.filename) + "']=" +
"[function(require,module,exports,__dirname,__filename){ " + bundleItem.source +
os.EOL + "},'" +
"\n},'" +
PathTool.fixWindowsPath(moduleId) + "'," +
PathTool.fixWindowsPath(JSON.stringify(dependencyMap)) + "];" +
(standalone ? "})(this);" : "") + os.EOL;
(standalone ? "})(this);" : "") + "\n";
};
Bundler.prototype.createEntrypointFilenames = function () {
if (this.entrypoints.length > 0) {
return "global.entrypointFilenames=['" + this.entrypoints.join("','") + "'];" + os.EOL;
return "global.entrypointFilenames=['" + this.entrypoints.join("','") + "'];\n";
}
return "";
};
Expand All @@ -161,15 +160,15 @@ var Bundler = (function () {
};
Bundler.prototype.writeMainBundleFile = function (onMainBundleFileWritten) {
var _this = this;
var bundle = "(function(global){" + os.EOL + "global.wrappers={};" + os.EOL;
var bundle = "(function(global){\nglobal.wrappers={};\n";
this.sourceMap.initialize(bundle);
this.bundleBuffer.forEach(function (bundleItem) {
_this.sourceMap.addFile(bundleItem);
var wrapped = _this.addLoaderFunction(bundleItem, false);
bundle += wrapped;
_this.sourceMap.offsetLineNumber(wrapped);
});
bundle += this.createEntrypointFilenames() + "})(this);" + os.EOL;
bundle += this.createEntrypointFilenames() + "})(this);\n";
bundle += this.sourceMap.getComment();
this.validator.validate(bundle, this.bundleFile.name);
fs.writeFile(this.bundleFile.name, bundle, function (error) {
Expand Down
11 changes: 5 additions & 6 deletions src/bundler/bundler.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as async from "async";
import * as fs from "fs";
import * as lodash from "lodash";
import * as os from "os";
import * as path from "path";
import * as tmp from "tmp";

Expand Down Expand Up @@ -174,15 +173,15 @@ export class Bundler {
return (standalone ? "(function(global){" : "") +
"global.wrappers['" + PathTool.fixWindowsPath(bundleItem.filename) + "']=" +
"[function(require,module,exports,__dirname,__filename){ " + bundleItem.source +
os.EOL + "},'" +
"\n},'" +
PathTool.fixWindowsPath(moduleId) + "'," +
PathTool.fixWindowsPath(JSON.stringify(dependencyMap)) + "];" +
(standalone ? "})(this);" : "") + os.EOL;
(standalone ? "})(this);" : "") + "\n";
}

private createEntrypointFilenames() {
if (this.entrypoints.length > 0) {
return "global.entrypointFilenames=['" + this.entrypoints.join("','") + "'];" + os.EOL;
return "global.entrypointFilenames=['" + this.entrypoints.join("','") + "'];\n";
}
return "";
}
Expand All @@ -206,7 +205,7 @@ export class Bundler {

private writeMainBundleFile(onMainBundleFileWritten: { (): void } ) {

let bundle = "(function(global){" + os.EOL + "global.wrappers={};" + os.EOL;
let bundle = "(function(global){\nglobal.wrappers={};\n";
this.sourceMap.initialize(bundle);

this.bundleBuffer.forEach((bundleItem) => {
Expand All @@ -219,7 +218,7 @@ export class Bundler {
this.sourceMap.offsetLineNumber(wrapped);
});

bundle += this.createEntrypointFilenames() + "})(this);" + os.EOL;
bundle += this.createEntrypointFilenames() + "})(this);\n";
bundle += this.sourceMap.getComment();

this.validator.validate(bundle, this.bundleFile.name);
Expand Down

0 comments on commit 6eae8c9

Please sign in to comment.