1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 15:04:11 -05:00

Source map support. Partially working.

This commit is contained in:
Ryan Dahl 2018-05-19 07:06:23 -04:00
parent ca8eb1d421
commit 2c65292119
5 changed files with 63 additions and 8 deletions

24
main.ts
View file

@ -3,6 +3,29 @@ import "./util";
import * as runtime from "./runtime";
import * as timers from "./timers";
import * as util from "./util";
import * as sourceMap from "source-map-support";
function retrieveFileForSourceMap(path: string): string {
util.log("retrieveFileForSourceMap", path);
throw Error("implemtn me");
}
function retrieveSourceMap(source: string): sourceMap.UrlAndMap {
util.log("retrieveSourceMap", source);
throw Error("implemtn me");
//return { url, map }
}
// TODO handleUncaughtExceptions
sourceMap.install({
//handleUncaughtExceptions: true,
environment: "node",
retrieveFile: retrieveFileForSourceMap,
hookRequire: false,
overrideRetrieveSourceMap: true,
overrideRetrieveFile: true,
retrieveSourceMap
});
// To control internal logging output
// Set with the -debug command-line flag.
@ -11,6 +34,7 @@ export let debug = false;
function start(cwd: string, argv: string[], debugFlag: boolean): void {
debug = debugFlag;
util.log("start", { cwd, argv, debugFlag });
const inputFn = argv[0];
const mod = runtime.resolveModule(inputFn, cwd + "/");
mod.compileAndRun();

View file

@ -5,9 +5,11 @@
"fmt": "prettier --write *.ts* *.js *.json"
},
"devDependencies": {
"@types/source-map-support": "^0.4.0",
"http-server": "^0.11.1",
"parcel-bundler": "^1.8.1",
"protobufjs": "^6.8.6",
"source-map-support": "^0.5.6",
"tslint": "^5.10.0",
"typescript": "^2.8.3"
},

View file

@ -14,6 +14,10 @@ import "./url";
const EOL = "\n";
// tslint:disable-next-line:no-any
type AmdFactory = (...args: any[]) => undefined | object;
type AmdDefine = (deps: string[], factory: AmdFactory) => void;
// This class represents a module. We call it FileModule to make it explicit
// that each module represents a single file.
// Access to FileModule instances should only be done thru the static method
@ -66,10 +70,6 @@ export class FileModule {
}
}
// tslint:disable-next-line:no-any
type AmdFactory = (...args: any[]) => undefined | object;
type AmdDefine = (deps: string[], factory: AmdFactory) => void;
export function makeDefine(fileName: string): AmdDefine {
const localDefine = (deps: string[], factory: AmdFactory): void => {
const localRequire = (x: string) => {
@ -122,6 +122,7 @@ function resolveModuleName(
function execute(fileName: string, outputCode: string): void {
util.assert(outputCode && outputCode.length > 0);
util._global["define"] = makeDefine(fileName);
outputCode += "\n//# sourceURL=" + fileName;
util.globalEval(outputCode);
util._global["define"] = null;
}
@ -131,12 +132,12 @@ class Compiler {
options: ts.CompilerOptions = {
allowJs: true,
module: ts.ModuleKind.AMD,
outDir: "$deno$"
outDir: "$deno$",
inlineSourceMap: true,
inlineSources: true
};
/*
allowJs: true,
inlineSourceMap: true,
inlineSources: true,
module: ts.ModuleKind.AMD,
noEmit: false,
outDir: '$deno$',

11
testdata/007_stack_trace.ts vendored Normal file
View file

@ -0,0 +1,11 @@
function foo() {
throw Error("bad");
}
function bar() {
foo()
}
console.log("before");
bar()
console.log("after");

View file

@ -49,10 +49,20 @@
version "3.0.32"
resolved "https://registry.yarnpkg.com/@types/long/-/long-3.0.32.tgz#f4e5af31e9e9b196d8e5fca8a5e2e20aa3d60b69"
"@types/node@*":
version "10.1.2"
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.1.2.tgz#1b928a0baa408fc8ae3ac012cc81375addc147c6"
"@types/node@^8.9.4":
version "8.10.14"
resolved "https://registry.yarnpkg.com/@types/node/-/node-8.10.14.tgz#a24767cfa22023f1bf7e751c0ead56a14c07ed45"
"@types/source-map-support@^0.4.0":
version "0.4.0"
resolved "https://registry.yarnpkg.com/@types/source-map-support/-/source-map-support-0.4.0.tgz#a62a1866614af68c888173c001481f242aaf148b"
dependencies:
"@types/node" "*"
abbrev@1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8"
@ -3317,11 +3327,18 @@ source-map-support@^0.4.15:
dependencies:
source-map "^0.5.6"
source-map-support@^0.5.6:
version "0.5.6"
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.6.tgz#4435cee46b1aab62b8e8610ce60f788091c51c13"
dependencies:
buffer-from "^1.0.0"
source-map "^0.6.0"
source-map-url@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/source-map-url/-/source-map-url-0.4.0.tgz#3e935d7ddd73631b97659956d55128e87b5084a3"
source-map@0.6.1, source-map@^0.6.1, source-map@~0.6.1:
source-map@0.6.1, source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.1:
version "0.6.1"
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"