diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2020-01-28 03:12:25 +0100 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2020-01-27 21:12:25 -0500 |
commit | ac10d79d231d3b66b918764b9706597321850687 (patch) | |
tree | 6a781c58075ee0c68091e71d2ffd2bb898dc9dfd /cli/js/main.ts | |
parent | f604becaba0c747fdf8dd9d0d744c7bd19322e41 (diff) |
refactor: isomorphic snapshot for CLI (#3728)
Diffstat (limited to 'cli/js/main.ts')
-rw-r--r-- | cli/js/main.ts | 59 |
1 files changed, 24 insertions, 35 deletions
diff --git a/cli/js/main.ts b/cli/js/main.ts index 1da56eaa5..b48277960 100644 --- a/cli/js/main.ts +++ b/cli/js/main.ts @@ -1,38 +1,27 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. -import "./globals.ts"; +import { bootstrapMainRuntime } from "./runtime_main.ts"; +import { + bootstrapWorkerRuntime, + runWorkerMessageLoop +} from "./runtime_worker.ts"; -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 { setVersions } from "./version.ts"; -import { setLocation } from "./location.ts"; -import { setBuildInfo } from "./build.ts"; -import { setSignals } from "./process.ts"; - -function bootstrapMainRuntime(): void { - const s = os.start(true); - - setBuildInfo(s.os, s.arch); - setSignals(); - setVersions(s.denoVersion, s.v8Version, s.tsVersion); - - setPrepareStackTrace(Error); - - if (s.mainModule) { - assert(s.mainModule.length > 0); - setLocation(s.mainModule); - } - log("cwd", s.cwd); - for (let i = 0; i < s.argv.length; i++) { - args.push(s.argv[i]); - } - log("args", args); - Object.freeze(args); - - if (!s.mainModule) { - replLoop(); +Object.defineProperties(globalThis, { + bootstrapMainRuntime: { + value: bootstrapMainRuntime, + enumerable: false, + writable: false, + configurable: false + }, + bootstrapWorkerRuntime: { + value: bootstrapWorkerRuntime, + enumerable: false, + writable: false, + configurable: false + }, + runWorkerMessageLoop: { + value: runWorkerMessageLoop, + enumerable: false, + writable: false, + configurable: false } -} -globalThis["bootstrapMainRuntime"] = bootstrapMainRuntime; +}); |