summaryrefslogtreecommitdiff
path: root/js/runtime.ts
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2018-08-02 13:13:32 -0400
committerGitHub <noreply@github.com>2018-08-02 13:13:32 -0400
commitc7c6203e61cb6bb85051b96eabd6deae7995a787 (patch)
treeef463466f34fd72a4ac5a30eecd3cc94254f321f /js/runtime.ts
parente30bdb71aa8b9902078e1ed8e7d014a68eb9eb2e (diff)
Source map support (#429)
This change increases size: out/debug/obj/libdeno/from_snapshot.o 19M -> 34M out/release/deno 32M -> 47M
Diffstat (limited to 'js/runtime.ts')
-rw-r--r--js/runtime.ts33
1 files changed, 23 insertions, 10 deletions
diff --git a/js/runtime.ts b/js/runtime.ts
index 79f463759..4e9cb657d 100644
--- a/js/runtime.ts
+++ b/js/runtime.ts
@@ -12,7 +12,7 @@ import * as util from "./util";
import { log } from "./util";
import { assetSourceCode } from "./assets";
import * as os from "./os";
-//import * as sourceMaps from "./v8_source_maps";
+import * as sourceMaps from "./v8_source_maps";
import { window, globalEval } from "./globals";
//import * as deno from "./deno";
@@ -39,26 +39,39 @@ window.onerror = (
os.exit(1);
};
-/*
-export function setup(mainJs: string, mainMap: string): void {
+// This is called during snapshot creation with the contents of
+// out/debug/gen/bundle/main.js.map.
+import { RawSourceMap } from "source-map";
+let mainSourceMap: RawSourceMap = null;
+function setMainSourceMap(rawSourceMap: RawSourceMap) {
+ util.assert(Number(rawSourceMap.version) === 3);
+ mainSourceMap = rawSourceMap;
+}
+window["setMainSourceMap"] = setMainSourceMap;
+
+export function setup(): void {
sourceMaps.install({
installPrepareStackTrace: true,
- getGeneratedContents: (filename: string): string => {
- if (filename === "/main.js") {
- return mainJs;
- } else if (filename === "/main.map") {
- return mainMap;
+ getGeneratedContents: (filename: string): string | RawSourceMap => {
+ util.log("getGeneratedContents", filename);
+ if (filename === "gen/bundle/main.js") {
+ util.assert(window["mainSource"].length > 0);
+ return window["mainSource"];
+ } else if (filename === "main.js.map") {
+ return mainSourceMap;
+ } else if (filename === "deno_main.js") {
+ return "";
} else {
const mod = FileModule.load(filename);
if (!mod) {
- console.error("getGeneratedContents cannot find", filename);
+ util.log("getGeneratedContents cannot find", filename);
+ return null;
}
return mod.outputCode;
}
}
});
}
-*/
// This class represents a module. We call it FileModule to make it explicit
// that each module represents a single file.