From 286e5d0be9bb11a69d55f0eedd4a6678b0d48e7d Mon Sep 17 00:00:00 2001 From: Leo Kettmeir Date: Wed, 8 Feb 2023 22:40:18 +0100 Subject: refactor: internal runtime code TS support (#17672) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a proof of concept for being able to snapshot TypeScript files. Currently only a single runtime file is authored in TypeScript - "runtime/js/01_version.ts". Not needed infrastructure was removed from "core/snapshot_util.rs". --------- Co-authored-by: Bartek IwaƄczuk --- runtime/js/01_version.js | 24 ------------------------ runtime/js/01_version.ts | 30 ++++++++++++++++++++++++++++++ runtime/js/90_deno_ns.js | 2 +- runtime/js/99_main.js | 2 +- 4 files changed, 32 insertions(+), 26 deletions(-) delete mode 100644 runtime/js/01_version.js create mode 100644 runtime/js/01_version.ts (limited to 'runtime/js') diff --git a/runtime/js/01_version.js b/runtime/js/01_version.js deleted file mode 100644 index 62f3df17c..000000000 --- a/runtime/js/01_version.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. - -const primordials = globalThis.__bootstrap.primordials; -const { ObjectFreeze } = primordials; - -const version = { - deno: "", - v8: "", - typescript: "", -}; - -function setVersions( - denoVersion, - v8Version, - tsVersion, -) { - version.deno = denoVersion; - version.v8 = v8Version; - version.typescript = tsVersion; - - ObjectFreeze(version); -} - -export { setVersions, version }; diff --git a/runtime/js/01_version.ts b/runtime/js/01_version.ts new file mode 100644 index 000000000..cbbbd8d03 --- /dev/null +++ b/runtime/js/01_version.ts @@ -0,0 +1,30 @@ +// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. + +const primordials = globalThis.__bootstrap.primordials; +const { ObjectFreeze } = primordials; + +interface Version { + deno: string; + v8: string; + typescript: string; +} + +const version: Version = { + deno: "", + v8: "", + typescript: "", +}; + +function setVersions( + denoVersion, + v8Version, + tsVersion, +) { + version.deno = denoVersion; + version.v8 = v8Version; + version.typescript = tsVersion; + + ObjectFreeze(version); +} + +export { setVersions, version }; diff --git a/runtime/js/90_deno_ns.js b/runtime/js/90_deno_ns.js index 5321bf1d3..fe59ea1a7 100644 --- a/runtime/js/90_deno_ns.js +++ b/runtime/js/90_deno_ns.js @@ -12,7 +12,7 @@ import * as http from "internal:deno_http/01_http.js"; import * as flash from "internal:deno_flash/01_http.js"; import * as build from "internal:runtime/js/01_build.js"; import * as errors from "internal:runtime/js/01_errors.js"; -import * as version from "internal:runtime/js/01_version.js"; +import * as version from "internal:runtime/js/01_version.ts"; import * as permissions from "internal:runtime/js/10_permissions.js"; import * as io from "internal:runtime/js/12_io.js"; import * as buffer from "internal:runtime/js/13_buffer.js"; diff --git a/runtime/js/99_main.js b/runtime/js/99_main.js index 5d9012bc4..fd7b93e24 100644 --- a/runtime/js/99_main.js +++ b/runtime/js/99_main.js @@ -43,7 +43,7 @@ import * as util from "internal:runtime/js/06_util.js"; import * as event from "internal:deno_web/02_event.js"; import * as location from "internal:deno_web/12_location.js"; import * as build from "internal:runtime/js/01_build.js"; -import * as version from "internal:runtime/js/01_version.js"; +import * as version from "internal:runtime/js/01_version.ts"; import * as os from "internal:runtime/js/30_os.js"; import * as timers from "internal:deno_web/02_timers.js"; import * as colors from "internal:deno_console/01_colors.js"; -- cgit v1.2.3