diff --git a/BUILD.gn b/BUILD.gn index 1436519efa..448f926cbd 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -227,7 +227,6 @@ run_node("bundle") { "js/fetch.ts", "js/fetch_types.d.ts", "js/globals.ts", - "js/lib.globals.d.ts", "js/main.ts", "js/os.ts", "js/plugins.d.ts", diff --git a/js/assets.ts b/js/assets.ts index e5ec507f7e..8ea8f96015 100644 --- a/js/assets.ts +++ b/js/assets.ts @@ -6,7 +6,7 @@ // There is a rollup plugin that will inline any module ending with `!string` // tslint:disable:max-line-length -// Generated definitions +// Generated default library import globalsDts from "gen/types/globals.d.ts!string"; // Static libraries @@ -38,7 +38,6 @@ import libEsnextAsynciterablesDts from "/third_party/node_modules/typescript/lib import libEsnextDts from "/third_party/node_modules/typescript/lib/lib.esnext.d.ts!string"; import libEsnextIntlDts from "/third_party/node_modules/typescript/lib/lib.esnext.intl.d.ts!string"; import libEsnextSymbolDts from "/third_party/node_modules/typescript/lib/lib.esnext.symbol.d.ts!string"; -import libGlobalsDts from "/js/lib.globals.d.ts!string"; // Static definitions import fetchTypesDts from "/js/fetch_types.d.ts!string"; @@ -49,7 +48,7 @@ import typescriptDts from "/third_party/node_modules/typescript/lib/typescript.d // prettier-ignore export const assetSourceCode: { [key: string]: string } = { - // Generated definitions + // Generated library "globals.d.ts": globalsDts, // Static libraries @@ -81,7 +80,6 @@ export const assetSourceCode: { [key: string]: string } = { "lib.esnext.asynciterable.d.ts": libEsnextAsynciterablesDts, "lib.esnext.intl.d.ts": libEsnextIntlDts, "lib.esnext.symbol.d.ts": libEsnextSymbolDts, - "lib.globals.d.ts": libGlobalsDts, // Static definitions "fetch-types.d.ts": fetchTypesDts, diff --git a/js/compiler.ts b/js/compiler.ts index 28fe8be8fc..e75bc48d82 100644 --- a/js/compiler.ts +++ b/js/compiler.ts @@ -641,7 +641,7 @@ export class DenoCompiler implements ts.LanguageServiceHost { getDefaultLibFileName(): string { this._log("getDefaultLibFileName()"); - const moduleSpecifier = "lib.globals.d.ts"; + const moduleSpecifier = "globals.d.ts"; const moduleMetaData = this.resolveModule(moduleSpecifier, ASSETS); return moduleMetaData.fileName; } diff --git a/js/compiler_test.ts b/js/compiler_test.ts index 18c2d16cc6..364850d8ea 100644 --- a/js/compiler_test.ts +++ b/js/compiler_test.ts @@ -445,10 +445,7 @@ test(function compilerGetCurrentDirectory() { test(function compilerGetDefaultLibFileName() { setup(); - assertEqual( - compilerInstance.getDefaultLibFileName(), - "$asset$/lib.globals.d.ts" - ); + assertEqual(compilerInstance.getDefaultLibFileName(), "$asset$/globals.d.ts"); teardown(); }); @@ -485,14 +482,13 @@ test(function compilerFileExists() { test(function compilerResolveModuleNames() { setup(); const results = compilerInstance.resolveModuleNames( - ["foo/bar.ts", "foo/baz.ts", "$asset$/lib.globals.d.ts", "deno"], + ["foo/bar.ts", "foo/baz.ts", "deno"], "/root/project" ); - assertEqual(results.length, 4); + assertEqual(results.length, 3); const fixtures: Array<[string, boolean]> = [ ["/root/project/foo/bar.ts", false], ["/root/project/foo/baz.ts", false], - ["$asset$/lib.globals.d.ts", true], ["$asset$/globals.d.ts", true] ]; for (let i = 0; i < results.length; i++) { diff --git a/js/lib.globals.d.ts b/js/lib.globals.d.ts deleted file mode 100644 index 5243e4b5d3..0000000000 --- a/js/lib.globals.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright 2018 the Deno authors. All rights reserved. MIT license. -// This file contains the default TypeScript libraries for the deno runtime. -/// -/// -/// diff --git a/rollup.config.js b/rollup.config.js index 299bdad92a..3dbe292601 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -24,6 +24,12 @@ const tsconfigOverride = { } }; +// this is a preamble for the `globals.d.ts` file to allow it to be the default +// lib for deno. +const libPreamble = `/// +/// +`; + // this is a rollup plugin which will look for imports ending with `!string` and resolve // them with a module that will inline the contents of the file as a string. Needed to // support `js/assets.ts`. @@ -62,7 +68,9 @@ function strings({ include, exclude } = {}) { transform(code, id) { if (filter(id)) { return { - code: `export default ${JSON.stringify(code)};`, + code: `export default ${JSON.stringify( + id.endsWith("globals.d.ts") ? libPreamble + code : code + )};`, map: { mappings: "" } }; }