summaryrefslogtreecommitdiff
path: root/cli/build.rs
diff options
context:
space:
mode:
authorLeo Kettmeir <crowlkats@toaxl.com>2023-02-07 20:22:46 +0100
committerGitHub <noreply@github.com>2023-02-07 20:22:46 +0100
commitb4aa1530970f7b9cc4e6f2f27e077852c4e178d3 (patch)
tree3d008912affe8550692183bd2697a386db5e3c79 /cli/build.rs
parent65500f36e870b4ada3996b06aa287e30177d21a3 (diff)
refactor: Use ES modules for internal runtime code (#17648)
This PR refactors all internal js files (except core) to be written as ES modules. `__bootstrap`has been mostly replaced with static imports in form in `internal:[path to file from repo root]`. To specify if files are ESM, an `esm` method has been added to `Extension`, similar to the `js` method. A new ModuleLoader called `InternalModuleLoader` has been added to enable the loading of internal specifiers, which is used in all situations except when a snapshot is only loaded, and not a new one is created from it. --------- Co-authored-by: Bartek IwaƄczuk <biwanczuk@gmail.com>
Diffstat (limited to 'cli/build.rs')
-rw-r--r--cli/build.rs14
1 files changed, 8 insertions, 6 deletions
diff --git a/cli/build.rs b/cli/build.rs
index bb048d0d4..d4cfc47e9 100644
--- a/cli/build.rs
+++ b/cli/build.rs
@@ -275,6 +275,7 @@ mod ts {
.build()],
extensions_with_js: vec![],
additional_files: files,
+ additional_esm_files: vec![],
compression_cb: Some(Box::new(|vec, snapshot_slice| {
vec.extend_from_slice(
&zstd::bulk::compress(snapshot_slice, 22)
@@ -306,7 +307,7 @@ mod ts {
}
}
-fn create_cli_snapshot(snapshot_path: PathBuf, files: Vec<PathBuf>) {
+fn create_cli_snapshot(snapshot_path: PathBuf, esm_files: Vec<PathBuf>) {
let extensions: Vec<Extension> = vec![
deno_webidl::init(),
deno_console::init(),
@@ -343,7 +344,8 @@ fn create_cli_snapshot(snapshot_path: PathBuf, files: Vec<PathBuf>) {
startup_snapshot: Some(deno_runtime::js::deno_isolate_init()),
extensions,
extensions_with_js: vec![],
- additional_files: files,
+ additional_files: vec![],
+ additional_esm_files: esm_files,
compression_cb: Some(Box::new(|vec, snapshot_slice| {
lzzzz::lz4_hc::compress_to_vec(
snapshot_slice,
@@ -448,13 +450,13 @@ fn main() {
let o = PathBuf::from(env::var_os("OUT_DIR").unwrap());
let compiler_snapshot_path = o.join("COMPILER_SNAPSHOT.bin");
- let js_files = get_js_files(env!("CARGO_MANIFEST_DIR"), "tsc");
+ let js_files = get_js_files(env!("CARGO_MANIFEST_DIR"), "tsc", None);
ts::create_compiler_snapshot(compiler_snapshot_path, js_files, &c);
let cli_snapshot_path = o.join("CLI_SNAPSHOT.bin");
- let mut js_files = get_js_files(env!("CARGO_MANIFEST_DIR"), "js");
- js_files.push(deno_runtime::js::get_99_main());
- create_cli_snapshot(cli_snapshot_path, js_files);
+ let mut esm_files = get_js_files(env!("CARGO_MANIFEST_DIR"), "js", None);
+ esm_files.push(deno_runtime::js::get_99_main());
+ create_cli_snapshot(cli_snapshot_path, esm_files);
#[cfg(target_os = "windows")]
{