diff --git a/BUILD.gn b/BUILD.gn index 5bb2d2ef24..9e996d9ff5 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -243,9 +243,8 @@ 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]) + bundle_location = rebase_path(bundle_outputs[0], root_build_dir) + bundle_map_location = rebase_path(bundle_outputs[1], root_build_dir) inputs = bundle_outputs sources = [ "libdeno/from_filesystem.cc", @@ -257,7 +256,6 @@ source_set("libdeno_nosnapshot") { configs += [ ":deno_config" ] defines = [ "BUNDLE_LOCATION=\"$bundle_location\"", - "BUNDLE_REL_LOCATION=\"$bundle_rel_location\"", "BUNDLE_MAP_LOCATION=\"$bundle_map_location\"", ] } diff --git a/libdeno/from_filesystem.cc b/libdeno/from_filesystem.cc index fa50c05151..0852f1558b 100644 --- a/libdeno/from_filesystem.cc +++ b/libdeno/from_filesystem.cc @@ -15,11 +15,17 @@ namespace deno { Deno* NewFromFileSystem(void* data, deno_recv_cb cb) { - std::string js_source; - CHECK(deno::ReadFileToString(BUNDLE_LOCATION, &js_source)); + std::string exe_path; + CHECK(deno::ExePath(&exe_path)); + std::string exe_dir = deno::Dirname(exe_path); // Always ends with a slash. + std::string js_source_path = exe_dir + BUNDLE_LOCATION; + std::string js_source; + CHECK(deno::ReadFileToString(js_source_path.c_str(), &js_source)); + + std::string js_source_map_path = exe_dir + BUNDLE_MAP_LOCATION; std::string js_source_map; - CHECK(deno::ReadFileToString(BUNDLE_MAP_LOCATION, &js_source_map)); + CHECK(deno::ReadFileToString(js_source_map_path.c_str(), &js_source_map)); Deno* d = new Deno; d->currentArgs = nullptr; @@ -36,10 +42,9 @@ Deno* NewFromFileSystem(void* data, deno_recv_cb cb) { { v8::HandleScope handle_scope(isolate); auto context = v8::Context::New(isolate); - // 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, + // For source maps to work, the bundle location that is passed to + // InitializeContext must be a relative path. + InitializeContext(isolate, context, BUNDLE_LOCATION, js_source, &js_source_map); d->context.Reset(d->isolate, context); }