mirror of
https://github.com/denoland/deno.git
synced 2025-01-10 16:11:13 -05:00
Create ASSETS const in runtime.ts
This commit is contained in:
parent
28078cf441
commit
eda1c7b74a
1 changed files with 7 additions and 6 deletions
|
@ -17,6 +17,7 @@ import { window, globalEval } from "./globals";
|
||||||
//import * as deno from "./deno";
|
//import * as deno from "./deno";
|
||||||
|
|
||||||
const EOL = "\n";
|
const EOL = "\n";
|
||||||
|
const ASSETS = "/$asset$/";
|
||||||
|
|
||||||
// tslint:disable-next-line:no-any
|
// tslint:disable-next-line:no-any
|
||||||
export type AmdFactory = (...args: any[]) => undefined | object;
|
export type AmdFactory = (...args: any[]) => undefined | object;
|
||||||
|
@ -166,13 +167,13 @@ export function resolveModule(
|
||||||
util.assert(moduleSpecifier != null && moduleSpecifier.length > 0);
|
util.assert(moduleSpecifier != null && moduleSpecifier.length > 0);
|
||||||
let filename: string, sourceCode: string, outputCode: string;
|
let filename: string, sourceCode: string, outputCode: string;
|
||||||
if (
|
if (
|
||||||
moduleSpecifier.startsWith("/$asset$/") ||
|
moduleSpecifier.startsWith(ASSETS) ||
|
||||||
containingFile.startsWith("/$asset$/")
|
containingFile.startsWith(ASSETS)
|
||||||
) {
|
) {
|
||||||
// Assets are compiled into the runtime javascript bundle.
|
// Assets are compiled into the runtime javascript bundle.
|
||||||
const assetName = moduleSpecifier.split("/").pop();
|
const assetName = moduleSpecifier.split("/").pop();
|
||||||
sourceCode = assetSourceCode[assetName];
|
sourceCode = assetSourceCode[assetName];
|
||||||
filename = "/$asset$/" + assetName;
|
filename = ASSETS + assetName;
|
||||||
} else {
|
} else {
|
||||||
// We query Rust with a CodeFetch message. It will load the sourceCode, and
|
// We query Rust with a CodeFetch message. It will load the sourceCode, and
|
||||||
// if there is any outputCode cached, will return that as well.
|
// if there is any outputCode cached, will return that as well.
|
||||||
|
@ -331,7 +332,7 @@ class TypeScriptHost implements ts.LanguageServiceHost {
|
||||||
getDefaultLibFileName(options: ts.CompilerOptions): string {
|
getDefaultLibFileName(options: ts.CompilerOptions): string {
|
||||||
const fn = "lib.deno.d.ts"; // ts.getDefaultLibFileName(options);
|
const fn = "lib.deno.d.ts"; // ts.getDefaultLibFileName(options);
|
||||||
util.log("getDefaultLibFileName", fn);
|
util.log("getDefaultLibFileName", fn);
|
||||||
const m = resolveModule(fn, "/$asset$/");
|
const m = resolveModule(fn, ASSETS);
|
||||||
return m.fileName;
|
return m.fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -344,9 +345,9 @@ class TypeScriptHost implements ts.LanguageServiceHost {
|
||||||
return moduleNames.map((name: string) => {
|
return moduleNames.map((name: string) => {
|
||||||
let resolvedFileName;
|
let resolvedFileName;
|
||||||
if (name === "deno") {
|
if (name === "deno") {
|
||||||
resolvedFileName = resolveModuleName("deno.d.ts", "/$asset$/");
|
resolvedFileName = resolveModuleName("deno.d.ts", ASSETS);
|
||||||
} else if (name === "typescript") {
|
} else if (name === "typescript") {
|
||||||
resolvedFileName = resolveModuleName("typescript.d.ts", "/$asset$/");
|
resolvedFileName = resolveModuleName("typescript.d.ts", ASSETS);
|
||||||
} else {
|
} else {
|
||||||
resolvedFileName = resolveModuleName(name, containingFile);
|
resolvedFileName = resolveModuleName(name, containingFile);
|
||||||
if (resolvedFileName == null) {
|
if (resolvedFileName == null) {
|
||||||
|
|
Loading…
Reference in a new issue