Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experiment: Remove all internal typescript code, manage bundle manually #4750

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@
"@typescript-eslint/explicit-function-return-type": ["off"]
}
},
{
"files": ["cli/js/rt/*.js", "cli/js/tsrt/*.js"],
"rules": {
"@typescript-eslint/camelcase": ["off"]
}
},
{
"files": ["tools/node_*.js"],
"rules": {
Expand Down
37 changes: 8 additions & 29 deletions cli/build.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
use deno_core::include_crate_modules;
use deno_core::Isolate;
use deno_core::StartupData;
use std::collections::HashMap;
Expand All @@ -20,8 +19,6 @@ fn main() {
deno_typescript::ts_version()
);

let extern_crate_modules = include_crate_modules![deno_core];

// The generation of snapshots is slow and often unnecessary. Until we figure
// out how to speed it up, or avoid it when unnecessary, this env var provides
// an escape hatch for the impatient hacker in need of faster incremental
Expand All @@ -36,40 +33,22 @@ fn main() {
let o = PathBuf::from(env::var_os("OUT_DIR").unwrap());

// Main snapshot
let root_names = vec![c.join("js/main.ts")];
let bundle_path = o.join("CLI_SNAPSHOT.js");
let script_dir = PathBuf::from("js/rt/");
let snapshot_path = o.join("CLI_SNAPSHOT.bin");

let main_module_name = deno_typescript::compile_bundle(
&bundle_path,
root_names,
Some(extern_crate_modules.clone()),
)
.expect("Bundle compilation failed");
assert!(bundle_path.exists());

assert!(script_dir.exists());
let runtime_isolate = &mut Isolate::new(StartupData::None, true);

deno_typescript::mksnapshot_bundle(
runtime_isolate,
&snapshot_path,
&bundle_path,
&main_module_name,
&script_dir,
"cli/js/main.ts",
)
.expect("Failed to create snapshot");

// Compiler snapshot
let root_names = vec![c.join("js/compiler.ts")];
let bundle_path = o.join("COMPILER_SNAPSHOT.js");
let script_dir = PathBuf::from("js/tsrt/");
let snapshot_path = o.join("COMPILER_SNAPSHOT.bin");

let main_module_name = deno_typescript::compile_bundle(
&bundle_path,
root_names,
Some(extern_crate_modules),
)
.expect("Bundle compilation failed");
assert!(bundle_path.exists());
assert!(script_dir.exists());

let runtime_isolate = &mut Isolate::new(StartupData::None, true);

Expand Down Expand Up @@ -98,8 +77,8 @@ fn main() {
deno_typescript::mksnapshot_bundle_ts(
runtime_isolate,
&snapshot_path,
&bundle_path,
&main_module_name,
&script_dir,
"cli/js/compiler.ts",
)
.expect("Failed to create snapshot");
}
8 changes: 4 additions & 4 deletions cli/file_fetcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1314,8 +1314,8 @@ mod tests {
let r = fetcher.fetch_source_file(&specifier, None).await;
assert!(r.is_err());

let p =
std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("js/main.ts");
let p = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("tests/002_hello.ts");
let specifier =
ModuleSpecifier::resolve_url_or_path(p.to_str().unwrap()).unwrap();
let r = fetcher.fetch_source_file(&specifier, None).await;
Expand All @@ -1333,8 +1333,8 @@ mod tests {
let r = fetcher.fetch_source_file(&specifier, None).await;
assert!(r.is_err());

let p =
std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("js/main.ts");
let p = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("tests/002_hello.ts");
let specifier =
ModuleSpecifier::resolve_url_or_path(p.to_str().unwrap()).unwrap();
let r = fetcher.fetch_source_file(&specifier, None).await;
Expand Down
10 changes: 0 additions & 10 deletions cli/js.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,9 @@ pub const TS_VERSION: &str = env!("TS_VERSION");

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"));
#[allow(dead_code)]
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"));
#[allow(dead_code)]
pub static COMPILER_SNAPSHOT_DTS: &[u8] =
include_bytes!(concat!(env!("OUT_DIR"), "/COMPILER_SNAPSHOT.d.ts"));

pub static DENO_NS_LIB: &str = include_str!("js/lib.deno.ns.d.ts");
pub static SHARED_GLOBALS_LIB: &str =
Expand Down
227 changes: 0 additions & 227 deletions cli/js/buffer.ts

This file was deleted.

24 changes: 0 additions & 24 deletions cli/js/build.ts

This file was deleted.

Loading