summaryrefslogtreecommitdiff
path: root/runtime.ts
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2018-05-21 17:33:33 -0400
committerRyan Dahl <ry@tinyclouds.org>2018-05-21 17:33:33 -0400
commit8e2e17cdbe02847b19d8bc2002ba713d18e291b9 (patch)
tree4e6cb105f4ca8857d28e5473894bf53dceeff3cc /runtime.ts
parentaf6076f3c6008d3aacb69ae3eca8db2eb3f00de9 (diff)
Support source maps for internal code.
Diffstat (limited to 'runtime.ts')
-rw-r--r--runtime.ts26
1 files changed, 17 insertions, 9 deletions
diff --git a/runtime.ts b/runtime.ts
index 9ca3b4944..57b556c21 100644
--- a/runtime.ts
+++ b/runtime.ts
@@ -19,16 +19,24 @@ const EOL = "\n";
type AmdFactory = (...args: any[]) => undefined | object;
type AmdDefine = (deps: string[], factory: AmdFactory) => void;
-sourceMaps.install({
- installPrepareStackTrace: true,
- getGeneratedContents: (filename: string): string => {
- util.log("getGeneratedContents", filename);
- if (filename === "dist/main.js") {
- return null;
+export function setup(mainJs: string, mainMap: string): void {
+ sourceMaps.install({
+ installPrepareStackTrace: true,
+ getGeneratedContents: (filename: string): string => {
+ if (filename === "/main.js") {
+ return mainJs;
+ } else if (filename === "/main.map") {
+ return mainMap;
+ } else {
+ const mod = FileModule.load(filename);
+ if (!mod) {
+ console.error("getGeneratedContents cannot find", filename);
+ }
+ return mod.outputCode;
+ }
}
- return FileModule.load(filename).outputCode;
- }
-});
+ });
+}
// This class represents a module. We call it FileModule to make it explicit
// that each module represents a single file.