1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-24 16:08:03 -05:00
denoland-deno/js/main.ts
Ryan Dahl d43b43ca78
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.
2019-09-02 17:07:11 -04:00

51 lines
1.4 KiB
TypeScript

// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import "./globals.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 { 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";
function denoMain(preserveDenoNamespace: boolean = true, name?: string): void {
const s = os.start(preserveDenoNamespace, name);
setVersions(s.denoVersion, s.v8Version);
// handle `--version`
if (s.versionFlag) {
const { console } = window;
console.log("deno:", Deno.version.deno);
console.log("v8:", Deno.version.v8);
console.log("typescript:", Deno.version.typescript);
os.exit(0);
}
setPrepareStackTrace(Error);
if (s.mainModule) {
assert(s.mainModule.length > 0);
setLocation(s.mainModule);
}
log("cwd", s.cwd);
for (let i = 1; i < s.argv.length; i++) {
args.push(s.argv[i]);
}
log("args", args);
Object.freeze(args);
if (window["_xevalWrapper"] !== undefined) {
xevalMain(window["_xevalWrapper"] as XevalFunc, s.xevalDelim);
} else if (!s.mainModule) {
replLoop();
}
}
window["denoMain"] = denoMain;