mirror of
https://github.com/denoland/deno.git
synced 2025-01-12 00:54:02 -05:00
Refactor snapshot build (#2825)
Instead of using core/snapshot_creator.rs, instead two crates are introduced which allow building the snapshot during build.rs. Rollup is removed and replaced with our own bundler. This removes the Node build dependency. Modules in //js now use Deno-style imports with file extensions, rather than Node style extensionless imports. This improves incremental build time when changes are made to //js files by about 40 seconds.
This commit is contained in:
parent
56508f113d
commit
d43b43ca78
110 changed files with 1548 additions and 1043 deletions
|
@ -200,10 +200,6 @@ test_script:
|
|||
- ps: Exec { & python tools\test.py --build-dir $env:DENO_BUILD_PATH }
|
||||
|
||||
after_test:
|
||||
# Delete the the rollup cache, which is unreliable, so that it doesn't get
|
||||
# persisted in the appveyor cache.
|
||||
- ps: if (Get-SaveCache) { Delete-Tree "$env:DENO_BUILD_PATH\.rpt2_cache" }
|
||||
|
||||
# Stop sccache and show stats.
|
||||
- ps: sccache --stop-server
|
||||
|
||||
|
@ -215,36 +211,15 @@ after_test:
|
|||
throw "Build should be up-to-date but isn't."
|
||||
}
|
||||
|
||||
# Verify that javascript and typescript files which are bundled by rollup are
|
||||
# listed explicitly in cli\BUILD.gn. This is not an air-tight check.
|
||||
# TODO: make rollup or another bundler write a depfile.
|
||||
# Verify that the bundled javascript and typescript files are listed
|
||||
# explicitly in cli_snapshots\BUILD.gn. This is not an air-tight check.
|
||||
- ps: |-
|
||||
$ignore = "test_util.ts", "unit_tests.ts", "unit_test_runner.ts", "*_test.ts"
|
||||
Get-ChildItem "js" -File -Force -Name |
|
||||
where { $name = $_; -not ($ignore | where { $name -like $_ }) } |
|
||||
where { -not (Select-String -Pattern $_ -Path cli\BUILD.gn `
|
||||
where { -not (Select-String -Pattern $_ -Path cli_snapshots\BUILD.gn `
|
||||
-SimpleMatch -CaseSensitive) } |
|
||||
foreach { throw "$_ should be listed in cli\BUILD.gn but isn't." }
|
||||
|
||||
# Verify that generated ninja files do not use absolute path names.
|
||||
# If they do, it makes ccache/sccache much less effective.
|
||||
- ps: |-
|
||||
$trap = "NO_ABS_PATH_PLS"
|
||||
$dir = "$env:APPVEYOR_BUILD_FOLDER\out\$trap"
|
||||
Exec { gn gen $dir | Out-Null }
|
||||
$files = Get-Tree $dir -File -Force -Recurse | where Extension -ne ".dll"
|
||||
Select-String $trap -Path $files -SimpleMatch | where {
|
||||
# V8 took the liberty to produce an absolute path in their ninja
|
||||
# output. We can't do much about that, so we just ignore it.
|
||||
$_.Line -notmatch "v8/builtins-generated/bytecodes-builtins-list.h"
|
||||
} | tee -Variable line_matches
|
||||
if ($line_matches) {
|
||||
$ctx = $line_matches.Line |
|
||||
Select-String "[^\s;,]*[\s=]*[^\s;,=]*$trap[^\s;,]*" -AllMatches |
|
||||
foreach { $_.Matches.Value -replace '\$(.)', '$1' } |
|
||||
sort -Unique
|
||||
throw @("Absolute path(s) found in build script:") + $ctx -join "`n "
|
||||
}
|
||||
foreach { throw "$_ should be listed in cli_snapshots\BUILD.gn but isn't." }
|
||||
|
||||
# If this build is going to be deployed, build a zip file.
|
||||
- ps: |-
|
||||
|
|
19
Cargo.lock
generated
19
Cargo.lock
generated
|
@ -272,6 +272,8 @@ dependencies = [
|
|||
"atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"deno 0.16.0",
|
||||
"deno_cli_snapshots 0.0.3",
|
||||
"deno_typescript 0.0.3",
|
||||
"dirs 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"fwdansi 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -308,6 +310,23 @@ dependencies = [
|
|||
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "deno_cli_snapshots"
|
||||
version = "0.0.3"
|
||||
dependencies = [
|
||||
"deno 0.16.0",
|
||||
"deno_typescript 0.0.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "deno_typescript"
|
||||
version = "0.0.3"
|
||||
dependencies = [
|
||||
"deno 0.16.0",
|
||||
"serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dirs"
|
||||
version = "2.0.2"
|
||||
|
|
|
@ -3,4 +3,6 @@ members = [
|
|||
"cli",
|
||||
"core",
|
||||
"tools/hyper_hello",
|
||||
"deno_typescript",
|
||||
"cli_snapshots",
|
||||
]
|
||||
|
|
150
cli/BUILD.gn
150
cli/BUILD.gn
|
@ -1,9 +1,6 @@
|
|||
# Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import("//build/toolchain/cc_wrapper.gni")
|
||||
import("//build_extra/rust/rust.gni")
|
||||
import("//third_party/v8/gni/snapshot_toolchain.gni")
|
||||
import("//third_party/v8/gni/v8.gni")
|
||||
import("deno.gni")
|
||||
|
||||
main_extern = [
|
||||
{
|
||||
|
@ -11,6 +8,16 @@ main_extern = [
|
|||
crate_name = "deno"
|
||||
crate_type = "rlib"
|
||||
},
|
||||
{
|
||||
label = "../cli_snapshots:deno_cli_snapshots"
|
||||
crate_name = "deno_cli_snapshots"
|
||||
crate_type = "rlib"
|
||||
},
|
||||
{
|
||||
label = "../deno_typescript:deno_typescript"
|
||||
crate_name = "deno_typescript"
|
||||
crate_type = "rlib"
|
||||
},
|
||||
{
|
||||
label = "$rust_build:serde_derive"
|
||||
crate_name = "serde_derive"
|
||||
|
@ -61,109 +68,6 @@ if (is_posix) {
|
|||
main_extern_rlib += [ "nix" ]
|
||||
}
|
||||
|
||||
ts_sources = [
|
||||
"../js/base64.ts",
|
||||
"../js/blob.ts",
|
||||
"../js/body.ts",
|
||||
"../js/buffer.ts",
|
||||
"../js/build.ts",
|
||||
"../js/chmod.ts",
|
||||
"../js/chown.ts",
|
||||
"../js/colors.ts",
|
||||
"../js/compiler.ts",
|
||||
"../js/console.ts",
|
||||
"../js/console_table.ts",
|
||||
"../js/copy_file.ts",
|
||||
"../js/core.ts",
|
||||
"../js/custom_event.ts",
|
||||
"../js/deno.ts",
|
||||
"../js/diagnostics.ts",
|
||||
"../js/dir.ts",
|
||||
"../js/dispatch.ts",
|
||||
"../js/dispatch_json.ts",
|
||||
"../js/dispatch_minimal.ts",
|
||||
"../js/dom_file.ts",
|
||||
"../js/dom_types.ts",
|
||||
"../js/dom_util.ts",
|
||||
"../js/error_stack.ts",
|
||||
"../js/errors.ts",
|
||||
"../js/event.ts",
|
||||
"../js/event_target.ts",
|
||||
"../js/fetch.ts",
|
||||
"../js/file_info.ts",
|
||||
"../js/files.ts",
|
||||
"../js/form_data.ts",
|
||||
"../js/format_error.ts",
|
||||
"../js/get_random_values.ts",
|
||||
"../js/globals.ts",
|
||||
"../js/headers.ts",
|
||||
"../js/io.ts",
|
||||
"../js/lib.deno_runtime.d.ts",
|
||||
"../js/lib.web_assembly.d.ts",
|
||||
"../js/link.ts",
|
||||
"../js/location.ts",
|
||||
"../js/main.ts",
|
||||
"../js/make_temp_dir.ts",
|
||||
"../js/metrics.ts",
|
||||
"../js/mkdir.ts",
|
||||
"../js/mock_builtin.js",
|
||||
"../js/net.ts",
|
||||
"../js/os.ts",
|
||||
"../js/performance.ts",
|
||||
"../js/permissions.ts",
|
||||
"../js/plugins.d.ts",
|
||||
"../js/process.ts",
|
||||
"../js/read_dir.ts",
|
||||
"../js/read_file.ts",
|
||||
"../js/read_link.ts",
|
||||
"../js/remove.ts",
|
||||
"../js/rename.ts",
|
||||
"../js/repl.ts",
|
||||
"../js/request.ts",
|
||||
"../js/resources.ts",
|
||||
"../js/stat.ts",
|
||||
"../js/symlink.ts",
|
||||
"../js/text_encoding.ts",
|
||||
"../js/timers.ts",
|
||||
"../js/truncate.ts",
|
||||
"../js/type_directives.ts",
|
||||
"../js/types.ts",
|
||||
"../js/url.ts",
|
||||
"../js/url_search_params.ts",
|
||||
"../js/util.ts",
|
||||
"../js/utime.ts",
|
||||
"../js/version.ts",
|
||||
"../js/window.ts",
|
||||
"../js/workers.ts",
|
||||
"../js/write_file.ts",
|
||||
"../js/xeval.ts",
|
||||
"../tsconfig.json",
|
||||
|
||||
# Listing package.json and yarn.lock as sources ensures the bundle is rebuilt
|
||||
# when npm packages are added/removed or their contents changes.
|
||||
"../package.json",
|
||||
"../third_party/yarn.lock",
|
||||
]
|
||||
|
||||
# When Cargo is driving the build, GN/Ninja are used to produce these non-Rust
|
||||
# targets. Cargo handles all Rust source files and the final linking step.
|
||||
group("deno_deps") {
|
||||
deps = [
|
||||
":snapshot_compiler",
|
||||
":snapshot_deno",
|
||||
]
|
||||
}
|
||||
|
||||
# Optimized dependencies for cross compiled builds.
|
||||
# This can be removed once we get snapshots into cross compiled builds.
|
||||
group("deno_deps_cross") {
|
||||
testonly = true
|
||||
deps = [
|
||||
":compiler_bundle",
|
||||
":main_bundle",
|
||||
]
|
||||
}
|
||||
|
||||
# Reads the cargo info from Cargo.toml
|
||||
deno_cargo_info = exec_script("../build_extra/rust/get_cargo_info.py",
|
||||
[ rebase_path("Cargo.toml", root_build_dir) ],
|
||||
|
@ -173,9 +77,6 @@ rust_executable("deno") {
|
|||
source_root = "main.rs"
|
||||
extern = main_extern
|
||||
extern_rlib = main_extern_rlib
|
||||
deps = [
|
||||
":deno_deps",
|
||||
]
|
||||
|
||||
# Extract version from Cargo.toml
|
||||
# TODO integrate this into rust.gni by allowing the rust_executable template
|
||||
|
@ -190,9 +91,6 @@ rust_test("cli_test") {
|
|||
source_root = "main.rs"
|
||||
extern = main_extern
|
||||
extern_rlib = main_extern_rlib
|
||||
deps = [
|
||||
":deno_deps",
|
||||
]
|
||||
|
||||
# Extract version from Cargo.toml
|
||||
inputs = [
|
||||
|
@ -200,31 +98,3 @@ rust_test("cli_test") {
|
|||
]
|
||||
env = [ "CARGO_PKG_VERSION=${deno_cargo_info.version}" ]
|
||||
}
|
||||
|
||||
bundle("main_bundle") {
|
||||
sources = ts_sources
|
||||
out_dir = "$target_gen_dir/bundle/"
|
||||
out_name = "main"
|
||||
}
|
||||
|
||||
bundle("compiler_bundle") {
|
||||
sources = ts_sources
|
||||
out_dir = "$target_gen_dir/bundle/"
|
||||
out_name = "compiler"
|
||||
}
|
||||
|
||||
# Generates $target_gen_dir/snapshot_deno.bin
|
||||
snapshot("snapshot_deno") {
|
||||
source_root = "$target_gen_dir/bundle/main.js"
|
||||
deps = [
|
||||
":main_bundle",
|
||||
]
|
||||
}
|
||||
|
||||
# Generates $target_gen_dir/snapshot_compiler.bin
|
||||
snapshot("snapshot_compiler") {
|
||||
source_root = "$target_gen_dir/bundle/compiler.js"
|
||||
deps = [
|
||||
":compiler_bundle",
|
||||
]
|
||||
}
|
||||
|
|
|
@ -52,6 +52,8 @@ tokio-rustls = "0.10.0"
|
|||
tokio-threadpool = "0.1.15"
|
||||
url = "1.7.2"
|
||||
utime = "0.2.1"
|
||||
deno_cli_snapshots = { path = "../cli_snapshots" }
|
||||
deno_typescript = { path = "../deno_typescript" }
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
winapi = "0.3.7"
|
||||
|
|
|
@ -1,59 +1,8 @@
|
|||
static DENO_RUNTIME: &str = include_str!("../js/lib.deno_runtime.d.ts");
|
||||
|
||||
macro_rules! inc {
|
||||
($e:expr) => {
|
||||
Some(include_str!(concat!(
|
||||
"../third_party/node_modules/typescript/lib/",
|
||||
$e
|
||||
)))
|
||||
};
|
||||
}
|
||||
|
||||
pub fn get_source_code(name: &str) -> Option<&'static str> {
|
||||
match name {
|
||||
"lib.deno_runtime.d.ts" => Some(DENO_RUNTIME),
|
||||
"lib.es2015.collection.d.ts" => inc!("lib.es2015.collection.d.ts"),
|
||||
"lib.es2015.core.d.ts" => inc!("lib.es2015.core.d.ts"),
|
||||
"lib.es2015.d.ts" => inc!("lib.es2015.d.ts"),
|
||||
"lib.es2015.generator.d.ts" => inc!("lib.es2015.generator.d.ts"),
|
||||
"lib.es2015.iterable.d.ts" => inc!("lib.es2015.iterable.d.ts"),
|
||||
"lib.es2015.promise.d.ts" => inc!("lib.es2015.promise.d.ts"),
|
||||
"lib.es2015.proxy.d.ts" => inc!("lib.es2015.proxy.d.ts"),
|
||||
"lib.es2015.reflect.d.ts" => inc!("lib.es2015.reflect.d.ts"),
|
||||
"lib.es2015.symbol.d.ts" => inc!("lib.es2015.symbol.d.ts"),
|
||||
"lib.es2015.symbol.wellknown.d.ts" => {
|
||||
inc!("lib.es2015.symbol.wellknown.d.ts")
|
||||
}
|
||||
"lib.es2016.array.include.d.ts" => inc!("lib.es2016.array.include.d.ts"),
|
||||
"lib.es2016.d.ts" => inc!("lib.es2016.d.ts"),
|
||||
"lib.es2017.d.ts" => inc!("lib.es2017.d.ts"),
|
||||
"lib.es2017.intl.d.ts" => inc!("lib.es2017.intl.d.ts"),
|
||||
"lib.es2017.object.d.ts" => inc!("lib.es2017.object.d.ts"),
|
||||
"lib.es2017.sharedmemory.d.ts" => inc!("lib.es2017.sharedmemory.d.ts"),
|
||||
"lib.es2017.string.d.ts" => inc!("lib.es2017.string.d.ts"),
|
||||
"lib.es2017.typedarrays.d.ts" => inc!("lib.es2017.typedarrays.d.ts"),
|
||||
"lib.es2018.d.ts" => inc!("lib.es2018.d.ts"),
|
||||
"lib.es2018.asynciterable.d.ts" => inc!("lib.es2018.asynciterable.d.ts"),
|
||||
"lib.es2018.intl.d.ts" => inc!("lib.es2018.intl.d.ts"),
|
||||
"lib.es2018.promise.d.ts" => inc!("lib.es2018.promise.d.ts"),
|
||||
"lib.es2018.regexp.d.ts" => inc!("lib.es2018.regexp.d.ts"),
|
||||
"lib.es2019.d.ts" => inc!("lib.es2019.d.ts"),
|
||||
"lib.es2019.array.d.ts" => inc!("lib.es2019.array.d.ts"),
|
||||
"lib.es2019.object.d.ts" => inc!("lib.es2019.object.d.ts"),
|
||||
"lib.es2019.string.d.ts" => inc!("lib.es2019.string.d.ts"),
|
||||
"lib.es2019.symbol.d.ts" => inc!("lib.es2019.symbol.d.ts"),
|
||||
"lib.es2020.d.ts" => inc!("lib.es2020.d.ts"),
|
||||
"lib.es2020.string.d.ts" => inc!("lib.es2020.string.d.ts"),
|
||||
"lib.es2020.symbol.wellknown.d.ts" => {
|
||||
inc!("lib.es2020.symbol.wellknown.d.ts")
|
||||
}
|
||||
"lib.es5.d.ts" => inc!("lib.es5.d.ts"),
|
||||
"lib.esnext.d.ts" => inc!("lib.esnext.d.ts"),
|
||||
"lib.esnext.array.d.ts" => inc!("lib.esnext.array.d.ts"),
|
||||
"lib.esnext.asynciterable.d.ts" => inc!("lib.esnext.asynciterable.d.ts"),
|
||||
"lib.esnext.bigint.d.ts" => inc!("lib.esnext.bigint.d.ts"),
|
||||
"lib.esnext.intl.d.ts" => inc!("lib.esnext.intl.d.ts"),
|
||||
"lib.esnext.symbol.d.ts" => inc!("lib.esnext.symbol.d.ts"),
|
||||
_ => None,
|
||||
_ => deno_typescript::get_asset(name),
|
||||
}
|
||||
}
|
||||
|
|
15
cli/build.rs
15
cli/build.rs
|
@ -1,15 +0,0 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
// Run "cargo build -vv" if you want to see gn output.
|
||||
mod gn {
|
||||
include!("../tools/gn.rs");
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let build = gn::Build::setup();
|
||||
// When RLS is running "cargo check" to analyze the source code, we're not
|
||||
// trying to build a working executable, rather we're just compiling all
|
||||
// rust code.
|
||||
if !build.check_only {
|
||||
build.run("cli:deno_deps");
|
||||
}
|
||||
}
|
65
cli/deno.gni
65
cli/deno.gni
|
@ -1,65 +0,0 @@
|
|||
# Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import("//build/compiled_action.gni")
|
||||
|
||||
# Tempalte to generate a Rollup bundle of code.
|
||||
template("bundle") {
|
||||
action(target_name) {
|
||||
forward_variables_from(invoker, "*")
|
||||
script = "//tools/run_node.py"
|
||||
outputs = [
|
||||
out_dir + out_name + ".js",
|
||||
out_dir + out_name + ".js.map",
|
||||
]
|
||||
inputs = [
|
||||
"//js/" + out_name + ".ts",
|
||||
"//rollup.config.js",
|
||||
]
|
||||
depfile = out_dir + out_name + ".d"
|
||||
args = [
|
||||
rebase_path("//third_party/node_modules/rollup/bin/rollup",
|
||||
root_build_dir),
|
||||
"-c",
|
||||
rebase_path("//rollup.config.js", root_build_dir),
|
||||
"-i",
|
||||
rebase_path(inputs[0], root_build_dir),
|
||||
"-o",
|
||||
rebase_path(outputs[0], root_build_dir),
|
||||
"--sourcemapFile",
|
||||
rebase_path("."),
|
||||
"--silent",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
template("run_node") {
|
||||
action(target_name) {
|
||||
forward_variables_from(invoker, "*")
|
||||
script = "//tools/run_node.py"
|
||||
}
|
||||
}
|
||||
|
||||
# Template to generate different V8 snapshots based on different runtime flags.
|
||||
template("snapshot") {
|
||||
compiled_action(target_name) {
|
||||
forward_variables_from(invoker,
|
||||
[
|
||||
"testonly",
|
||||
"deps",
|
||||
])
|
||||
tool = "//core:snapshot_creator"
|
||||
visibility = [ ":*" ] # Only targets in this file can depend on this.
|
||||
snapshot_out_bin = "$target_gen_dir/$target_name.bin"
|
||||
inputs = [
|
||||
invoker.source_root,
|
||||
]
|
||||
|
||||
outputs = [
|
||||
snapshot_out_bin,
|
||||
]
|
||||
args = rebase_path(outputs, root_build_dir) +
|
||||
rebase_path(inputs, root_build_dir)
|
||||
|
||||
# To debug snapshotting problems:
|
||||
# args += ["--trace-serializer"]
|
||||
}
|
||||
}
|
|
@ -9,6 +9,7 @@ extern crate futures;
|
|||
extern crate serde_json;
|
||||
extern crate clap;
|
||||
extern crate deno;
|
||||
extern crate deno_typescript;
|
||||
extern crate indexmap;
|
||||
#[cfg(unix)]
|
||||
extern crate nix;
|
||||
|
|
|
@ -73,22 +73,12 @@ fn builtin_source_map(_: &str) -> Option<Vec<u8>> {
|
|||
|
||||
#[cfg(not(feature = "check-only"))]
|
||||
fn builtin_source_map(script_name: &str) -> Option<Vec<u8>> {
|
||||
match script_name {
|
||||
"gen/cli/bundle/main.js" => Some(
|
||||
include_bytes!(concat!(
|
||||
env!("GN_OUT_DIR"),
|
||||
"/gen/cli/bundle/main.js.map"
|
||||
))
|
||||
.to_vec(),
|
||||
),
|
||||
"gen/cli/bundle/compiler.js" => Some(
|
||||
include_bytes!(concat!(
|
||||
env!("GN_OUT_DIR"),
|
||||
"/gen/cli/bundle/compiler.js.map"
|
||||
))
|
||||
.to_vec(),
|
||||
),
|
||||
_ => None,
|
||||
if script_name.ends_with("CLI_SNAPSHOT.js") {
|
||||
Some(deno_cli_snapshots::CLI_SNAPSHOT_MAP.to_vec())
|
||||
} else if script_name.ends_with("COMPILER_SNAPSHOT.js") {
|
||||
Some(deno_cli_snapshots::COMPILER_SNAPSHOT_MAP.to_vec())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -405,7 +395,7 @@ mod tests {
|
|||
frames: vec![StackFrame {
|
||||
line: 11,
|
||||
column: 12,
|
||||
script_name: "gen/cli/bundle/main.js".to_string(),
|
||||
script_name: "CLI_SNAPSHOT.js".to_string(),
|
||||
function_name: "setLogDebug".to_string(),
|
||||
is_eval: false,
|
||||
is_constructor: false,
|
||||
|
@ -417,7 +407,7 @@ mod tests {
|
|||
assert_eq!(actual.message, "TypeError: baz");
|
||||
// Because this is accessing the live bundle, this test might be more fragile
|
||||
assert_eq!(actual.frames.len(), 1);
|
||||
assert!(actual.frames[0].script_name.ends_with("js/util.ts"));
|
||||
assert!(actual.frames[0].script_name.ends_with("js/window.ts"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
use deno::Script;
|
||||
|
||||
use deno::StartupData;
|
||||
use deno_cli_snapshots::CLI_SNAPSHOT;
|
||||
use deno_cli_snapshots::COMPILER_SNAPSHOT;
|
||||
|
||||
#[cfg(feature = "no-snapshot-init")]
|
||||
pub fn deno_isolate_init() -> StartupData<'static> {
|
||||
|
@ -23,8 +25,7 @@ pub fn deno_isolate_init() -> StartupData<'static> {
|
|||
pub fn deno_isolate_init() -> StartupData<'static> {
|
||||
debug!("Deno isolate init with snapshots.");
|
||||
#[cfg(not(feature = "check-only"))]
|
||||
let data =
|
||||
include_bytes!(concat!(env!("GN_OUT_DIR"), "/gen/cli/snapshot_deno.bin"));
|
||||
let data = CLI_SNAPSHOT;
|
||||
#[cfg(feature = "check-only")]
|
||||
let data = b"";
|
||||
|
||||
|
@ -50,10 +51,7 @@ pub fn compiler_isolate_init() -> StartupData<'static> {
|
|||
pub fn compiler_isolate_init() -> StartupData<'static> {
|
||||
debug!("Deno isolate init with snapshots.");
|
||||
#[cfg(not(feature = "check-only"))]
|
||||
let data = include_bytes!(concat!(
|
||||
env!("GN_OUT_DIR"),
|
||||
"/gen/cli/snapshot_compiler.bin"
|
||||
));
|
||||
let data = COMPILER_SNAPSHOT;
|
||||
#[cfg(feature = "check-only")]
|
||||
let data = b"";
|
||||
|
||||
|
|
121
cli_snapshots/BUILD.gn
Normal file
121
cli_snapshots/BUILD.gn
Normal file
|
@ -0,0 +1,121 @@
|
|||
import("//build_extra/rust/rust.gni")
|
||||
|
||||
rust_rlib("deno_cli_snapshots") {
|
||||
source_root = "lib.rs"
|
||||
generated_source_dir = rebase_path(root_out_dir)
|
||||
deps = [
|
||||
":deno_cli_snapshots_build_run",
|
||||
]
|
||||
}
|
||||
|
||||
ts_sources = [
|
||||
"../js/base64.ts",
|
||||
"../js/blob.ts",
|
||||
"../js/body.ts",
|
||||
"../js/buffer.ts",
|
||||
"../js/build.ts",
|
||||
"../js/chmod.ts",
|
||||
"../js/chown.ts",
|
||||
"../js/colors.ts",
|
||||
"../js/compiler.ts",
|
||||
"../js/console.ts",
|
||||
"../js/console_table.ts",
|
||||
"../js/copy_file.ts",
|
||||
"../js/core.ts",
|
||||
"../js/custom_event.ts",
|
||||
"../js/deno.ts",
|
||||
"../js/diagnostics.ts",
|
||||
"../js/dir.ts",
|
||||
"../js/dispatch.ts",
|
||||
"../js/dispatch_json.ts",
|
||||
"../js/dispatch_minimal.ts",
|
||||
"../js/dom_file.ts",
|
||||
"../js/dom_types.ts",
|
||||
"../js/dom_util.ts",
|
||||
"../js/error_stack.ts",
|
||||
"../js/errors.ts",
|
||||
"../js/event.ts",
|
||||
"../js/event_target.ts",
|
||||
"../js/fetch.ts",
|
||||
"../js/file_info.ts",
|
||||
"../js/files.ts",
|
||||
"../js/form_data.ts",
|
||||
"../js/format_error.ts",
|
||||
"../js/get_random_values.ts",
|
||||
"../js/globals.ts",
|
||||
"../js/headers.ts",
|
||||
"../js/io.ts",
|
||||
"../js/lib.deno_runtime.d.ts",
|
||||
"../js/lib.web_assembly.d.ts",
|
||||
"../js/link.ts",
|
||||
"../js/location.ts",
|
||||
"../js/main.ts",
|
||||
"../js/make_temp_dir.ts",
|
||||
"../js/metrics.ts",
|
||||
"../js/mkdir.ts",
|
||||
"../js/mock_builtin.js",
|
||||
"../js/net.ts",
|
||||
"../js/os.ts",
|
||||
"../js/performance.ts",
|
||||
"../js/permissions.ts",
|
||||
"../js/process.ts",
|
||||
"../js/read_dir.ts",
|
||||
"../js/read_file.ts",
|
||||
"../js/read_link.ts",
|
||||
"../js/remove.ts",
|
||||
"../js/rename.ts",
|
||||
"../js/repl.ts",
|
||||
"../js/request.ts",
|
||||
"../js/resources.ts",
|
||||
"../js/stat.ts",
|
||||
"../js/symlink.ts",
|
||||
"../js/text_encoding.ts",
|
||||
"../js/timers.ts",
|
||||
"../js/truncate.ts",
|
||||
"../js/type_directives.ts",
|
||||
"../js/types.ts",
|
||||
"../js/url.ts",
|
||||
"../js/url_search_params.ts",
|
||||
"../js/util.ts",
|
||||
"../js/utime.ts",
|
||||
"../js/version.ts",
|
||||
"../js/window.ts",
|
||||
"../js/workers.ts",
|
||||
"../js/write_file.ts",
|
||||
"../js/xeval.ts",
|
||||
]
|
||||
|
||||
action("deno_cli_snapshots_build_run") {
|
||||
script = "run.py"
|
||||
inputs = ts_sources
|
||||
outputs = [
|
||||
"$root_out_dir/CLI_SNAPSHOT.bin",
|
||||
"$root_out_dir/CLI_SNAPSHOT.js",
|
||||
"$root_out_dir/CLI_SNAPSHOT.js.map",
|
||||
"$root_out_dir/CLI_SNAPSHOT.d.ts",
|
||||
"$root_out_dir/COMPILER_SNAPSHOT.bin",
|
||||
"$root_out_dir/COMPILER_SNAPSHOT.js",
|
||||
"$root_out_dir/COMPILER_SNAPSHOT.js.map",
|
||||
"$root_out_dir/COMPILER_SNAPSHOT.d.ts",
|
||||
]
|
||||
args = [ rebase_path("$root_out_dir/deno_cli_snapshots_build", ".") ]
|
||||
deps = [
|
||||
":deno_cli_snapshots_build",
|
||||
]
|
||||
}
|
||||
|
||||
rust_executable("deno_cli_snapshots_build") {
|
||||
source_root = "build.rs"
|
||||
extern = [
|
||||
{
|
||||
label = "../deno_typescript:deno_typescript"
|
||||
crate_name = "deno_typescript"
|
||||
crate_type = "rlib"
|
||||
},
|
||||
{
|
||||
label = "../core:deno"
|
||||
crate_name = "deno"
|
||||
crate_type = "rlib"
|
||||
},
|
||||
]
|
||||
}
|
18
cli_snapshots/Cargo.toml
Normal file
18
cli_snapshots/Cargo.toml
Normal file
|
@ -0,0 +1,18 @@
|
|||
[package]
|
||||
name = "deno_cli_snapshots"
|
||||
version = "0.0.3"
|
||||
license = "MIT"
|
||||
authors = ["Ryan Dahl <ry@tinyclouds.org>"]
|
||||
edition = "2018"
|
||||
description = "Provides snapshots for the deno CLI"
|
||||
repository = "https://github.com/ry/deno_typescript"
|
||||
|
||||
[lib]
|
||||
path = "lib.rs"
|
||||
|
||||
[dev-dependencies]
|
||||
deno = { path = "../core" }
|
||||
|
||||
[build-dependencies]
|
||||
deno_typescript = { path = "../deno_typescript", version = "0.0.3" }
|
||||
|
9
cli_snapshots/README.md
Normal file
9
cli_snapshots/README.md
Normal file
|
@ -0,0 +1,9 @@
|
|||
This is a small crate which exports just a few static blobs. It contains a
|
||||
build.rs file which compiles Deno's internal JavaScript and TypeScript code
|
||||
first into a single AMD bundle, and then into a binary V8 Snapshot.
|
||||
|
||||
The main Deno executable crate ("cli") depends on this crate and has access to
|
||||
all the runtime code.
|
||||
|
||||
The //js/ directory should be moved as a sub-directory of this crate, to denote
|
||||
the dependency structure. However, that is left to future work.
|
24
cli_snapshots/build.rs
Normal file
24
cli_snapshots/build.rs
Normal file
|
@ -0,0 +1,24 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
use std::env;
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn main() {
|
||||
// To debug snapshot issues uncomment:
|
||||
// deno_typescript::trace_serializer();
|
||||
|
||||
let c = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap());
|
||||
let o = PathBuf::from(env::var_os("OUT_DIR").unwrap());
|
||||
let js_dir = c.join("../js");
|
||||
|
||||
let root_names = vec![js_dir.join("main.ts")];
|
||||
let bundle = o.join("CLI_SNAPSHOT.js");
|
||||
let state = deno_typescript::compile_bundle(&bundle, root_names).unwrap();
|
||||
assert!(bundle.exists());
|
||||
deno_typescript::mksnapshot_bundle(&bundle, state).unwrap();
|
||||
|
||||
let root_names = vec![js_dir.join("compiler.ts")];
|
||||
let bundle = o.join("COMPILER_SNAPSHOT.js");
|
||||
let state = deno_typescript::compile_bundle(&bundle, root_names).unwrap();
|
||||
assert!(bundle.exists());
|
||||
deno_typescript::mksnapshot_bundle_ts(&bundle, state).unwrap();
|
||||
}
|
43
cli_snapshots/lib.rs
Normal file
43
cli_snapshots/lib.rs
Normal file
|
@ -0,0 +1,43 @@
|
|||
pub static CLI_SNAPSHOT: &[u8] =
|
||||
include_bytes!(concat!(env!("OUT_DIR"), "/CLI_SNAPSHOT.bin"));
|
||||
pub static CLI_SNAPSHOT_MAP: &[u8] =
|
||||
include_bytes!(concat!(env!("OUT_DIR"), "/CLI_SNAPSHOT.js.map"));
|
||||
pub static CLI_SNAPSHOT_DTS: &[u8] =
|
||||
include_bytes!(concat!(env!("OUT_DIR"), "/CLI_SNAPSHOT.d.ts"));
|
||||
|
||||
pub static COMPILER_SNAPSHOT: &[u8] =
|
||||
include_bytes!(concat!(env!("OUT_DIR"), "/COMPILER_SNAPSHOT.bin"));
|
||||
pub static COMPILER_SNAPSHOT_MAP: &[u8] =
|
||||
include_bytes!(concat!(env!("OUT_DIR"), "/COMPILER_SNAPSHOT.js.map"));
|
||||
pub static COMPILER_SNAPSHOT_DTS: &[u8] =
|
||||
include_bytes!(concat!(env!("OUT_DIR"), "/COMPILER_SNAPSHOT.d.ts"));
|
||||
|
||||
#[test]
|
||||
fn cli_snapshot() {
|
||||
let mut isolate =
|
||||
deno::Isolate::new(deno::StartupData::Snapshot(CLI_SNAPSHOT), false);
|
||||
deno::js_check(isolate.execute(
|
||||
"<anon>",
|
||||
r#"
|
||||
if (!window) {
|
||||
throw Error("bad");
|
||||
}
|
||||
console.log("we have console.log!!!");
|
||||
"#,
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn compiler_snapshot() {
|
||||
let mut isolate =
|
||||
deno::Isolate::new(deno::StartupData::Snapshot(COMPILER_SNAPSHOT), false);
|
||||
deno::js_check(isolate.execute(
|
||||
"<anon>",
|
||||
r#"
|
||||
if (!compilerMain) {
|
||||
throw Error("bad");
|
||||
}
|
||||
console.log(`ts version: ${ts.version}`);
|
||||
"#,
|
||||
));
|
||||
}
|
15
cli_snapshots/run.py
Normal file
15
cli_snapshots/run.py
Normal file
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/env python
|
||||
# Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
# This script is to execute build.rs during the GN build. See BUILD.gn.
|
||||
import subprocess
|
||||
import sys
|
||||
import os
|
||||
|
||||
d = os.path.dirname(os.path.realpath(__file__))
|
||||
exe = sys.argv[1]
|
||||
env = os.environ.copy()
|
||||
env["CARGO_MANIFEST_DIR"] = d
|
||||
env["OUT_DIR"] = os.path.dirname(exe)
|
||||
# To match the behavior of cargo, we need to cd into this directory.
|
||||
os.chdir(d)
|
||||
sys.exit(subprocess.call([exe], env=env))
|
|
@ -7,7 +7,6 @@ group("default") {
|
|||
":deno_core_http_bench",
|
||||
":deno_core_http_bench_test",
|
||||
":deno_core_test",
|
||||
":snapshot_creator",
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -78,14 +77,3 @@ rust_test("deno_core_http_bench_test") {
|
|||
extern = http_bench_extern
|
||||
extern_rlib = http_bench_extern_rlib
|
||||
}
|
||||
|
||||
rust_executable("snapshot_creator") {
|
||||
source_root = "snapshot_creator.rs"
|
||||
extern = [
|
||||
{
|
||||
label = ":deno"
|
||||
crate_name = "deno"
|
||||
crate_type = "rlib"
|
||||
},
|
||||
]
|
||||
}
|
||||
|
|
|
@ -13,12 +13,6 @@ repository = "https://github.com/denoland/deno"
|
|||
[lib]
|
||||
path = "lib.rs"
|
||||
|
||||
# NOTE: The ninja build of snapshot_creator gets clobbered by 'cargo build' if
|
||||
# the following is added. This breaks incremental 'cargo build'.
|
||||
# [[bin]]
|
||||
# name = "snapshot_creator"
|
||||
# path = "snapshot_creator.rs"
|
||||
|
||||
[dependencies]
|
||||
futures = "0.1.28"
|
||||
lazy_static = "1.3.0"
|
||||
|
|
26
core/core.d.ts
vendored
26
core/core.d.ts
vendored
|
@ -1,26 +0,0 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
// This file contains APIs that are introduced into the global namespace by
|
||||
// Deno core. These are not intended to be used directly by runtime users of
|
||||
// Deno and therefore do not flow through to the runtime type library.
|
||||
|
||||
declare interface MessageCallback {
|
||||
(opId: number, msg: Uint8Array): void;
|
||||
}
|
||||
|
||||
declare interface DenoCore {
|
||||
dispatch(
|
||||
opId: number,
|
||||
control: Uint8Array,
|
||||
zeroCopy?: ArrayBufferView | null
|
||||
): Uint8Array | null;
|
||||
setAsyncHandler(cb: MessageCallback): void;
|
||||
sharedQueue: {
|
||||
head(): number;
|
||||
numRecords(): number;
|
||||
size(): number;
|
||||
push(buf: Uint8Array): boolean;
|
||||
reset(): void;
|
||||
shift(): Uint8Array | null;
|
||||
};
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
// Note: This is a nearly identical rewrite of core/libdeno/snapshot_creator.cc
|
||||
// but in Rust.
|
||||
//
|
||||
// This snapshot program is considered "basic" because the code being
|
||||
// snapshotted cannot call ops.
|
||||
|
||||
extern crate deno;
|
||||
|
||||
use deno::js_check;
|
||||
use deno::Isolate;
|
||||
use deno::StartupData;
|
||||
use std::env;
|
||||
use std::io::Write;
|
||||
|
||||
fn main() {
|
||||
let args: Vec<String> = env::args().collect();
|
||||
// NOTE: `--help` arg will display V8 help and exit
|
||||
let args = deno::v8_set_flags(args);
|
||||
|
||||
let (snapshot_out_bin, js_filename) = if args.len() == 3 {
|
||||
(args[1].clone(), args[2].clone())
|
||||
} else {
|
||||
eprintln!("Usage: snapshot_creator <out_filename> <js_filename>");
|
||||
std::process::exit(1);
|
||||
};
|
||||
|
||||
let js_source =
|
||||
std::fs::read(&js_filename).expect("couldn't read js_filename");
|
||||
let js_source_str = std::str::from_utf8(&js_source).unwrap();
|
||||
|
||||
let will_snapshot = true;
|
||||
let mut isolate = Isolate::new(StartupData::None, will_snapshot);
|
||||
|
||||
js_check(isolate.execute(&js_filename, js_source_str));
|
||||
|
||||
let snapshot = isolate.snapshot().expect("error snapshotting");
|
||||
|
||||
let mut out_file = std::fs::File::create(snapshot_out_bin).unwrap();
|
||||
let snapshot_slice =
|
||||
unsafe { std::slice::from_raw_parts(snapshot.data_ptr, snapshot.data_len) };
|
||||
out_file
|
||||
.write_all(snapshot_slice)
|
||||
.expect("Failed to write snapshot file");
|
||||
}
|
22
deno_typescript/BUILD.gn
Normal file
22
deno_typescript/BUILD.gn
Normal file
|
@ -0,0 +1,22 @@
|
|||
import("//build_extra/rust/rust.gni")
|
||||
|
||||
rust_rlib("deno_typescript") {
|
||||
source_root = "lib.rs"
|
||||
generated_source_dir = "."
|
||||
extern = [
|
||||
{
|
||||
label = "../core:deno"
|
||||
crate_name = "deno"
|
||||
crate_type = "rlib"
|
||||
},
|
||||
{
|
||||
label = "$rust_build:serde_derive"
|
||||
crate_name = "serde_derive"
|
||||
crate_type = "proc_macro"
|
||||
},
|
||||
]
|
||||
extern_rlib = [
|
||||
"serde_json",
|
||||
"serde",
|
||||
]
|
||||
}
|
16
deno_typescript/Cargo.toml
Normal file
16
deno_typescript/Cargo.toml
Normal file
|
@ -0,0 +1,16 @@
|
|||
[package]
|
||||
name = "deno_typescript"
|
||||
version = "0.0.3"
|
||||
license = "MIT"
|
||||
description = "To compile TypeScript to a snapshot during build.rs"
|
||||
repository = "https://github.com/ry/deno_typescript"
|
||||
authors = ["Ryan Dahl <ry@tinyclouds.org>"]
|
||||
edition = "2018"
|
||||
|
||||
[lib]
|
||||
path = "lib.rs"
|
||||
|
||||
[dependencies]
|
||||
deno = { path = "../core" }
|
||||
serde_json = "1.0"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
8
deno_typescript/README.md
Normal file
8
deno_typescript/README.md
Normal file
|
@ -0,0 +1,8 @@
|
|||
This crate provides utilies to compile typescript, bundle it up, and create a V8
|
||||
snapshot, all during build. This allows users to startup fast.
|
||||
|
||||
The cli_snapshots crate, neighboring this one uses deno_typescript at build
|
||||
time.
|
||||
|
||||
This crate does not depend on Node, Python, nor any other external dependencies
|
||||
besides those listed as such in Cargo.toml.
|
39
deno_typescript/amd_runtime.js
Normal file
39
deno_typescript/amd_runtime.js
Normal file
|
@ -0,0 +1,39 @@
|
|||
// A very very basic AMD preamble to support the output of TypeScript outFile
|
||||
// bundles.
|
||||
let require, define;
|
||||
|
||||
(function() {
|
||||
const modules = new Map();
|
||||
|
||||
function println(first, ...s) {
|
||||
Deno.core.print(first + " " + s.map(JSON.stringify).join(" ") + "\n");
|
||||
}
|
||||
|
||||
function createOrLoadModule(name) {
|
||||
if (!modules.has(name)) {
|
||||
const m = { name, exports: {} };
|
||||
modules.set(name, m);
|
||||
}
|
||||
return modules.get(name);
|
||||
}
|
||||
|
||||
require = name => {
|
||||
return createOrLoadModule(name).exports;
|
||||
};
|
||||
|
||||
define = (name, deps, factory) => {
|
||||
const currentModule = createOrLoadModule(name);
|
||||
const localExports = currentModule.exports;
|
||||
const args = deps.map(dep => {
|
||||
if (dep === "require") {
|
||||
return require;
|
||||
} else if (dep === "exports") {
|
||||
return localExports;
|
||||
} else {
|
||||
const depModule = createOrLoadModule(dep);
|
||||
return depModule.exports;
|
||||
}
|
||||
});
|
||||
factory(...args);
|
||||
};
|
||||
})();
|
320
deno_typescript/compiler_main.js
Normal file
320
deno_typescript/compiler_main.js
Normal file
|
@ -0,0 +1,320 @@
|
|||
// Because we're bootstrapping the TS compiler without dependencies on Node,
|
||||
// this is written in JS.
|
||||
|
||||
const ASSETS = "$asset$";
|
||||
|
||||
let replacements;
|
||||
|
||||
function main(configText, rootNames, replacements_) {
|
||||
println(`>>> ts version ${ts.version}`);
|
||||
println(`>>> rootNames ${rootNames}`);
|
||||
|
||||
replacements = replacements_;
|
||||
replacements["DENO_REPLACE_TS_VERSION"] = ts.version;
|
||||
println(`>>> replacements ${JSON.stringify(replacements)}`);
|
||||
|
||||
const host = new Host();
|
||||
|
||||
assert(rootNames.length > 0);
|
||||
|
||||
let { options, diagnostics } = configure(configText);
|
||||
handleDiagnostics(host, diagnostics);
|
||||
|
||||
println(`>>> TS config: ${JSON.stringify(options)}`);
|
||||
|
||||
const program = ts.createProgram(rootNames, options, host);
|
||||
|
||||
diagnostics = ts.getPreEmitDiagnostics(program).filter(({ code }) => {
|
||||
// TS2691: An import path cannot end with a '.ts' extension. Consider
|
||||
// importing 'bad-module' instead.
|
||||
if (code === 2691) return false;
|
||||
// TS5009: Cannot find the common subdirectory path for the input files.
|
||||
if (code === 5009) return false;
|
||||
return true;
|
||||
});
|
||||
handleDiagnostics(host, diagnostics);
|
||||
|
||||
const emitResult = program.emit();
|
||||
handleDiagnostics(host, emitResult.diagnostics);
|
||||
|
||||
dispatch("setEmitResult", emitResult);
|
||||
}
|
||||
|
||||
function println(...s) {
|
||||
Deno.core.print(s.join(" ") + "\n");
|
||||
}
|
||||
|
||||
function unreachable() {
|
||||
throw Error("unreachable");
|
||||
}
|
||||
|
||||
function assert(cond) {
|
||||
if (!cond) {
|
||||
throw Error("assert");
|
||||
}
|
||||
}
|
||||
|
||||
// decode(Uint8Array): string
|
||||
function decodeAscii(ui8) {
|
||||
let out = "";
|
||||
for (let i = 0; i < ui8.length; i++) {
|
||||
out += String.fromCharCode(ui8[i]);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
function encode(str) {
|
||||
const charCodes = str.split("").map(c => c.charCodeAt(0));
|
||||
const ui8 = new Uint8Array(charCodes);
|
||||
return ui8;
|
||||
}
|
||||
|
||||
// Warning! The op_id values below are shared between this code and
|
||||
// the Rust side. Update with care!
|
||||
const ops = {
|
||||
readFile: 49,
|
||||
exit: 50,
|
||||
writeFile: 51,
|
||||
resolveModuleNames: 52,
|
||||
setEmitResult: 53
|
||||
};
|
||||
|
||||
// interface CompilerHost extends ModuleResolutionHost {
|
||||
class Host {
|
||||
// fileExists(fileName: string): boolean;
|
||||
fileExists(fileName) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// readFile(fileName: string): string | undefined;
|
||||
readFile() {
|
||||
unreachable();
|
||||
}
|
||||
|
||||
// trace?(s: string): void;
|
||||
// directoryExists?(directoryName: string): boolean;
|
||||
// realpath?(path: string): string;
|
||||
// getCurrentDirectory?(): string;
|
||||
// getDirectories?(path: string): string[];
|
||||
|
||||
// useCaseSensitiveFileNames(): boolean;
|
||||
useCaseSensitiveFileNames() {
|
||||
return false;
|
||||
}
|
||||
|
||||
// getDefaultLibFileName(options: CompilerOptions): string;
|
||||
getDefaultLibFileName(options) {
|
||||
return "lib.deno_core.d.ts";
|
||||
}
|
||||
|
||||
// getDefaultLibLocation?(): string;
|
||||
getDefaultLibLocation() {
|
||||
return ASSETS;
|
||||
}
|
||||
|
||||
// getCurrentDirectory(): string;
|
||||
getCurrentDirectory() {
|
||||
return ".";
|
||||
}
|
||||
|
||||
// getCanonicalFileName(fileName: string): string
|
||||
getCanonicalFileName(fileName) {
|
||||
unreachable();
|
||||
}
|
||||
|
||||
// getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?:
|
||||
// (message: string) => void, shouldCreateNewSourceFile?: boolean): SourceFile
|
||||
// | undefined;
|
||||
getSourceFile(fileName, languageVersion, onError, shouldCreateNewSourceFile) {
|
||||
assert(!shouldCreateNewSourceFile); // We haven't yet encountered this.
|
||||
|
||||
// This hacks around the fact that TypeScript tries to magically guess the
|
||||
// d.ts filename.
|
||||
if (fileName.startsWith("$typeRoots$")) {
|
||||
assert(fileName.startsWith("$typeRoots$/"));
|
||||
assert(fileName.endsWith("/index.d.ts"));
|
||||
fileName = fileName
|
||||
.replace("$typeRoots$/", "")
|
||||
.replace("/index.d.ts", "");
|
||||
}
|
||||
|
||||
let { sourceCode, moduleName } = dispatch("readFile", {
|
||||
fileName,
|
||||
languageVersion,
|
||||
shouldCreateNewSourceFile
|
||||
});
|
||||
|
||||
// TODO(ry) A terrible hack. Please remove ASAP.
|
||||
if (fileName.endsWith("typescript.d.ts")) {
|
||||
sourceCode = sourceCode.replace("export = ts;", "");
|
||||
}
|
||||
|
||||
// TODO(ry) A terrible hack. Please remove ASAP.
|
||||
for (let key of Object.keys(replacements)) {
|
||||
let val = replacements[key];
|
||||
sourceCode = sourceCode.replace(key, val);
|
||||
}
|
||||
|
||||
let sourceFile = ts.createSourceFile(fileName, sourceCode, languageVersion);
|
||||
sourceFile.moduleName = moduleName;
|
||||
return sourceFile;
|
||||
}
|
||||
|
||||
/*
|
||||
writeFile(
|
||||
fileName: string,
|
||||
data: string,
|
||||
writeByteOrderMark: boolean,
|
||||
onError?: (message: string) => void,
|
||||
sourceFiles?: ReadonlyArray<ts.SourceFile>
|
||||
): void
|
||||
*/
|
||||
writeFile(
|
||||
fileName,
|
||||
data,
|
||||
writeByteOrderMark,
|
||||
onError = null,
|
||||
sourceFiles = null
|
||||
) {
|
||||
const moduleName = sourceFiles[sourceFiles.length - 1].moduleName;
|
||||
return dispatch("writeFile", { fileName, moduleName, data });
|
||||
}
|
||||
|
||||
// getSourceFileByPath?(fileName: string, path: Path, languageVersion: ScriptTarget, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean): SourceFile | undefined;
|
||||
getSourceFileByPath(
|
||||
fileName,
|
||||
path,
|
||||
languageVersion,
|
||||
onError,
|
||||
shouldCreateNewSourceFile
|
||||
) {
|
||||
unreachable();
|
||||
}
|
||||
|
||||
// getCancellationToken?(): CancellationToken;
|
||||
getCancellationToken() {
|
||||
unreachable();
|
||||
}
|
||||
|
||||
// getCanonicalFileName(fileName: string): string;
|
||||
getCanonicalFileName(fileName) {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
// getNewLine(): string
|
||||
getNewLine() {
|
||||
return "\n";
|
||||
}
|
||||
|
||||
// readDirectory?(rootDir: string, extensions: ReadonlyArray<string>, excludes: ReadonlyArray<string> | undefined, includes: ReadonlyArray<string>, depth?: number): string[];
|
||||
readDirectory() {
|
||||
unreachable();
|
||||
}
|
||||
|
||||
// resolveModuleNames?(
|
||||
// moduleNames: string[],
|
||||
// containingFile: string,
|
||||
// reusedNames?: string[],
|
||||
// redirectedReference?: ResolvedProjectReference
|
||||
// ): (ResolvedModule | undefined)[];
|
||||
resolveModuleNames(moduleNames, containingFile) {
|
||||
const resolvedNames = dispatch("resolveModuleNames", {
|
||||
moduleNames,
|
||||
containingFile
|
||||
});
|
||||
const r = resolvedNames.map(resolvedFileName => {
|
||||
const extension = getExtension(resolvedFileName);
|
||||
return { resolvedFileName, extension };
|
||||
});
|
||||
return r;
|
||||
}
|
||||
|
||||
// resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[], containingFile: string, redirectedReference?: ResolvedProjectReference): (ResolvedTypeReferenceDirective | undefined)[];
|
||||
/*
|
||||
resolveTypeReferenceDirectives() {
|
||||
unreachable();
|
||||
}
|
||||
*/
|
||||
|
||||
// getEnvironmentVariable?(name: string): string | undefined;
|
||||
getEnvironmentVariable() {
|
||||
unreachable();
|
||||
}
|
||||
|
||||
// createHash?(data: string): string;
|
||||
createHash() {
|
||||
unreachable();
|
||||
}
|
||||
|
||||
// getParsedCommandLine?(fileName: string): ParsedCommandLine | undefined;
|
||||
getParsedCommandLine() {
|
||||
unreachable();
|
||||
}
|
||||
}
|
||||
|
||||
function configure(configurationText) {
|
||||
const { config, error } = ts.parseConfigFileTextToJson(
|
||||
"tsconfig.json",
|
||||
configurationText
|
||||
);
|
||||
if (error) {
|
||||
return { diagnostics: [error] };
|
||||
}
|
||||
const { options, errors } = ts.convertCompilerOptionsFromJson(
|
||||
config.compilerOptions,
|
||||
""
|
||||
);
|
||||
return {
|
||||
options,
|
||||
diagnostics: errors.length ? errors : undefined
|
||||
};
|
||||
}
|
||||
|
||||
function dispatch(opName, obj) {
|
||||
const s = JSON.stringify(obj);
|
||||
const msg = encode(s);
|
||||
const resUi8 = Deno.core.dispatch(ops[opName], msg);
|
||||
const resStr = decodeAscii(resUi8);
|
||||
const res = JSON.parse(resStr);
|
||||
if (!res["ok"]) {
|
||||
throw Error(`${opName} failed ${res["err"]}. Args: ${JSON.stringify(obj)}`);
|
||||
}
|
||||
return res["ok"];
|
||||
}
|
||||
|
||||
function exit(code) {
|
||||
dispatch("exit", { code });
|
||||
unreachable();
|
||||
}
|
||||
|
||||
// Maximum number of diagnostics to display.
|
||||
const MAX_ERRORS = 5;
|
||||
|
||||
function handleDiagnostics(host, diagnostics) {
|
||||
if (diagnostics && diagnostics.length) {
|
||||
let rest = 0;
|
||||
if (diagnostics.length > MAX_ERRORS) {
|
||||
rest = diagnostics.length - MAX_ERRORS;
|
||||
diagnostics = diagnostics.slice(0, MAX_ERRORS);
|
||||
}
|
||||
const msg = ts.formatDiagnosticsWithColorAndContext(diagnostics, host);
|
||||
println(msg);
|
||||
if (rest) {
|
||||
println(`And ${rest} other errors.`);
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
/** Returns the TypeScript Extension enum for a given media type. */
|
||||
function getExtension(fileName) {
|
||||
if (fileName.endsWith(".d.ts")) {
|
||||
return ts.Extension.Dts;
|
||||
} else if (fileName.endsWith(".ts")) {
|
||||
return ts.Extension.Ts;
|
||||
} else if (fileName.endsWith(".js")) {
|
||||
return ts.Extension.Js;
|
||||
} else {
|
||||
throw TypeError(`Cannot resolve extension for ${fileName}`);
|
||||
}
|
||||
}
|
|
@ -1,5 +1,13 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
// This file contains APIs that are introduced into the global namespace by
|
||||
// Deno core. These are not intended to be used directly by runtime users of
|
||||
// Deno and therefore do not flow through to the runtime type library.
|
||||
|
||||
declare interface MessageCallback {
|
||||
(opId: number, msg: Uint8Array): void;
|
||||
}
|
||||
|
||||
interface EvalErrorInfo {
|
||||
// Is the object thrown a native Error?
|
||||
isNativeError: boolean;
|
||||
|
@ -12,11 +20,23 @@ interface EvalErrorInfo {
|
|||
thrown: any;
|
||||
}
|
||||
|
||||
declare interface MessageCallback {
|
||||
(opId: number, msg: Uint8Array): void;
|
||||
}
|
||||
|
||||
declare interface DenoCore {
|
||||
print(s: string, is_err?: boolean);
|
||||
dispatch(
|
||||
opId: number,
|
||||
control: Uint8Array,
|
||||
zeroCopy?: ArrayBufferView | null
|
||||
): Uint8Array | null;
|
||||
setAsyncHandler(cb: MessageCallback): void;
|
||||
sharedQueue: {
|
||||
head(): number;
|
||||
numRecords(): number;
|
||||
size(): number;
|
||||
push(buf: Uint8Array): boolean;
|
||||
reset(): void;
|
||||
shift(): Uint8Array | null;
|
||||
};
|
||||
|
||||
recv(cb: MessageCallback): void;
|
||||
|
||||
send(
|
||||
|
@ -39,3 +59,8 @@ declare interface DenoCore {
|
|||
|
||||
errorToJSON: (e: Error) => string;
|
||||
}
|
||||
|
||||
declare interface DenoInterface {
|
||||
core: DenoCore;
|
||||
}
|
||||
declare var Deno: DenoInterface;
|
288
deno_typescript/lib.rs
Normal file
288
deno_typescript/lib.rs
Normal file
|
@ -0,0 +1,288 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
extern crate deno;
|
||||
extern crate serde;
|
||||
extern crate serde_json;
|
||||
|
||||
mod ops;
|
||||
use deno::js_check;
|
||||
pub use deno::v8_set_flags;
|
||||
use deno::ErrBox;
|
||||
use deno::Isolate;
|
||||
use deno::ModuleSpecifier;
|
||||
use deno::StartupData;
|
||||
pub use ops::EmitResult;
|
||||
use ops::WrittenFile;
|
||||
use std::collections::HashMap;
|
||||
use std::fs;
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
use std::sync::Mutex;
|
||||
|
||||
static TYPESCRIPT_CODE: &str =
|
||||
include_str!("../third_party/node_modules/typescript/lib/typescript.js");
|
||||
static COMPILER_CODE: &str = include_str!("compiler_main.js");
|
||||
static AMD_RUNTIME_CODE: &str = include_str!("amd_runtime.js");
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct TSState {
|
||||
bundle: bool,
|
||||
exit_code: i32,
|
||||
emit_result: Option<EmitResult>,
|
||||
/// A list of files emitted by typescript. WrittenFile is tuple of the form
|
||||
/// (url, corresponding_module, source_code)
|
||||
written_files: Vec<WrittenFile>,
|
||||
}
|
||||
|
||||
impl TSState {
|
||||
fn main_module_name(&self) -> String {
|
||||
// Assuming that TypeScript has emitted the main file last.
|
||||
self.written_files.last().unwrap().module_name.clone()
|
||||
}
|
||||
}
|
||||
|
||||
pub struct TSIsolate {
|
||||
isolate: Isolate,
|
||||
state: Arc<Mutex<TSState>>,
|
||||
}
|
||||
|
||||
impl TSIsolate {
|
||||
fn new(bundle: bool) -> TSIsolate {
|
||||
let mut isolate = Isolate::new(StartupData::None, false);
|
||||
js_check(isolate.execute("assets/typescript.js", TYPESCRIPT_CODE));
|
||||
js_check(isolate.execute("compiler_main.js", COMPILER_CODE));
|
||||
|
||||
let state = Arc::new(Mutex::new(TSState {
|
||||
bundle,
|
||||
exit_code: 0,
|
||||
emit_result: None,
|
||||
written_files: Vec::new(),
|
||||
}));
|
||||
let state_ = state.clone();
|
||||
isolate.set_dispatch(move |op_id, control_buf, zero_copy_buf| {
|
||||
assert!(zero_copy_buf.is_none()); // zero_copy_buf unused in compiler.
|
||||
let mut s = state_.lock().unwrap();
|
||||
ops::dispatch_op(&mut s, op_id, control_buf)
|
||||
});
|
||||
TSIsolate { isolate, state }
|
||||
}
|
||||
|
||||
// TODO(ry) Instead of Result<Arc<Mutex<TSState>>, ErrBox>, return something
|
||||
// like Result<TSState, ErrBox>. I think it would be nicer if this function
|
||||
// consumes TSIsolate.
|
||||
/// Compiles each module to ESM. Doesn't write any files to disk.
|
||||
/// Passes all output via state.
|
||||
fn compile(
|
||||
mut self,
|
||||
config_json: &serde_json::Value,
|
||||
root_names: Vec<String>,
|
||||
) -> Result<Arc<Mutex<TSState>>, ErrBox> {
|
||||
let root_names_json = serde_json::json!(root_names).to_string();
|
||||
let source = &format!(
|
||||
"main({:?}, {}, {})",
|
||||
config_json.to_string(),
|
||||
root_names_json,
|
||||
preprocessor_replacements_json()
|
||||
);
|
||||
self.isolate.execute("<anon>", source)?;
|
||||
Ok(self.state.clone())
|
||||
}
|
||||
}
|
||||
|
||||
pub fn compile_bundle(
|
||||
bundle: &Path,
|
||||
root_names: Vec<PathBuf>,
|
||||
) -> Result<Arc<Mutex<TSState>>, ErrBox> {
|
||||
let ts_isolate = TSIsolate::new(true);
|
||||
|
||||
let config_json = serde_json::json!({
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"lib": ["esnext"],
|
||||
"module": "amd",
|
||||
"target": "esnext",
|
||||
"listFiles": true,
|
||||
"listEmittedFiles": true,
|
||||
// "types" : ["typescript.d.ts"],
|
||||
"typeRoots" : ["$typeRoots$"],
|
||||
// Emit the source alongside the sourcemaps within a single file;
|
||||
// requires --inlineSourceMap or --sourceMap to be set.
|
||||
// "inlineSources": true,
|
||||
"sourceMap": true,
|
||||
"outFile": bundle,
|
||||
},
|
||||
});
|
||||
|
||||
let mut root_names_str: Vec<String> = root_names
|
||||
.iter()
|
||||
.map(|p| {
|
||||
if !p.exists() {
|
||||
panic!("File not found {}", p.display());
|
||||
}
|
||||
|
||||
let module_specifier =
|
||||
ModuleSpecifier::resolve_url_or_path(&p.to_string_lossy()).unwrap();
|
||||
module_specifier.as_str().to_string()
|
||||
})
|
||||
.collect();
|
||||
root_names_str.push("$asset$/lib.deno_core.d.ts".to_string());
|
||||
|
||||
// TODO lift js_check to caller?
|
||||
let state = js_check(ts_isolate.compile(&config_json, root_names_str));
|
||||
|
||||
Ok(state)
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn print_source_code(code: &str) {
|
||||
let mut i = 1;
|
||||
for line in code.lines() {
|
||||
println!("{:3} {}", i, line);
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
|
||||
/// Create a V8 snapshot.
|
||||
pub fn mksnapshot_bundle(
|
||||
bundle: &Path,
|
||||
state: Arc<Mutex<TSState>>,
|
||||
) -> Result<(), ErrBox> {
|
||||
let mut runtime_isolate = Isolate::new(StartupData::None, true);
|
||||
let source_code_vec = std::fs::read(bundle)?;
|
||||
let source_code = std::str::from_utf8(&source_code_vec)?;
|
||||
|
||||
js_check(runtime_isolate.execute("amd_runtime.js", AMD_RUNTIME_CODE));
|
||||
js_check(runtime_isolate.execute(&bundle.to_string_lossy(), &source_code));
|
||||
|
||||
let main = state.lock().unwrap().main_module_name();
|
||||
js_check(runtime_isolate.execute("anon", &format!("require('{}')", main)));
|
||||
|
||||
write_snapshot(runtime_isolate, bundle)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Create a V8 snapshot. This differs from mksnapshot_bundle in that is also
|
||||
/// runs typescript.js
|
||||
pub fn mksnapshot_bundle_ts(
|
||||
bundle: &Path,
|
||||
state: Arc<Mutex<TSState>>,
|
||||
) -> Result<(), ErrBox> {
|
||||
let mut runtime_isolate = Isolate::new(StartupData::None, true);
|
||||
let source_code_vec = std::fs::read(bundle)?;
|
||||
let source_code = std::str::from_utf8(&source_code_vec)?;
|
||||
|
||||
js_check(runtime_isolate.execute("amd_runtime.js", AMD_RUNTIME_CODE));
|
||||
js_check(runtime_isolate.execute("typescript.js", TYPESCRIPT_CODE));
|
||||
js_check(runtime_isolate.execute(&bundle.to_string_lossy(), &source_code));
|
||||
|
||||
let main = state.lock().unwrap().main_module_name();
|
||||
js_check(runtime_isolate.execute("anon", &format!("require('{}')", main)));
|
||||
|
||||
write_snapshot(runtime_isolate, bundle)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn write_snapshot(
|
||||
runtime_isolate: Isolate,
|
||||
bundle: &Path,
|
||||
) -> Result<(), ErrBox> {
|
||||
println!("creating snapshot...");
|
||||
let snapshot = runtime_isolate.snapshot()?;
|
||||
let snapshot_slice =
|
||||
unsafe { std::slice::from_raw_parts(snapshot.data_ptr, snapshot.data_len) };
|
||||
println!("snapshot bytes {}", snapshot_slice.len());
|
||||
|
||||
let snapshot_path = bundle.with_extension("bin");
|
||||
|
||||
fs::write(&snapshot_path, snapshot_slice)?;
|
||||
println!("snapshot path {} ", snapshot_path.display());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
macro_rules! inc {
|
||||
($e:expr) => {
|
||||
Some(include_str!(concat!(
|
||||
"../third_party/node_modules/typescript/lib/",
|
||||
$e
|
||||
)))
|
||||
};
|
||||
}
|
||||
|
||||
/// Same as get_asset() but returns NotFound intead of None.
|
||||
pub fn get_asset2(name: &str) -> Result<&'static str, ErrBox> {
|
||||
match get_asset(name) {
|
||||
Some(a) => Ok(a),
|
||||
None => Err(
|
||||
std::io::Error::new(std::io::ErrorKind::NotFound, "Asset not found")
|
||||
.into(),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_asset(name: &str) -> Option<&'static str> {
|
||||
match name {
|
||||
"lib.deno_core.d.ts" => Some(include_str!("lib.deno_core.d.ts")),
|
||||
"lib.esnext.d.ts" => inc!("lib.esnext.d.ts"),
|
||||
"lib.es2019.d.ts" => inc!("lib.es2019.d.ts"),
|
||||
"lib.es2018.d.ts" => inc!("lib.es2018.d.ts"),
|
||||
"lib.es2017.d.ts" => inc!("lib.es2017.d.ts"),
|
||||
"lib.es2016.d.ts" => inc!("lib.es2016.d.ts"),
|
||||
"lib.es5.d.ts" => inc!("lib.es5.d.ts"),
|
||||
"lib.es2015.d.ts" => inc!("lib.es2015.d.ts"),
|
||||
"lib.es2015.core.d.ts" => inc!("lib.es2015.core.d.ts"),
|
||||
"lib.es2015.collection.d.ts" => inc!("lib.es2015.collection.d.ts"),
|
||||
"lib.es2015.generator.d.ts" => inc!("lib.es2015.generator.d.ts"),
|
||||
"lib.es2015.iterable.d.ts" => inc!("lib.es2015.iterable.d.ts"),
|
||||
"lib.es2015.promise.d.ts" => inc!("lib.es2015.promise.d.ts"),
|
||||
"lib.es2015.symbol.d.ts" => inc!("lib.es2015.symbol.d.ts"),
|
||||
"lib.es2015.proxy.d.ts" => inc!("lib.es2015.proxy.d.ts"),
|
||||
"lib.es2015.symbol.wellknown.d.ts" => {
|
||||
inc!("lib.es2015.symbol.wellknown.d.ts")
|
||||
}
|
||||
"lib.es2015.reflect.d.ts" => inc!("lib.es2015.reflect.d.ts"),
|
||||
"lib.es2016.array.include.d.ts" => inc!("lib.es2016.array.include.d.ts"),
|
||||
"lib.es2017.object.d.ts" => inc!("lib.es2017.object.d.ts"),
|
||||
"lib.es2017.sharedmemory.d.ts" => inc!("lib.es2017.sharedmemory.d.ts"),
|
||||
"lib.es2017.string.d.ts" => inc!("lib.es2017.string.d.ts"),
|
||||
"lib.es2017.intl.d.ts" => inc!("lib.es2017.intl.d.ts"),
|
||||
"lib.es2017.typedarrays.d.ts" => inc!("lib.es2017.typedarrays.d.ts"),
|
||||
"lib.es2018.asynciterable.d.ts" => inc!("lib.es2018.asynciterable.d.ts"),
|
||||
"lib.es2018.promise.d.ts" => inc!("lib.es2018.promise.d.ts"),
|
||||
"lib.es2018.regexp.d.ts" => inc!("lib.es2018.regexp.d.ts"),
|
||||
"lib.es2018.intl.d.ts" => inc!("lib.es2018.intl.d.ts"),
|
||||
"lib.es2019.array.d.ts" => inc!("lib.es2019.array.d.ts"),
|
||||
"lib.es2019.object.d.ts" => inc!("lib.es2019.object.d.ts"),
|
||||
"lib.es2019.string.d.ts" => inc!("lib.es2019.string.d.ts"),
|
||||
"lib.es2019.symbol.d.ts" => inc!("lib.es2019.symbol.d.ts"),
|
||||
"lib.esnext.bigint.d.ts" => inc!("lib.esnext.bigint.d.ts"),
|
||||
"lib.esnext.intl.d.ts" => inc!("lib.esnext.intl.d.ts"),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Sets the --trace-serializer V8 flag for debugging snapshots.
|
||||
pub fn trace_serializer() {
|
||||
let dummy = "foo".to_string();
|
||||
let r =
|
||||
deno::v8_set_flags(vec![dummy.clone(), "--trace-serializer".to_string()]);
|
||||
assert_eq!(r, vec![dummy]);
|
||||
}
|
||||
|
||||
fn preprocessor_replacements_json() -> String {
|
||||
/// BUILD_OS and BUILD_ARCH match the values in Deno.build. See js/build.ts.
|
||||
#[cfg(target_os = "macos")]
|
||||
static BUILD_OS: &str = "mac";
|
||||
#[cfg(target_os = "linux")]
|
||||
static BUILD_OS: &str = "linux";
|
||||
#[cfg(target_os = "windows")]
|
||||
static BUILD_OS: &str = "win";
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
static BUILD_ARCH: &str = "x64";
|
||||
|
||||
let mut replacements = HashMap::new();
|
||||
replacements.insert("DENO_REPLACE_OS", BUILD_OS);
|
||||
replacements.insert("DENO_REPLACE_ARCH", BUILD_ARCH);
|
||||
serde_json::json!(replacements).to_string()
|
||||
}
|
141
deno_typescript/ops.rs
Normal file
141
deno_typescript/ops.rs
Normal file
|
@ -0,0 +1,141 @@
|
|||
use crate::TSState;
|
||||
use deno::CoreOp;
|
||||
use deno::ErrBox;
|
||||
use deno::ModuleSpecifier;
|
||||
use deno::Op;
|
||||
use deno::OpId;
|
||||
use serde::Deserialize;
|
||||
use serde_json::json;
|
||||
use serde_json::Value;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct WrittenFile {
|
||||
pub url: String,
|
||||
pub module_name: String,
|
||||
pub source_code: String,
|
||||
}
|
||||
|
||||
fn dispatch2(
|
||||
s: &mut TSState,
|
||||
op_id: OpId,
|
||||
control_buf: &[u8],
|
||||
) -> Result<Value, ErrBox> {
|
||||
let v = serde_json::from_slice(control_buf)?;
|
||||
// Warning! The op_id values below are shared between this code and
|
||||
// compiler_main.js. Update with care!
|
||||
match op_id {
|
||||
49 => read_file(s, v),
|
||||
50 => exit(s, v),
|
||||
51 => write_file(s, v),
|
||||
52 => resolve_module_names(s, v),
|
||||
53 => set_emit_result(s, v),
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn dispatch_op(s: &mut TSState, op_id: OpId, control_buf: &[u8]) -> CoreOp {
|
||||
let result = dispatch2(s, op_id, control_buf);
|
||||
let response = match result {
|
||||
Ok(v) => json!({ "ok": v }),
|
||||
Err(err) => json!({ "err": err.to_string() }),
|
||||
};
|
||||
let x = serde_json::to_string(&response).unwrap();
|
||||
let vec = x.into_bytes();
|
||||
Op::Sync(vec.into_boxed_slice())
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct ReadFile {
|
||||
file_name: String,
|
||||
language_version: Option<i32>,
|
||||
should_create_new_source_file: bool,
|
||||
}
|
||||
|
||||
fn read_file(_s: &mut TSState, v: Value) -> Result<Value, ErrBox> {
|
||||
let v: ReadFile = serde_json::from_value(v)?;
|
||||
let (module_name, source_code) = if v.file_name.starts_with("$asset$/") {
|
||||
let asset = v.file_name.replace("$asset$/", "");
|
||||
let source_code = crate::get_asset2(&asset)?.to_string();
|
||||
(asset, source_code)
|
||||
} else {
|
||||
assert!(!v.file_name.starts_with("$assets$"), "you meant $asset$");
|
||||
let module_specifier = ModuleSpecifier::resolve_url_or_path(&v.file_name)?;
|
||||
let path = module_specifier.as_url().to_file_path().unwrap();
|
||||
println!("cargo:rerun-if-changed={}", path.display());
|
||||
(
|
||||
module_specifier.as_str().to_string(),
|
||||
std::fs::read_to_string(&path)?,
|
||||
)
|
||||
};
|
||||
Ok(json!({
|
||||
"moduleName": module_name,
|
||||
"sourceCode": source_code,
|
||||
}))
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct WriteFile {
|
||||
file_name: String,
|
||||
data: String,
|
||||
module_name: String,
|
||||
}
|
||||
|
||||
fn write_file(s: &mut TSState, v: Value) -> Result<Value, ErrBox> {
|
||||
let v: WriteFile = serde_json::from_value(v)?;
|
||||
let module_specifier = ModuleSpecifier::resolve_url_or_path(&v.file_name)?;
|
||||
if s.bundle {
|
||||
std::fs::write(&v.file_name, &v.data)?;
|
||||
}
|
||||
s.written_files.push(WrittenFile {
|
||||
url: module_specifier.as_str().to_string(),
|
||||
module_name: v.module_name,
|
||||
source_code: v.data,
|
||||
});
|
||||
Ok(json!(true))
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct ResolveModuleNames {
|
||||
module_names: Vec<String>,
|
||||
containing_file: String,
|
||||
}
|
||||
|
||||
fn resolve_module_names(_s: &mut TSState, v: Value) -> Result<Value, ErrBox> {
|
||||
let v: ResolveModuleNames = serde_json::from_value(v).unwrap();
|
||||
let mut resolved = Vec::<String>::new();
|
||||
let referrer = ModuleSpecifier::resolve_url_or_path(&v.containing_file)?;
|
||||
for specifier in v.module_names {
|
||||
let ms = ModuleSpecifier::resolve_import(&specifier, referrer.as_str())?;
|
||||
resolved.push(ms.as_str().to_string());
|
||||
}
|
||||
Ok(json!(resolved))
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct Exit {
|
||||
code: i32,
|
||||
}
|
||||
|
||||
fn exit(s: &mut TSState, v: Value) -> Result<Value, ErrBox> {
|
||||
let v: Exit = serde_json::from_value(v)?;
|
||||
s.exit_code = v.code;
|
||||
std::process::exit(v.code)
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct EmitResult {
|
||||
pub emit_skipped: bool,
|
||||
pub diagnostics: Vec<String>,
|
||||
pub emitted_files: Vec<String>,
|
||||
}
|
||||
|
||||
fn set_emit_result(s: &mut TSState, v: Value) -> Result<Value, ErrBox> {
|
||||
let v: EmitResult = serde_json::from_value(v)?;
|
||||
s.emit_result = Some(v);
|
||||
Ok(json!(true))
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import * as domTypes from "./dom_types";
|
||||
import { containsOnlyASCII, hasOwnProperty } from "./util";
|
||||
import { TextEncoder } from "./text_encoding";
|
||||
import { build } from "./build";
|
||||
import * as domTypes from "./dom_types.ts";
|
||||
import { containsOnlyASCII, hasOwnProperty } from "./util.ts";
|
||||
import { TextEncoder } from "./text_encoding.ts";
|
||||
import { build } from "./build.ts";
|
||||
|
||||
export const bytesSymbol = Symbol("bytes");
|
||||
|
||||
|
|
10
js/body.ts
10
js/body.ts
|
@ -1,8 +1,8 @@
|
|||
import * as formData from "./form_data";
|
||||
import * as blob from "./blob";
|
||||
import * as encoding from "./text_encoding";
|
||||
import * as headers from "./headers";
|
||||
import * as domTypes from "./dom_types";
|
||||
import * as formData from "./form_data.ts";
|
||||
import * as blob from "./blob.ts";
|
||||
import * as encoding from "./text_encoding.ts";
|
||||
import * as headers from "./headers.ts";
|
||||
import * as domTypes from "./dom_types.ts";
|
||||
|
||||
const { Headers } = headers;
|
||||
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
// Copyright 2009 The Go Authors. All rights reserved. BSD license.
|
||||
// https://github.com/golang/go/blob/master/LICENSE
|
||||
|
||||
import { Reader, Writer, EOF, SyncReader, SyncWriter } from "./io";
|
||||
import { assert } from "./util";
|
||||
import { TextDecoder } from "./text_encoding";
|
||||
import { DenoError, ErrorKind } from "./errors";
|
||||
import { Reader, Writer, EOF, SyncReader, SyncWriter } from "./io.ts";
|
||||
import { assert } from "./util.ts";
|
||||
import { TextDecoder } from "./text_encoding.ts";
|
||||
import { DenoError, ErrorKind } from "./errors.ts";
|
||||
|
||||
// MIN_READ is the minimum ArrayBuffer size passed to a read call by
|
||||
// buffer.ReadFrom. As long as the Buffer has at least MIN_READ bytes beyond
|
||||
|
|
|
@ -18,9 +18,9 @@ export interface BuildInfo {
|
|||
export const build: BuildInfo = {
|
||||
// These string will be replaced by rollup
|
||||
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
||||
arch: `ROLLUP_REPLACE_ARCH` as any,
|
||||
arch: `DENO_REPLACE_ARCH` as any,
|
||||
/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
|
||||
os: `ROLLUP_REPLACE_OS` as any
|
||||
os: `DENO_REPLACE_OS` as any
|
||||
};
|
||||
|
||||
// TODO(kevinkassimo): deprecate Deno.platform
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import { sendSync, sendAsync } from "./dispatch_json";
|
||||
import * as dispatch from "./dispatch";
|
||||
import { sendSync, sendAsync } from "./dispatch_json.ts";
|
||||
import * as dispatch from "./dispatch.ts";
|
||||
|
||||
/** Changes the permission of a specific file/directory of specified path
|
||||
* synchronously.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import { sendSync, sendAsync } from "./dispatch_json";
|
||||
import * as dispatch from "./dispatch";
|
||||
import { sendSync, sendAsync } from "./dispatch_json.ts";
|
||||
import * as dispatch from "./dispatch.ts";
|
||||
|
||||
/**
|
||||
* Change owner of a regular file or directory synchronously. Unix only at the moment.
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
// TODO(kitsonk) Replace with `deno_std/colors/mod.ts` when we can load modules
|
||||
// which end in `.ts`.
|
||||
|
||||
import { noColor } from "./os";
|
||||
import { noColor } from "./deno.ts";
|
||||
|
||||
interface Code {
|
||||
open: string;
|
||||
|
|
|
@ -1,20 +1,25 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import * as ts from "typescript";
|
||||
import { bold, cyan, yellow } from "./colors";
|
||||
import { Console } from "./console";
|
||||
import { core } from "./core";
|
||||
import { Diagnostic, fromTypeScriptDiagnostic } from "./diagnostics";
|
||||
import { cwd } from "./dir";
|
||||
import * as dispatch from "./dispatch";
|
||||
import { sendSync } from "./dispatch_json";
|
||||
import * as os from "./os";
|
||||
import { TextEncoder } from "./text_encoding";
|
||||
import { getMappedModuleName, parseTypeDirectives } from "./type_directives";
|
||||
import { assert, notImplemented } from "./util";
|
||||
import * as util from "./util";
|
||||
import { window } from "./window";
|
||||
import { postMessage, workerClose, workerMain } from "./workers";
|
||||
import { writeFileSync } from "./write_file";
|
||||
// TODO(ry) Combine this implementation with //deno_typescript/compiler_main.js
|
||||
|
||||
/// <reference types="../third_party/node_modules/typescript/lib/typescript.d.ts"/>
|
||||
|
||||
import "./globals.ts";
|
||||
|
||||
import { bold, cyan, yellow } from "./colors.ts";
|
||||
import { Console } from "./console.ts";
|
||||
import { core } from "./core.ts";
|
||||
import { Diagnostic, fromTypeScriptDiagnostic } from "./diagnostics.ts";
|
||||
import { cwd } from "./dir.ts";
|
||||
import * as dispatch from "./dispatch.ts";
|
||||
import { sendSync } from "./dispatch_json.ts";
|
||||
import * as os from "./os.ts";
|
||||
import { TextEncoder } from "./text_encoding.ts";
|
||||
import { getMappedModuleName, parseTypeDirectives } from "./type_directives.ts";
|
||||
import { assert, notImplemented } from "./util.ts";
|
||||
import * as util from "./util.ts";
|
||||
import { window } from "./window.ts";
|
||||
import { postMessage, workerClose, workerMain } from "./workers.ts";
|
||||
import { writeFileSync } from "./write_file.ts";
|
||||
|
||||
// Warning! The values in this enum are duplicated in cli/msg.rs
|
||||
// Update carefully!
|
||||
|
@ -31,9 +36,10 @@ enum MediaType {
|
|||
const console = new Console(core.print);
|
||||
window.console = console;
|
||||
window.workerMain = workerMain;
|
||||
export default function denoMain(): void {
|
||||
function denoMain(): void {
|
||||
os.start(true, "TS");
|
||||
}
|
||||
window["denoMain"] = denoMain;
|
||||
|
||||
const ASSETS = "$asset$";
|
||||
const OUT_DIR = "$deno$";
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import { isTypedArray } from "./util";
|
||||
import { TypedArray } from "./types";
|
||||
import { TextEncoder } from "./text_encoding";
|
||||
import { File, stdout } from "./files";
|
||||
import { cliTable } from "./console_table";
|
||||
import { isTypedArray } from "./util.ts";
|
||||
import { TypedArray } from "./types.ts";
|
||||
import { TextEncoder } from "./text_encoding.ts";
|
||||
import { File, stdout } from "./files.ts";
|
||||
import { cliTable } from "./console_table.ts";
|
||||
|
||||
type ConsoleContext = Set<unknown>;
|
||||
type ConsoleOptions = Partial<{
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
// Copyright Joyent, Inc. and other Node contributors. MIT license.
|
||||
// Forked from Node's lib/internal/cli_table.js
|
||||
|
||||
import { TextEncoder } from "./text_encoding";
|
||||
import { hasOwnProperty } from "./util";
|
||||
import { TextEncoder } from "./text_encoding.ts";
|
||||
import { hasOwnProperty } from "./util.ts";
|
||||
|
||||
const encoder = new TextEncoder();
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import { sendSync, sendAsync } from "./dispatch_json";
|
||||
import * as dispatch from "./dispatch";
|
||||
import { sendSync, sendAsync } from "./dispatch_json.ts";
|
||||
import * as dispatch from "./dispatch.ts";
|
||||
|
||||
/** Copies the contents of a file to another by name synchronously.
|
||||
* Creates a new file if target does not exists, and if target exists,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import { window } from "./window";
|
||||
import { window } from "./window.ts";
|
||||
|
||||
// This allows us to access core in API even if we
|
||||
// dispose window.Deno
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright 2018 the Deno authors. All rights reserved. MIT license.
|
||||
import * as domTypes from "./dom_types";
|
||||
import * as event from "./event";
|
||||
import { getPrivateValue, requiredArguments } from "./util";
|
||||
import * as domTypes from "./dom_types.ts";
|
||||
import * as event from "./event.ts";
|
||||
import { getPrivateValue, requiredArguments } from "./util.ts";
|
||||
|
||||
// WeakMaps are recommended for private attributes (see MDN link below)
|
||||
// https://developer.mozilla.org/en-US/docs/Archive/Add-ons/Add-on_SDK/Guides/Contributor_s_Guide/Private_Properties#Using_WeakMaps
|
||||
|
|
90
js/deno.ts
90
js/deno.ts
|
@ -1,8 +1,8 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
// Public deno module.
|
||||
export { noColor, pid, env, exit, isTTY, execPath, homeDir } from "./os";
|
||||
export { chdir, cwd } from "./dir";
|
||||
export { env, exit, isTTY, execPath, homeDir } from "./os.ts";
|
||||
export { chdir, cwd } from "./dir.ts";
|
||||
export {
|
||||
File,
|
||||
open,
|
||||
|
@ -18,7 +18,7 @@ export {
|
|||
seekSync,
|
||||
close,
|
||||
OpenMode
|
||||
} from "./files";
|
||||
} from "./files.ts";
|
||||
export {
|
||||
EOF,
|
||||
copy,
|
||||
|
@ -37,40 +37,46 @@ export {
|
|||
WriteSeeker,
|
||||
ReadWriteCloser,
|
||||
ReadWriteSeeker
|
||||
} from "./io";
|
||||
export { Buffer, readAll, readAllSync, writeAll, writeAllSync } from "./buffer";
|
||||
export { mkdirSync, mkdir } from "./mkdir";
|
||||
} from "./io.ts";
|
||||
export {
|
||||
Buffer,
|
||||
readAll,
|
||||
readAllSync,
|
||||
writeAll,
|
||||
writeAllSync
|
||||
} from "./buffer.ts";
|
||||
export { mkdirSync, mkdir } from "./mkdir.ts";
|
||||
export {
|
||||
makeTempDirSync,
|
||||
makeTempDir,
|
||||
MakeTempDirOptions
|
||||
} from "./make_temp_dir";
|
||||
export { chmodSync, chmod } from "./chmod";
|
||||
export { chownSync, chown } from "./chown";
|
||||
export { utimeSync, utime } from "./utime";
|
||||
export { removeSync, remove, RemoveOption } from "./remove";
|
||||
export { renameSync, rename } from "./rename";
|
||||
export { readFileSync, readFile } from "./read_file";
|
||||
export { readDirSync, readDir } from "./read_dir";
|
||||
export { copyFileSync, copyFile } from "./copy_file";
|
||||
export { readlinkSync, readlink } from "./read_link";
|
||||
export { statSync, lstatSync, stat, lstat } from "./stat";
|
||||
export { linkSync, link } from "./link";
|
||||
export { symlinkSync, symlink } from "./symlink";
|
||||
export { writeFileSync, writeFile, WriteFileOptions } from "./write_file";
|
||||
export { applySourceMap } from "./error_stack";
|
||||
export { ErrorKind, DenoError } from "./errors";
|
||||
} from "./make_temp_dir.ts";
|
||||
export { chmodSync, chmod } from "./chmod.ts";
|
||||
export { chownSync, chown } from "./chown.ts";
|
||||
export { utimeSync, utime } from "./utime.ts";
|
||||
export { removeSync, remove, RemoveOption } from "./remove.ts";
|
||||
export { renameSync, rename } from "./rename.ts";
|
||||
export { readFileSync, readFile } from "./read_file.ts";
|
||||
export { readDirSync, readDir } from "./read_dir.ts";
|
||||
export { copyFileSync, copyFile } from "./copy_file.ts";
|
||||
export { readlinkSync, readlink } from "./read_link.ts";
|
||||
export { statSync, lstatSync, stat, lstat } from "./stat.ts";
|
||||
export { linkSync, link } from "./link.ts";
|
||||
export { symlinkSync, symlink } from "./symlink.ts";
|
||||
export { writeFileSync, writeFile, WriteFileOptions } from "./write_file.ts";
|
||||
export { applySourceMap } from "./error_stack.ts";
|
||||
export { ErrorKind, DenoError } from "./errors.ts";
|
||||
export {
|
||||
permissions,
|
||||
revokePermission,
|
||||
Permission,
|
||||
Permissions
|
||||
} from "./permissions";
|
||||
export { truncateSync, truncate } from "./truncate";
|
||||
export { FileInfo } from "./file_info";
|
||||
export { connect, dial, listen, Listener, Conn } from "./net";
|
||||
export { metrics, Metrics } from "./metrics";
|
||||
export { resources } from "./resources";
|
||||
} from "./permissions.ts";
|
||||
export { truncateSync, truncate } from "./truncate.ts";
|
||||
export { FileInfo } from "./file_info.ts";
|
||||
export { connect, dial, listen, Listener, Conn } from "./net.ts";
|
||||
export { metrics, Metrics } from "./metrics.ts";
|
||||
export { resources } from "./resources.ts";
|
||||
export {
|
||||
kill,
|
||||
run,
|
||||
|
@ -78,23 +84,35 @@ export {
|
|||
Process,
|
||||
ProcessStatus,
|
||||
Signal
|
||||
} from "./process";
|
||||
export { inspect, customInspect } from "./console";
|
||||
export { build, platform, OperatingSystem, Arch } from "./build";
|
||||
export { version } from "./version";
|
||||
} from "./process.ts";
|
||||
export { inspect, customInspect } from "./console.ts";
|
||||
export { build, platform, OperatingSystem, Arch } from "./build.ts";
|
||||
export { version } from "./version.ts";
|
||||
export const args: string[] = [];
|
||||
|
||||
// These are internal Deno APIs. We are marking them as internal so they do not
|
||||
// appear in the runtime type library.
|
||||
/** @internal */
|
||||
export { core } from "./core";
|
||||
export { core } from "./core.ts";
|
||||
|
||||
/** @internal */
|
||||
export { setPrepareStackTrace } from "./error_stack";
|
||||
export { setPrepareStackTrace } from "./error_stack.ts";
|
||||
|
||||
// TODO Don't expose Console nor stringifyArgs.
|
||||
/** @internal */
|
||||
export { Console, stringifyArgs } from "./console";
|
||||
export { Console, stringifyArgs } from "./console.ts";
|
||||
// TODO Don't expose DomIterableMixin.
|
||||
/** @internal */
|
||||
export { DomIterableMixin } from "./mixins/dom_iterable";
|
||||
export { DomIterableMixin } from "./mixins/dom_iterable.ts";
|
||||
|
||||
/** The current process id of the runtime. */
|
||||
export let pid: number;
|
||||
|
||||
/** Reflects the NO_COLOR environment variable: https://no-color.org/ */
|
||||
export let noColor: boolean;
|
||||
|
||||
// TODO(ry) This should not be exposed to Deno.
|
||||
export function _setGlobals(pid_: number, noColor_: boolean): void {
|
||||
pid = pid_;
|
||||
noColor = noColor_;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
// compiler, which is strongly influenced by the format of TypeScript
|
||||
// diagnostics.
|
||||
|
||||
import * as ts from "typescript";
|
||||
/// <reference types="../third_party/node_modules/typescript/lib/typescript.d.ts"/>
|
||||
|
||||
/** The log category for a diagnostic message */
|
||||
export enum DiagnosticCategory {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import { sendSync } from "./dispatch_json";
|
||||
import * as dispatch from "./dispatch";
|
||||
import { sendSync } from "./dispatch_json.ts";
|
||||
import * as dispatch from "./dispatch.ts";
|
||||
|
||||
/**
|
||||
* `cwd()` Return a string representing the current working directory.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import * as minimal from "./dispatch_minimal";
|
||||
import * as json from "./dispatch_json";
|
||||
import * as minimal from "./dispatch_minimal.ts";
|
||||
import * as json from "./dispatch_json.ts";
|
||||
|
||||
// These consts are shared with Rust. Update with care.
|
||||
export const OP_READ = 1;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import * as util from "./util";
|
||||
import { TextEncoder, TextDecoder } from "./text_encoding";
|
||||
import { core } from "./core";
|
||||
import { ErrorKind, DenoError } from "./errors";
|
||||
import * as util from "./util.ts";
|
||||
import { TextEncoder, TextDecoder } from "./text_encoding.ts";
|
||||
import { core } from "./core.ts";
|
||||
import { ErrorKind, DenoError } from "./errors.ts";
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
type Ok = any;
|
||||
|
|
|
@ -2,9 +2,9 @@ import { testPerm, assertMatch, unreachable } from "./test_util.ts";
|
|||
|
||||
const openErrorStackPattern = new RegExp(
|
||||
`^.*
|
||||
at unwrapResponse \\(js\\/dispatch_json\\.ts:.*\\)
|
||||
at sendAsync.* \\(js\\/dispatch_json\\.ts:.*\\)
|
||||
at async Object\\.open \\(js\\/files\\.ts:.*\\).*$`,
|
||||
at unwrapResponse \\(.*dispatch_json\\.ts:.*\\)
|
||||
at Object.sendAsync \\(.*dispatch_json\\.ts:.*\\)
|
||||
at async Object\\.open \\(.*files\\.ts:.*\\).*$`,
|
||||
"ms"
|
||||
);
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import * as util from "./util";
|
||||
import { core } from "./core";
|
||||
import * as util from "./util.ts";
|
||||
import { core } from "./core.ts";
|
||||
|
||||
const promiseTableMin = new Map<number, util.Resolvable<number>>();
|
||||
// Note it's important that promiseId starts at 1 instead of 0, because sync
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import * as domTypes from "./dom_types";
|
||||
import * as blob from "./blob";
|
||||
import * as domTypes from "./dom_types.ts";
|
||||
import * as blob from "./blob.ts";
|
||||
|
||||
// TODO Rename this to DomFileImpl
|
||||
export class DenoFile extends blob.DenoBlob implements domTypes.DomFile {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
// Utility functions for DOM nodes
|
||||
import * as domTypes from "./dom_types";
|
||||
import * as domTypes from "./dom_types.ts";
|
||||
|
||||
export function isNode(nodeImpl: domTypes.EventTarget | null): boolean {
|
||||
return Boolean(nodeImpl && "nodeType" in nodeImpl);
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
// Some of the code here is adapted directly from V8 and licensed under a BSD
|
||||
// style license available here: https://github.com/v8/v8/blob/24886f2d1c565287d33d71e4109a53bf0b54b75c/LICENSE.v8
|
||||
import * as dispatch from "./dispatch";
|
||||
import { sendSync } from "./dispatch_json";
|
||||
import { assert } from "./util";
|
||||
import * as dispatch from "./dispatch.ts";
|
||||
import { sendSync } from "./dispatch_json.ts";
|
||||
import { assert } from "./util.ts";
|
||||
|
||||
export interface Location {
|
||||
/** The full url for the module, e.g. `file://some/file.ts` or
|
||||
|
|
|
@ -90,22 +90,19 @@ test(function prepareStackTrace(): void {
|
|||
structuredStackTrace: CallSite[]
|
||||
) => string = MockError.prepareStackTrace;
|
||||
const result = prepareStackTrace(new Error("foo"), [
|
||||
getMockCallSite("gen/cli/bundle/main.js", 23, 0)
|
||||
getMockCallSite("CLI_SNAPSHOT.js", 23, 0)
|
||||
]);
|
||||
assert(result.startsWith("Error: foo\n"));
|
||||
assert(
|
||||
result.includes("<anonymous> (js/"),
|
||||
"should remap to something in 'js/'"
|
||||
);
|
||||
assert(result.includes(".ts:"), "should remap to something in 'js/'");
|
||||
});
|
||||
|
||||
test(function applySourceMap(): void {
|
||||
const result = Deno.applySourceMap({
|
||||
filename: "gen/cli/bundle/main.js",
|
||||
filename: "CLI_SNAPSHOT.js",
|
||||
line: 23,
|
||||
column: 0
|
||||
});
|
||||
assert(result.filename.startsWith("js/"));
|
||||
assert(result.filename.endsWith(".ts"));
|
||||
assert(result.line != null);
|
||||
assert(result.column != null);
|
||||
});
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import * as domTypes from "./dom_types";
|
||||
import { getPrivateValue, requiredArguments } from "./util";
|
||||
import * as domTypes from "./dom_types.ts";
|
||||
import { getPrivateValue, requiredArguments } from "./util.ts";
|
||||
|
||||
// WeakMaps are recommended for private attributes (see MDN link below)
|
||||
// https://developer.mozilla.org/en-US/docs/Archive/Add-ons/Add-on_SDK/Guides/Contributor_s_Guide/Private_Properties#Using_WeakMaps
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import * as domTypes from "./dom_types";
|
||||
import { DenoError, ErrorKind } from "./errors";
|
||||
import { hasOwnProperty, requiredArguments } from "./util";
|
||||
import * as domTypes from "./dom_types.ts";
|
||||
import { DenoError, ErrorKind } from "./errors.ts";
|
||||
import { hasOwnProperty, requiredArguments } from "./util.ts";
|
||||
import {
|
||||
getRoot,
|
||||
isNode,
|
||||
|
@ -9,7 +9,7 @@ import {
|
|||
isShadowInclusiveAncestor,
|
||||
isSlotable,
|
||||
retarget
|
||||
} from "./dom_util";
|
||||
} from "./dom_util.ts";
|
||||
|
||||
// https://dom.spec.whatwg.org/#get-the-parent
|
||||
// Note: Nodes, shadow roots, and documents override this algorithm so we set it to null.
|
||||
|
|
29
js/fetch.ts
29
js/fetch.ts
|
@ -1,16 +1,21 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import { assert, createResolvable, notImplemented, isTypedArray } from "./util";
|
||||
import * as domTypes from "./dom_types";
|
||||
import { TextDecoder, TextEncoder } from "./text_encoding";
|
||||
import { DenoBlob, bytesSymbol as blobBytesSymbol } from "./blob";
|
||||
import { Headers } from "./headers";
|
||||
import * as io from "./io";
|
||||
import { read, close } from "./files";
|
||||
import { Buffer } from "./buffer";
|
||||
import { FormData } from "./form_data";
|
||||
import { URLSearchParams } from "./url_search_params";
|
||||
import * as dispatch from "./dispatch";
|
||||
import { sendAsync } from "./dispatch_json";
|
||||
import {
|
||||
assert,
|
||||
createResolvable,
|
||||
notImplemented,
|
||||
isTypedArray
|
||||
} from "./util.ts";
|
||||
import * as domTypes from "./dom_types.ts";
|
||||
import { TextDecoder, TextEncoder } from "./text_encoding.ts";
|
||||
import { DenoBlob, bytesSymbol as blobBytesSymbol } from "./blob.ts";
|
||||
import { Headers } from "./headers.ts";
|
||||
import * as io from "./io.ts";
|
||||
import { read, close } from "./files.ts";
|
||||
import { Buffer } from "./buffer.ts";
|
||||
import { FormData } from "./form_data.ts";
|
||||
import { URLSearchParams } from "./url_search_params.ts";
|
||||
import * as dispatch from "./dispatch.ts";
|
||||
import { sendAsync } from "./dispatch_json.ts";
|
||||
|
||||
function getHeaderValueParams(value: string): Map<string, string> {
|
||||
const params = new Map();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import { StatResponse } from "./stat";
|
||||
import { StatResponse } from "./stat.ts";
|
||||
|
||||
/** A FileInfo describes a file and is returned by `stat`, `lstat`,
|
||||
* `statSync`, `lstatSync`.
|
||||
|
|
|
@ -9,13 +9,13 @@ import {
|
|||
SyncReader,
|
||||
SyncWriter,
|
||||
SyncSeeker
|
||||
} from "./io";
|
||||
import { sendAsyncMinimal, sendSyncMinimal } from "./dispatch_minimal";
|
||||
import * as dispatch from "./dispatch";
|
||||
} from "./io.ts";
|
||||
import { sendAsyncMinimal, sendSyncMinimal } from "./dispatch_minimal.ts";
|
||||
import * as dispatch from "./dispatch.ts";
|
||||
import {
|
||||
sendSync as sendSyncJson,
|
||||
sendAsync as sendAsyncJson
|
||||
} from "./dispatch_json";
|
||||
} from "./dispatch_json.ts";
|
||||
|
||||
/** Open a file and return an instance of the `File` object
|
||||
* synchronously.
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import * as domTypes from "./dom_types";
|
||||
import * as blob from "./blob";
|
||||
import * as domFile from "./dom_file";
|
||||
import { DomIterableMixin } from "./mixins/dom_iterable";
|
||||
import { requiredArguments } from "./util";
|
||||
import * as domTypes from "./dom_types.ts";
|
||||
import * as blob from "./blob.ts";
|
||||
import * as domFile from "./dom_file.ts";
|
||||
import { DomIterableMixin } from "./mixins/dom_iterable.ts";
|
||||
import { requiredArguments } from "./util.ts";
|
||||
|
||||
const dataSymbol = Symbol("data");
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import * as dispatch from "./dispatch";
|
||||
import { sendSync } from "./dispatch_json";
|
||||
import * as dispatch from "./dispatch.ts";
|
||||
import { sendSync } from "./dispatch_json.ts";
|
||||
|
||||
// TODO(bartlomieju): move to `repl.ts`?
|
||||
export function formatError(errString: string): string {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import * as dispatch from "./dispatch";
|
||||
import { sendSync } from "./dispatch_json";
|
||||
import { assert } from "./util";
|
||||
import * as dispatch from "./dispatch.ts";
|
||||
import { sendSync } from "./dispatch_json.ts";
|
||||
import { assert } from "./util.ts";
|
||||
|
||||
/** Synchronously collects cryptographically secure random values. The
|
||||
* underlying CSPRNG in use is Rust's `rand::rngs::ThreadRng`.
|
||||
|
|
|
@ -7,31 +7,31 @@
|
|||
// Modules which will make up part of the global public API surface should be
|
||||
// imported as namespaces, so when the runtime type library is generated they
|
||||
// can be expressed as a namespace in the type library.
|
||||
import { window } from "./window";
|
||||
import * as blob from "./blob";
|
||||
import * as consoleTypes from "./console";
|
||||
import * as csprng from "./get_random_values";
|
||||
import * as customEvent from "./custom_event";
|
||||
import * as Deno from "./deno";
|
||||
import * as domTypes from "./dom_types";
|
||||
import * as domFile from "./dom_file";
|
||||
import * as event from "./event";
|
||||
import * as eventTarget from "./event_target";
|
||||
import * as formData from "./form_data";
|
||||
import * as fetchTypes from "./fetch";
|
||||
import * as headers from "./headers";
|
||||
import * as textEncoding from "./text_encoding";
|
||||
import * as timers from "./timers";
|
||||
import * as url from "./url";
|
||||
import * as urlSearchParams from "./url_search_params";
|
||||
import * as workers from "./workers";
|
||||
import * as performanceUtil from "./performance";
|
||||
import { window } from "./window.ts";
|
||||
import * as blob from "./blob.ts";
|
||||
import * as consoleTypes from "./console.ts";
|
||||
import * as csprng from "./get_random_values.ts";
|
||||
import * as customEvent from "./custom_event.ts";
|
||||
import * as Deno from "./deno.ts";
|
||||
import * as domTypes from "./dom_types.ts";
|
||||
import * as domFile from "./dom_file.ts";
|
||||
import * as event from "./event.ts";
|
||||
import * as eventTarget from "./event_target.ts";
|
||||
import * as formData from "./form_data.ts";
|
||||
import * as fetchTypes from "./fetch.ts";
|
||||
import * as headers from "./headers.ts";
|
||||
import * as textEncoding from "./text_encoding.ts";
|
||||
import * as timers from "./timers.ts";
|
||||
import * as url from "./url.ts";
|
||||
import * as urlSearchParams from "./url_search_params.ts";
|
||||
import * as workers from "./workers.ts";
|
||||
import * as performanceUtil from "./performance.ts";
|
||||
|
||||
import * as request from "./request";
|
||||
import * as request from "./request.ts";
|
||||
|
||||
// These imports are not exposed and therefore are fine to just import the
|
||||
// symbols required.
|
||||
import { core } from "./core";
|
||||
import { core } from "./core.ts";
|
||||
|
||||
// During the build process, augmentations to the variable `window` in this
|
||||
// file are tracked and created as part of default library that is built into
|
||||
|
@ -72,7 +72,6 @@ window.window = window;
|
|||
// properties when building the runtime type library, as the whole module
|
||||
// is flattened into a single namespace.
|
||||
window.Deno = Deno;
|
||||
Object.freeze(window.Deno);
|
||||
|
||||
// Globally available functions and object instances.
|
||||
window.atob = textEncoding.atob;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import * as domTypes from "./dom_types";
|
||||
import { DomIterableMixin } from "./mixins/dom_iterable";
|
||||
import { requiredArguments } from "./util";
|
||||
import * as domTypes from "./dom_types.ts";
|
||||
import { DomIterableMixin } from "./mixins/dom_iterable.ts";
|
||||
import { requiredArguments } from "./util.ts";
|
||||
|
||||
// From node-fetch
|
||||
// Copyright (c) 2016 David Frank. MIT License.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import { sendSync, sendAsync } from "./dispatch_json";
|
||||
import * as dispatch from "./dispatch";
|
||||
import { sendSync, sendAsync } from "./dispatch_json.ts";
|
||||
import * as dispatch from "./dispatch.ts";
|
||||
|
||||
/** Synchronously creates `newname` as a hard link to `oldname`.
|
||||
*
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import { URL } from "./url";
|
||||
import { notImplemented } from "./util";
|
||||
import { Location } from "./dom_types";
|
||||
import { window } from "./window";
|
||||
import { URL } from "./url.ts";
|
||||
import { notImplemented } from "./util.ts";
|
||||
import { Location } from "./dom_types.ts";
|
||||
import { window } from "./window.ts";
|
||||
|
||||
export class LocationImpl implements Location {
|
||||
constructor(url: string) {
|
||||
|
|
40
js/main.ts
40
js/main.ts
|
@ -1,36 +1,29 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-triple-slash-reference
|
||||
/// <reference path="./plugins.d.ts" />
|
||||
import "./globals.ts";
|
||||
|
||||
import "./globals";
|
||||
import { assert, log } from "./util.ts";
|
||||
import * as os from "./os.ts";
|
||||
import { args } from "./deno.ts";
|
||||
import { setPrepareStackTrace } from "./error_stack.ts";
|
||||
import { replLoop } from "./repl.ts";
|
||||
import { xevalMain, XevalFunc } from "./xeval.ts";
|
||||
import { setVersions } from "./version.ts";
|
||||
import { window } from "./window.ts";
|
||||
import { setLocation } from "./location.ts";
|
||||
import * as Deno from "./deno.ts";
|
||||
|
||||
import { assert, log } from "./util";
|
||||
import * as os from "./os";
|
||||
import { args } from "./deno";
|
||||
import { setPrepareStackTrace } from "./error_stack";
|
||||
import { replLoop } from "./repl";
|
||||
import { xevalMain, XevalFunc } from "./xeval";
|
||||
import { setVersions } from "./version";
|
||||
import { window } from "./window";
|
||||
import { setLocation } from "./location";
|
||||
|
||||
// builtin modules
|
||||
import * as deno from "./deno";
|
||||
|
||||
export default function denoMain(
|
||||
preserveDenoNamespace: boolean = true,
|
||||
name?: string
|
||||
): void {
|
||||
function denoMain(preserveDenoNamespace: boolean = true, name?: string): void {
|
||||
const s = os.start(preserveDenoNamespace, name);
|
||||
|
||||
setVersions(s.denoVersion, s.v8Version);
|
||||
|
||||
// handle `--version`
|
||||
if (s.versionFlag) {
|
||||
console.log("deno:", deno.version.deno);
|
||||
console.log("v8:", deno.version.v8);
|
||||
console.log("typescript:", deno.version.typescript);
|
||||
const { console } = window;
|
||||
console.log("deno:", Deno.version.deno);
|
||||
console.log("v8:", Deno.version.v8);
|
||||
console.log("typescript:", Deno.version.typescript);
|
||||
os.exit(0);
|
||||
}
|
||||
|
||||
|
@ -55,3 +48,4 @@ export default function denoMain(
|
|||
replLoop();
|
||||
}
|
||||
}
|
||||
window["denoMain"] = denoMain;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import { sendSync, sendAsync } from "./dispatch_json";
|
||||
import * as dispatch from "./dispatch";
|
||||
import { sendSync, sendAsync } from "./dispatch_json.ts";
|
||||
import * as dispatch from "./dispatch.ts";
|
||||
|
||||
export interface MakeTempDirOptions {
|
||||
dir?: string;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import * as dispatch from "./dispatch";
|
||||
import { sendSync } from "./dispatch_json";
|
||||
import * as dispatch from "./dispatch.ts";
|
||||
import { sendSync } from "./dispatch_json.ts";
|
||||
|
||||
export interface Metrics {
|
||||
opsDispatched: number;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
import { DomIterable } from "../dom_types";
|
||||
import { window } from "../window";
|
||||
import { requiredArguments } from "../util";
|
||||
import { DomIterable } from "../dom_types.ts";
|
||||
import { window } from "../window.ts";
|
||||
import { requiredArguments } from "../util.ts";
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
type Constructor<T = {}> = new (...args: any[]) => T;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import { sendSync, sendAsync } from "./dispatch_json";
|
||||
import * as dispatch from "./dispatch";
|
||||
import { sendSync, sendAsync } from "./dispatch_json.ts";
|
||||
import * as dispatch from "./dispatch.ts";
|
||||
|
||||
/** Creates a new directory with the specified path synchronously.
|
||||
* If `recursive` is set to true, nested directories will be created (also known
|
||||
|
|
10
js/net.ts
10
js/net.ts
|
@ -1,9 +1,9 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import { EOF, Reader, Writer, Closer } from "./io";
|
||||
import { notImplemented } from "./util";
|
||||
import { read, write, close } from "./files";
|
||||
import * as dispatch from "./dispatch";
|
||||
import { sendSync, sendAsync } from "./dispatch_json";
|
||||
import { EOF, Reader, Writer, Closer } from "./io.ts";
|
||||
import { notImplemented } from "./util.ts";
|
||||
import { read, write, close } from "./files.ts";
|
||||
import * as dispatch from "./dispatch.ts";
|
||||
import { sendSync, sendAsync } from "./dispatch_json.ts";
|
||||
|
||||
export type Network = "tcp";
|
||||
// TODO support other types:
|
||||
|
|
31
js/os.ts
31
js/os.ts
|
@ -1,22 +1,13 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import { core } from "./core";
|
||||
import * as dispatch from "./dispatch";
|
||||
import { sendSync } from "./dispatch_json";
|
||||
import { assert } from "./util";
|
||||
import * as util from "./util";
|
||||
import { window } from "./window";
|
||||
import { core } from "./core.ts";
|
||||
import * as dispatch from "./dispatch.ts";
|
||||
import { sendSync } from "./dispatch_json.ts";
|
||||
import { assert } from "./util.ts";
|
||||
import * as util from "./util.ts";
|
||||
import { window } from "./window.ts";
|
||||
|
||||
/** The current process id of the runtime. */
|
||||
export let pid: number;
|
||||
|
||||
/** Reflects the NO_COLOR environment variable: https://no-color.org/ */
|
||||
export let noColor: boolean;
|
||||
|
||||
function setGlobals(pid_: number, noColor_: boolean): void {
|
||||
assert(!pid);
|
||||
pid = pid_;
|
||||
noColor = noColor_;
|
||||
}
|
||||
// builtin modules
|
||||
import { _setGlobals } from "./deno.ts";
|
||||
|
||||
/** Check if running in terminal.
|
||||
*
|
||||
|
@ -85,7 +76,11 @@ export function start(preserveDenoNamespace = true, source?: string): Start {
|
|||
|
||||
util.setLogDebug(s.debugFlag, source);
|
||||
|
||||
setGlobals(s.pid, s.noColor);
|
||||
// pid and noColor need to be set in the Deno module before it's set to be
|
||||
// frozen.
|
||||
_setGlobals(s.pid, s.noColor);
|
||||
delete window.Deno._setGlobals;
|
||||
Object.freeze(window.Deno);
|
||||
|
||||
if (preserveDenoNamespace) {
|
||||
util.immutableDefine(window, "Deno", window.Deno);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import * as dispatch from "./dispatch";
|
||||
import { sendSync } from "./dispatch_json";
|
||||
import * as dispatch from "./dispatch.ts";
|
||||
import { sendSync } from "./dispatch_json.ts";
|
||||
|
||||
interface NowResponse {
|
||||
seconds: number;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import * as dispatch from "./dispatch";
|
||||
import { sendSync } from "./dispatch_json";
|
||||
import * as dispatch from "./dispatch.ts";
|
||||
import { sendSync } from "./dispatch_json.ts";
|
||||
|
||||
/** Permissions as granted by the caller */
|
||||
export interface Permissions {
|
||||
|
|
9
js/plugins.d.ts
vendored
9
js/plugins.d.ts
vendored
|
@ -1,9 +0,0 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
// This allows TypeScript to resolve any modules that end with `!string`
|
||||
// as there is a rollup plugin that will take any mids ending with `!string`
|
||||
// and return them as a string to rollup for inlining
|
||||
declare module "*!string" {
|
||||
const value: string;
|
||||
export default value;
|
||||
}
|
|
@ -1,11 +1,11 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import { sendSync, sendAsync } from "./dispatch_json";
|
||||
import * as dispatch from "./dispatch";
|
||||
import { File, close } from "./files";
|
||||
import { ReadCloser, WriteCloser } from "./io";
|
||||
import { readAll } from "./buffer";
|
||||
import { assert, unreachable } from "./util";
|
||||
import { platform } from "./build";
|
||||
import { sendSync, sendAsync } from "./dispatch_json.ts";
|
||||
import * as dispatch from "./dispatch.ts";
|
||||
import { File, close } from "./files.ts";
|
||||
import { ReadCloser, WriteCloser } from "./io.ts";
|
||||
import { readAll } from "./buffer.ts";
|
||||
import { assert, unreachable } from "./util.ts";
|
||||
import { platform } from "./build.ts";
|
||||
|
||||
/** How to handle subprocess stdio.
|
||||
*
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import { sendSync, sendAsync } from "./dispatch_json";
|
||||
import * as dispatch from "./dispatch";
|
||||
import { FileInfo, FileInfoImpl } from "./file_info";
|
||||
import { StatResponse } from "./stat";
|
||||
import { sendSync, sendAsync } from "./dispatch_json.ts";
|
||||
import * as dispatch from "./dispatch.ts";
|
||||
import { FileInfo, FileInfoImpl } from "./file_info.ts";
|
||||
import { StatResponse } from "./stat.ts";
|
||||
|
||||
interface ReadDirResponse {
|
||||
entries: StatResponse[];
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import { open, openSync } from "./files";
|
||||
import { readAll, readAllSync } from "./buffer";
|
||||
import { open, openSync } from "./files.ts";
|
||||
import { readAll, readAllSync } from "./buffer.ts";
|
||||
|
||||
/** Read the entire contents of a file synchronously.
|
||||
*
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import { sendSync, sendAsync } from "./dispatch_json";
|
||||
import * as dispatch from "./dispatch";
|
||||
import { sendSync, sendAsync } from "./dispatch_json.ts";
|
||||
import * as dispatch from "./dispatch.ts";
|
||||
|
||||
/** Returns the destination of the named symbolic link synchronously.
|
||||
*
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import { sendSync, sendAsync } from "./dispatch_json";
|
||||
import * as dispatch from "./dispatch";
|
||||
import { sendSync, sendAsync } from "./dispatch_json.ts";
|
||||
import * as dispatch from "./dispatch.ts";
|
||||
|
||||
export interface RemoveOption {
|
||||
recursive?: boolean;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import { sendSync, sendAsync } from "./dispatch_json";
|
||||
import * as dispatch from "./dispatch";
|
||||
import { sendSync, sendAsync } from "./dispatch_json.ts";
|
||||
import * as dispatch from "./dispatch.ts";
|
||||
|
||||
/** Synchronously renames (moves) `oldpath` to `newpath`. If `newpath` already
|
||||
* exists and is not a directory, `renameSync()` replaces it. OS-specific
|
||||
|
|
18
js/repl.ts
18
js/repl.ts
|
@ -1,12 +1,14 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import { close } from "./files";
|
||||
import { exit } from "./os";
|
||||
import { window } from "./window";
|
||||
import { core } from "./core";
|
||||
import { formatError } from "./format_error";
|
||||
import { stringifyArgs } from "./console";
|
||||
import * as dispatch from "./dispatch";
|
||||
import { sendSync, sendAsync } from "./dispatch_json";
|
||||
import { close } from "./files.ts";
|
||||
import { exit } from "./os.ts";
|
||||
import { window } from "./window.ts";
|
||||
import { core } from "./core.ts";
|
||||
import { formatError } from "./format_error.ts";
|
||||
import { stringifyArgs } from "./console.ts";
|
||||
import * as dispatch from "./dispatch.ts";
|
||||
import { sendSync, sendAsync } from "./dispatch_json.ts";
|
||||
|
||||
const { console } = window;
|
||||
|
||||
/**
|
||||
* REPL logging.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import * as headers from "./headers";
|
||||
import * as body from "./body";
|
||||
import * as domTypes from "./dom_types";
|
||||
import * as headers from "./headers.ts";
|
||||
import * as body from "./body.ts";
|
||||
import * as domTypes from "./dom_types.ts";
|
||||
|
||||
const { Headers } = headers;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import * as dispatch from "./dispatch";
|
||||
import { sendSync } from "./dispatch_json";
|
||||
import * as dispatch from "./dispatch.ts";
|
||||
import { sendSync } from "./dispatch_json.ts";
|
||||
|
||||
export interface ResourceMap {
|
||||
[rid: number]: string;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import { sendSync, sendAsync } from "./dispatch_json";
|
||||
import * as dispatch from "./dispatch";
|
||||
import { FileInfo, FileInfoImpl } from "./file_info";
|
||||
import { sendSync, sendAsync } from "./dispatch_json.ts";
|
||||
import * as dispatch from "./dispatch.ts";
|
||||
import { FileInfo, FileInfoImpl } from "./file_info.ts";
|
||||
|
||||
export interface StatResponse {
|
||||
isFile: boolean;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import { sendSync, sendAsync } from "./dispatch_json";
|
||||
import * as dispatch from "./dispatch";
|
||||
import * as util from "./util";
|
||||
import { platform } from "./build";
|
||||
import { sendSync, sendAsync } from "./dispatch_json.ts";
|
||||
import * as dispatch from "./dispatch.ts";
|
||||
import * as util from "./util.ts";
|
||||
import { platform } from "./build.ts";
|
||||
|
||||
/** Synchronously creates `newname` as a symbolic link to `oldname`. The type
|
||||
* argument can be set to `dir` or `file` and is only available on Windows
|
||||
|
|
|
@ -23,9 +23,9 @@
|
|||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
// OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
import * as base64 from "./base64";
|
||||
import * as domTypes from "./dom_types";
|
||||
import { DenoError, ErrorKind } from "./errors";
|
||||
import * as base64 from "./base64.ts";
|
||||
import * as domTypes from "./dom_types.ts";
|
||||
import { DenoError, ErrorKind } from "./errors.ts";
|
||||
|
||||
const CONTINUE = null;
|
||||
const END_OF_STREAM = -1;
|
||||
|
|
10
js/timers.ts
10
js/timers.ts
|
@ -1,8 +1,10 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import { assert } from "./util";
|
||||
import { window } from "./window";
|
||||
import * as dispatch from "./dispatch";
|
||||
import { sendSync, sendAsync } from "./dispatch_json";
|
||||
import { assert } from "./util.ts";
|
||||
import { window } from "./window.ts";
|
||||
import * as dispatch from "./dispatch.ts";
|
||||
import { sendSync, sendAsync } from "./dispatch_json.ts";
|
||||
|
||||
const { console } = window;
|
||||
|
||||
interface Timer {
|
||||
id: number;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import { sendSync, sendAsync } from "./dispatch_json";
|
||||
import * as dispatch from "./dispatch";
|
||||
import { sendSync, sendAsync } from "./dispatch_json.ts";
|
||||
import * as dispatch from "./dispatch.ts";
|
||||
|
||||
function coerceLen(len?: number): number {
|
||||
if (!len) {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import * as urlSearchParams from "./url_search_params";
|
||||
import * as domTypes from "./dom_types";
|
||||
import { getRandomValues } from "./get_random_values";
|
||||
import { window } from "./window";
|
||||
import * as urlSearchParams from "./url_search_params.ts";
|
||||
import * as domTypes from "./dom_types.ts";
|
||||
import { getRandomValues } from "./get_random_values.ts";
|
||||
import { window } from "./window.ts";
|
||||
|
||||
interface URLParts {
|
||||
protocol: string;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import { URL } from "./url";
|
||||
import { requiredArguments, isIterable } from "./util";
|
||||
import { URL } from "./url.ts";
|
||||
import { requiredArguments, isIterable } from "./util.ts";
|
||||
|
||||
export class URLSearchParams {
|
||||
private params: Array<[string, string]> = [];
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import { TypedArray } from "./types";
|
||||
import { TypedArray } from "./types.ts";
|
||||
import { window } from "./window.ts";
|
||||
const { console } = window;
|
||||
|
||||
let logDebug = false;
|
||||
let logSource = "JS";
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import { sendSync, sendAsync } from "./dispatch_json";
|
||||
import { OP_UTIME } from "./dispatch";
|
||||
import { sendSync, sendAsync } from "./dispatch_json.ts";
|
||||
import { OP_UTIME } from "./dispatch.ts";
|
||||
|
||||
function toSecondsFromEpoch(v: number | Date): number {
|
||||
return v instanceof Date ? v.valueOf() / 1000 : v;
|
||||
|
|
|
@ -9,7 +9,7 @@ export const version: Version = {
|
|||
deno: "",
|
||||
v8: "",
|
||||
// This string will be replaced by rollup
|
||||
typescript: `ROLLUP_REPLACE_TS_VERSION`
|
||||
typescript: `DENO_REPLACE_TS_VERSION`
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import * as dispatch from "./dispatch";
|
||||
import { sendAsync, sendSync } from "./dispatch_json";
|
||||
import { log } from "./util";
|
||||
import { TextDecoder, TextEncoder } from "./text_encoding";
|
||||
import { window } from "./window";
|
||||
import { blobURLMap } from "./url";
|
||||
import { blobBytesWeakMap } from "./blob";
|
||||
import * as dispatch from "./dispatch.ts";
|
||||
import { sendAsync, sendSync } from "./dispatch_json.ts";
|
||||
import { log } from "./util.ts";
|
||||
import { TextDecoder, TextEncoder } from "./text_encoding.ts";
|
||||
import { window } from "./window.ts";
|
||||
import { blobURLMap } from "./url.ts";
|
||||
import { blobBytesWeakMap } from "./blob.ts";
|
||||
|
||||
const encoder = new TextEncoder();
|
||||
const decoder = new TextDecoder();
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
import { stat, statSync } from "./stat";
|
||||
import { open, openSync } from "./files";
|
||||
import { chmod, chmodSync } from "./chmod";
|
||||
import { writeAll, writeAllSync } from "./buffer";
|
||||
import { stat, statSync } from "./stat.ts";
|
||||
import { open, openSync } from "./files.ts";
|
||||
import { chmod, chmodSync } from "./chmod.ts";
|
||||
import { writeAll, writeAllSync } from "./buffer.ts";
|
||||
|
||||
/** Options for writing to a file.
|
||||
* `perm` would change the file's permission if set.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { Buffer, writeAll } from "./buffer";
|
||||
import { stdin } from "./files";
|
||||
import { TextEncoder, TextDecoder } from "./text_encoding";
|
||||
import { Reader, EOF } from "./io";
|
||||
import { Buffer, writeAll } from "./buffer.ts";
|
||||
import { stdin } from "./files.ts";
|
||||
import { TextEncoder, TextDecoder } from "./text_encoding.ts";
|
||||
import { Reader, EOF } from "./io.ts";
|
||||
|
||||
export type XevalFunc = (v: string) => void;
|
||||
|
||||
|
|
12
package.json
12
package.json
|
@ -8,18 +8,6 @@
|
|||
"eslint-config-prettier": "4.1.0",
|
||||
"magic-string": "0.25.2",
|
||||
"prettier": "1.17.1",
|
||||
"rollup": "1.4.1",
|
||||
"rollup-plugin-alias": "1.5.1",
|
||||
"rollup-plugin-analyzer": "3.0.0",
|
||||
"rollup-plugin-commonjs": "9.1.3",
|
||||
"rollup-plugin-node-globals": "1.4.0",
|
||||
"rollup-plugin-node-resolve": "4.0.1",
|
||||
"rollup-plugin-replace": "2.1.0",
|
||||
"rollup-plugin-string": "3.0.0",
|
||||
"rollup-plugin-typescript2": "0.19.3",
|
||||
"rollup-pluginutils": "2.4.1",
|
||||
"ts-morph": "1.3.0",
|
||||
"ts-node": "8.0.2",
|
||||
"typescript": "3.5.1"
|
||||
}
|
||||
}
|
||||
|
|
231
rollup.config.js
231
rollup.config.js
|
@ -1,231 +0,0 @@
|
|||
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
||||
// @ts-check
|
||||
import * as fs from "fs";
|
||||
import path from "path";
|
||||
import alias from "rollup-plugin-alias";
|
||||
import { plugin as analyze } from "rollup-plugin-analyzer";
|
||||
import commonjs from "rollup-plugin-commonjs";
|
||||
import globals from "rollup-plugin-node-globals";
|
||||
import nodeResolve from "rollup-plugin-node-resolve";
|
||||
import typescriptPlugin from "rollup-plugin-typescript2";
|
||||
import { createFilter } from "rollup-pluginutils";
|
||||
import replace from "rollup-plugin-replace";
|
||||
import typescript from "typescript";
|
||||
|
||||
const mockPath = path.resolve(__dirname, "js/mock_builtin.js");
|
||||
const tsconfig = path.resolve(__dirname, "tsconfig.json");
|
||||
const typescriptPath = path.resolve(
|
||||
__dirname,
|
||||
"third_party/node_modules/typescript/lib/typescript.js"
|
||||
);
|
||||
|
||||
// We will allow generated modules to be resolvable by TypeScript based on
|
||||
// the current build path
|
||||
const tsconfigOverride = {
|
||||
compilerOptions: {
|
||||
paths: {
|
||||
"*": ["*", path.resolve("*")]
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const archNodeToDeno = {
|
||||
x64: "x64"
|
||||
};
|
||||
const osNodeToDeno = {
|
||||
win32: "win",
|
||||
darwin: "mac",
|
||||
linux: "linux"
|
||||
};
|
||||
|
||||
function generateDepFile({ outputFile, sourceFiles = [], configFiles = [] }) {
|
||||
let timestamp = new Date();
|
||||
|
||||
// Save the depfile just before the node process exits.
|
||||
process.once("beforeExit", () =>
|
||||
writeDepFile({ outputFile, sourceFiles, configFiles, timestamp })
|
||||
);
|
||||
|
||||
return {
|
||||
name: "depfile",
|
||||
load(sourceFile) {
|
||||
// The 'globals' plugin adds generated files that don't exist on disk.
|
||||
// Don't add them to the depfile.
|
||||
if (/^[0-9a-f]{30}$/.test(sourceFile)) {
|
||||
return;
|
||||
}
|
||||
sourceFiles.push(sourceFile);
|
||||
// Remember the time stamp that we last resolved a dependency.
|
||||
// We'll set the last modified time of the depfile to that.
|
||||
timestamp = new Date();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function writeDepFile({ outputFile, sourceFiles, configFiles, timestamp }) {
|
||||
const buildDir = process.cwd();
|
||||
const outputDir = path.dirname(outputFile);
|
||||
|
||||
// Assert that the discovered bundle inputs are files that exist on disk.
|
||||
sourceFiles.forEach(f => fs.accessSync(f));
|
||||
// Since we also want to rebuild the bundle if rollup configuration or the the
|
||||
// tooling changes (e.g. when typescript is updated), add the currently loaded
|
||||
// node.js modules to the list of dependencies.
|
||||
let inputs = [...sourceFiles, ...configFiles, ...Object.keys(require.cache)];
|
||||
// Deduplicate the list of inputs.
|
||||
inputs = Array.from(new Set(inputs.map(f => path.resolve(f))));
|
||||
// Turn filenames into relative paths and format/escape them for a Makefile.
|
||||
inputs = inputs.map(formatPath);
|
||||
|
||||
// Build a list of output filenames and normalize those too.
|
||||
const depFile = path.join(
|
||||
outputDir,
|
||||
path.basename(outputFile, path.extname(outputFile)) + ".d"
|
||||
);
|
||||
const outputs = [outputFile, depFile].map(formatPath);
|
||||
|
||||
// Generate depfile contents.
|
||||
const depFileContent = [
|
||||
...outputs.map(filename => `${filename}: ` + inputs.join(" ") + "\n\n"),
|
||||
...inputs.map(filename => `${filename}:\n`)
|
||||
].join("");
|
||||
|
||||
// Since we're writing the depfile when node's "beforeExit" hook triggers,
|
||||
// it's getting written _after_ the regular outputs are saved to disk.
|
||||
// Therefore, after writing the depfile, reset its timestamps to when we last
|
||||
// discovered a dependency, which was certainly before the bundle was built.
|
||||
fs.writeFileSync(depFile, depFileContent);
|
||||
fs.utimesSync(depFile, timestamp, timestamp);
|
||||
|
||||
// Renders path to make it suitable for a depfile.
|
||||
function formatPath(filename) {
|
||||
// Make the path relative to the root build directory.
|
||||
filename = path.relative(buildDir, filename);
|
||||
// Use forward slashes on Windows.
|
||||
if (process.platform === "win32") {
|
||||
filename = filename.replace(/\\/g, "/");
|
||||
}
|
||||
// Escape spaces with a backslash. This is what rust and clang do too.
|
||||
filename = filename.replace(/ /g, "\\ ");
|
||||
return filename;
|
||||
}
|
||||
}
|
||||
|
||||
export default function makeConfig(commandOptions) {
|
||||
return {
|
||||
output: {
|
||||
format: "iife",
|
||||
name: "denoMain",
|
||||
sourcemap: true,
|
||||
sourcemapExcludeSources: true
|
||||
},
|
||||
|
||||
plugins: [
|
||||
// inject build and version info
|
||||
replace({
|
||||
ROLLUP_REPLACE_TS_VERSION: typescript.version,
|
||||
ROLLUP_REPLACE_ARCH: archNodeToDeno[process.arch],
|
||||
ROLLUP_REPLACE_OS: osNodeToDeno[process.platform]
|
||||
}),
|
||||
|
||||
// would prefer to use `rollup-plugin-virtual` to inject the empty module, but there
|
||||
// is an issue with `rollup-plugin-commonjs` which causes errors when using the
|
||||
// virtual plugin (see: rollup/rollup-plugin-commonjs#315), this means we have to use
|
||||
// a physical module to substitute
|
||||
alias({
|
||||
fs: mockPath,
|
||||
path: mockPath,
|
||||
os: mockPath,
|
||||
crypto: mockPath,
|
||||
buffer: mockPath,
|
||||
module: mockPath
|
||||
}),
|
||||
|
||||
// Allows rollup to resolve modules based on Node.js resolution
|
||||
nodeResolve(),
|
||||
|
||||
// Allows rollup to import CommonJS modules
|
||||
commonjs({
|
||||
namedExports: {
|
||||
// Static analysis of `typescript.js` does detect the exports properly, therefore
|
||||
// rollup requires them to be explicitly defined to make them available in the
|
||||
// bundle
|
||||
[typescriptPath]: [
|
||||
"convertCompilerOptionsFromJson",
|
||||
"createLanguageService",
|
||||
"createProgram",
|
||||
"createSourceFile",
|
||||
"getPreEmitDiagnostics",
|
||||
"formatDiagnostics",
|
||||
"formatDiagnosticsWithColorAndContext",
|
||||
"parseConfigFileTextToJson",
|
||||
"version",
|
||||
"CompilerHost",
|
||||
"DiagnosticCategory",
|
||||
"Extension",
|
||||
"ModuleKind",
|
||||
"ScriptKind",
|
||||
"ScriptSnapshot",
|
||||
"ScriptTarget"
|
||||
]
|
||||
}
|
||||
}),
|
||||
|
||||
typescriptPlugin({
|
||||
// The build script is invoked from `out/:target` so passing an absolute file path is needed
|
||||
tsconfig,
|
||||
|
||||
// This provides any overrides to the `tsconfig.json` that are needed to bundle
|
||||
tsconfigOverride,
|
||||
|
||||
// This provides the locally configured version of TypeScript instead of the plugins
|
||||
// default version
|
||||
typescript,
|
||||
|
||||
// By default, the include path only includes the cwd and below, need to include the root of the project
|
||||
// and build path to be passed to this plugin. This is different front tsconfig.json include
|
||||
include: ["*.ts", `${__dirname}/**/*.ts`, `${process.cwd()}/**/*.ts`],
|
||||
|
||||
// d.ts files are not bundled and by default like include, it only includes the cwd and below
|
||||
exclude: [
|
||||
"*.d.ts",
|
||||
`${__dirname}/**/*.d.ts`,
|
||||
`${process.cwd()}/**/*.d.ts`
|
||||
]
|
||||
}),
|
||||
|
||||
// Provide some concise information about the bundle
|
||||
analyze({
|
||||
skipFormatted: true,
|
||||
onAnalysis({
|
||||
bundleSize,
|
||||
bundleOrigSize,
|
||||
bundleReduction,
|
||||
moduleCount
|
||||
}) {
|
||||
if (!commandOptions.silent) {
|
||||
console.log(
|
||||
`Bundle size: ${Math.round((bundleSize / 1000000) * 100) / 100}Mb`
|
||||
);
|
||||
console.log(
|
||||
`Original size: ${Math.round((bundleOrigSize / 1000000) * 100) /
|
||||
100}Mb`
|
||||
);
|
||||
console.log(`Reduction: ${bundleReduction}%`);
|
||||
console.log(`Module count: ${moduleCount}`);
|
||||
}
|
||||
}
|
||||
}),
|
||||
|
||||
// source-map-support, which is required by TypeScript to support source maps, requires Node.js Buffer
|
||||
// implementation. This needs to come at the end of the plugins because of the impact it has on
|
||||
// the existing runtime environment, which breaks other plugins and features of the bundler.
|
||||
globals(),
|
||||
|
||||
generateDepFile({
|
||||
outputFile: commandOptions.o,
|
||||
configFiles: [commandOptions.c, tsconfig]
|
||||
})
|
||||
]
|
||||
};
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
[WILDCARD]error: Uncaught NotFound: Cannot resolve module "[WILDCARD]/bad-module.ts"
|
||||
[WILDCARD] js/dispatch_json.ts:[WILDCARD]
|
||||
at DenoError (js/errors.ts:[WILDCARD])
|
||||
at unwrapResponse (js/dispatch_json.ts:[WILDCARD])
|
||||
at sendSync[WILDCARD] (js/dispatch_json.ts:[WILDCARD])
|
||||
at fetchSourceFile (js/compiler.ts:[WILDCARD])
|
||||
at _resolveModule (js/compiler.ts:[WILDCARD])
|
||||
at js/compiler.ts:[WILDCARD]
|
||||
at resolveModuleNames (js/compiler.ts:[WILDCARD])
|
||||
[WILDCARD]dispatch_json.ts:[WILDCARD]
|
||||
at DenoError ([WILDCARD]errors.ts:[WILDCARD])
|
||||
at unwrapResponse ([WILDCARD]dispatch_json.ts:[WILDCARD])
|
||||
at sendSync[WILDCARD] ([WILDCARD]dispatch_json.ts:[WILDCARD])
|
||||
at fetchSourceFile ([WILDCARD]compiler.ts:[WILDCARD])
|
||||
at _resolveModule ([WILDCARD]compiler.ts:[WILDCARD])
|
||||
at [WILDCARD]compiler.ts:[WILDCARD]
|
||||
at resolveModuleNames ([WILDCARD]compiler.ts:[WILDCARD])
|
||||
at resolveModuleNamesWorker ([WILDCARD]typescript.js:[WILDCARD])
|
||||
at resolveModuleNamesReusingOldState ([WILDCARD]typescript.js:[WILDCARD])
|
||||
at processImportedModules ([WILDCARD]typescript.js:[WILDCARD])
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue