summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKitson Kelly <me@kitsonkelly.com>2018-08-10 10:41:12 -0700
committerRyan Dahl <ry@tinyclouds.org>2018-08-10 11:50:45 -0700
commit2c8bdd2f5fda04254551d04923ef91c79524282f (patch)
tree28a1a4f69bd318f9c123782fad8fd913835d6707
parentc4cafcecb1f50e38275b7d82852fd33b63964fb2 (diff)
Fix stacktraces in deno_ns
-rw-r--r--BUILD.gn13
-rw-r--r--src/from_filesystem.cc10
2 files changed, 19 insertions, 4 deletions
diff --git a/BUILD.gn b/BUILD.gn
index ee3caab5c..32d1b527c 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -321,6 +321,11 @@ run_node("bundle") {
}
source_set("libdeno_nosnapshot") {
+ bundle_outputs = get_target_outputs(":bundle")
+ bundle_location = rebase_path(bundle_outputs[0])
+ bundle_rel_location = rebase_path(bundle_outputs[0], root_build_dir)
+ bundle_map_location = rebase_path(bundle_outputs[1])
+ inputs = bundle_outputs
sources = [
"src/from_filesystem.cc",
]
@@ -329,9 +334,11 @@ source_set("libdeno_nosnapshot") {
":deno_bindings",
]
configs += [ ":deno_config" ]
- bundle_outputs = get_target_outputs(":bundle")
- bundle_location = rebase_path(bundle_outputs[0])
- defines = [ "BUNDLE_LOCATION=\"$bundle_location\"" ]
+ defines = [
+ "BUNDLE_LOCATION=\"$bundle_location\"",
+ "BUNDLE_REL_LOCATION=\"$bundle_rel_location\"",
+ "BUNDLE_MAP_LOCATION=\"$bundle_map_location\"",
+ ]
}
ts_flatbuffer("msg_ts") {
diff --git a/src/from_filesystem.cc b/src/from_filesystem.cc
index 797659de0..fa50c0515 100644
--- a/src/from_filesystem.cc
+++ b/src/from_filesystem.cc
@@ -1,4 +1,5 @@
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
+// This file is used to load the bundle at start for deno_ns.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -17,6 +18,9 @@ Deno* NewFromFileSystem(void* data, deno_recv_cb cb) {
std::string js_source;
CHECK(deno::ReadFileToString(BUNDLE_LOCATION, &js_source));
+ std::string js_source_map;
+ CHECK(deno::ReadFileToString(BUNDLE_MAP_LOCATION, &js_source_map));
+
Deno* d = new Deno;
d->currentArgs = nullptr;
d->cb = cb;
@@ -32,7 +36,11 @@ Deno* NewFromFileSystem(void* data, deno_recv_cb cb) {
{
v8::HandleScope handle_scope(isolate);
auto context = v8::Context::New(isolate);
- InitializeContext(isolate, context, BUNDLE_LOCATION, js_source, nullptr);
+ // BUNDLE_LOCATION is absolute so deno_ns can load the bundle independently
+ // of the cwd. However for source maps to work, the bundle location relative
+ // to the build path must be supplied: BUNDLE_REL_LOCATION.
+ InitializeContext(isolate, context, BUNDLE_REL_LOCATION, js_source,
+ &js_source_map);
d->context.Reset(d->isolate, context);
}