summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--js/assets.ts8
-rw-r--r--js/compiler.ts10
-rw-r--r--js/libdeno.ts3
-rw-r--r--js/main.ts5
-rw-r--r--js/permissions_test.ts9
-rw-r--r--libdeno/binding.cc22
-rw-r--r--libdeno/internal.h5
-rw-r--r--libdeno/modules.cc54
-rw-r--r--libdeno/modules_test.cc151
-rw-r--r--src/isolate.rs6
-rw-r--r--tests/no_color.js3
-rw-r--r--tools/ts_library_builder/build_library.ts1
12 files changed, 11 insertions, 266 deletions
diff --git a/js/assets.ts b/js/assets.ts
index 773612b26..18bf97548 100644
--- a/js/assets.ts
+++ b/js/assets.ts
@@ -39,9 +39,6 @@ import libEsnextBigintDts from "/third_party/node_modules/typescript/lib/lib.esn
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";
-
-// Static definitions
-import typescriptDts from "/third_party/node_modules/typescript/lib/typescript.d.ts!string";
// tslint:enable:max-line-length
// @internal
@@ -78,8 +75,5 @@ export const assetSourceCode: { [key: string]: string } = {
"lib.esnext.asynciterable.d.ts": libEsnextAsynciterablesDts,
"lib.esnext.bigint.d.ts": libEsnextBigintDts,
"lib.esnext.intl.d.ts": libEsnextIntlDts,
- "lib.esnext.symbol.d.ts": libEsnextSymbolDts,
-
- // Static definitions
- "typescript.d.ts": typescriptDts
+ "lib.esnext.symbol.d.ts": libEsnextSymbolDts
};
diff --git a/js/compiler.ts b/js/compiler.ts
index 27890babd..39a32bc24 100644
--- a/js/compiler.ts
+++ b/js/compiler.ts
@@ -477,15 +477,7 @@ class Compiler implements ts.LanguageServiceHost, ts.FormatDiagnosticsHost {
this._log("resolveModuleNames()", { moduleNames, containingFile });
const resolvedModuleNames: ts.ResolvedModuleFull[] = [];
for (const moduleName of moduleNames) {
- let moduleMetaData: ModuleMetaData;
- if (moduleName === "deno") {
- // builtin modules are part of the runtime lib
- moduleMetaData = this._getModuleMetaData(LIB_RUNTIME)!;
- } else if (moduleName === "typescript") {
- moduleMetaData = this._getModuleMetaData(`${ASSETS}/typescript.d.ts`)!;
- } else {
- moduleMetaData = this._resolveModule(moduleName, containingFile);
- }
+ const moduleMetaData = this._resolveModule(moduleName, containingFile);
// According to the interface we shouldn't return `undefined` but if we
// fail to return the same length of modules to those we cannot resolve
// then TypeScript fails on an assertion that the lengths can't be
diff --git a/js/libdeno.ts b/js/libdeno.ts
index 61e259b54..ee43413f3 100644
--- a/js/libdeno.ts
+++ b/js/libdeno.ts
@@ -24,9 +24,6 @@ interface Libdeno {
shared: ArrayBuffer;
- // DEPRECATED
- builtinModules: { [s: string]: object };
-
/** Evaluate provided code in the current context.
* It differs from eval(...) in that it does not create a new context.
* Returns an array: [output, errInfo].
diff --git a/js/main.ts b/js/main.ts
index b67f188ac..830c77eb6 100644
--- a/js/main.ts
+++ b/js/main.ts
@@ -6,7 +6,6 @@ import "./globals";
import { assert, log } from "./util";
import * as os from "./os";
-import { libdeno } from "./libdeno";
import { args } from "./deno";
import { replLoop } from "./repl";
import { setVersions } from "./version";
@@ -22,10 +21,6 @@ import libDts from "gen/lib/lib.deno_runtime.d.ts!string";
export default function denoMain() {
const startResMsg = os.start();
- // TODO(kitsonk) remove when import "deno" no longer supported
- libdeno.builtinModules["deno"] = deno;
- Object.freeze(libdeno.builtinModules);
-
setVersions(startResMsg.denoVersion()!, startResMsg.v8Version()!);
// handle `--version`
diff --git a/js/permissions_test.ts b/js/permissions_test.ts
index 21c21aa94..e44be79bb 100644
--- a/js/permissions_test.ts
+++ b/js/permissions_test.ts
@@ -1,8 +1,13 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import { testPerm, assert, assertEquals } from "./test_util.ts";
-import { Permission } from "deno";
-const knownPermissions: Permission[] = ["run", "read", "write", "net", "env"];
+const knownPermissions: Deno.Permission[] = [
+ "run",
+ "read",
+ "write",
+ "net",
+ "env"
+];
for (let grant of knownPermissions) {
testPerm({ [grant]: true }, function envGranted() {
diff --git a/libdeno/binding.cc b/libdeno/binding.cc
index 7346956fd..c291852da 100644
--- a/libdeno/binding.cc
+++ b/libdeno/binding.cc
@@ -289,14 +289,6 @@ void Send(const v8::FunctionCallbackInfo<v8::Value>& args) {
}
}
-v8::Local<v8::Object> DenoIsolate::GetBuiltinModules() {
- v8::EscapableHandleScope handle_scope(isolate_);
- if (builtin_modules_.IsEmpty()) {
- builtin_modules_.Reset(isolate_, v8::Object::New(isolate_));
- }
- return handle_scope.Escape(builtin_modules_.Get(isolate_));
-}
-
v8::ScriptOrigin ModuleOrigin(v8::Isolate* isolate,
v8::Local<v8::Value> resource_name) {
return v8::ScriptOrigin(resource_name, v8::Local<v8::Integer>(),
@@ -350,15 +342,6 @@ deno_mod DenoIsolate::RegisterModule(bool main, const char* name,
return id;
}
-void BuiltinModules(v8::Local<v8::Name> property,
- const v8::PropertyCallbackInfo<v8::Value>& info) {
- v8::Isolate* isolate = info.GetIsolate();
- DenoIsolate* d = DenoIsolate::FromIsolate(isolate);
- DCHECK_EQ(d->isolate_, isolate);
- v8::Locker locker(d->isolate_);
- info.GetReturnValue().Set(d->GetBuiltinModules());
-}
-
void Shared(v8::Local<v8::Name> property,
const v8::PropertyCallbackInfo<v8::Value>& info) {
v8::Isolate* isolate = info.GetIsolate();
@@ -530,11 +513,6 @@ void InitializeContext(v8::Isolate* isolate, v8::Local<v8::Context> context) {
CHECK(deno_val->SetAccessor(context, deno::v8_str("shared"), Shared)
.FromJust());
-
- CHECK(
- deno_val
- ->SetAccessor(context, deno::v8_str("builtinModules"), BuiltinModules)
- .FromJust());
}
void MessageCallback(v8::Local<v8::Message> message,
diff --git a/libdeno/internal.h b/libdeno/internal.h
index 563043085..71cf731b6 100644
--- a/libdeno/internal.h
+++ b/libdeno/internal.h
@@ -67,7 +67,6 @@ class DenoIsolate {
void AddIsolate(v8::Isolate* isolate);
deno_mod RegisterModule(bool main, const char* name, const char* source);
- v8::Local<v8::Object> GetBuiltinModules();
void ClearModules();
ModuleInfo* GetModuleInfo(deno_mod id) {
@@ -109,7 +108,6 @@ class DenoIsolate {
size_t next_zero_copy_id_;
void* user_data_;
- v8::Persistent<v8::Object> builtin_modules_;
std::map<deno_mod, ModuleInfo> mods_;
std::map<std::string, deno_mod> mods_by_name_;
deno_resolve_cb resolve_cb_;
@@ -159,8 +157,6 @@ void EvalContext(const v8::FunctionCallbackInfo<v8::Value>& args);
void ErrorToJSON(const v8::FunctionCallbackInfo<v8::Value>& args);
void Shared(v8::Local<v8::Name> property,
const v8::PropertyCallbackInfo<v8::Value>& info);
-void BuiltinModules(v8::Local<v8::Name> property,
- const v8::PropertyCallbackInfo<v8::Value>& info);
void MessageCallback(v8::Local<v8::Message> message, v8::Local<v8::Value> data);
static intptr_t external_references[] = {
reinterpret_cast<intptr_t>(Print),
@@ -169,7 +165,6 @@ static intptr_t external_references[] = {
reinterpret_cast<intptr_t>(EvalContext),
reinterpret_cast<intptr_t>(ErrorToJSON),
reinterpret_cast<intptr_t>(Shared),
- reinterpret_cast<intptr_t>(BuiltinModules),
reinterpret_cast<intptr_t>(MessageCallback),
0};
diff --git a/libdeno/modules.cc b/libdeno/modules.cc
index d8b2f48d1..0b408aec8 100644
--- a/libdeno/modules.cc
+++ b/libdeno/modules.cc
@@ -19,42 +19,6 @@ using v8::ScriptOrigin;
using v8::String;
using v8::Value;
-std::string BuiltinModuleSrc(Local<Context> context, Local<String> specifier) {
- auto* isolate = context->GetIsolate();
- DenoIsolate* d = DenoIsolate::FromIsolate(isolate);
- v8::Isolate::Scope isolate_scope(isolate);
- v8::EscapableHandleScope handle_scope(isolate);
- v8::Context::Scope context_scope(context);
-
- v8::String::Utf8Value specifier_utf8val(isolate, specifier);
- const char* specifier_cstr = *specifier_utf8val;
-
- auto builtin_modules = d->GetBuiltinModules();
- auto val = builtin_modules->Get(context, specifier).ToLocalChecked();
- CHECK(val->IsObject());
- auto obj = val->ToObject(isolate);
-
- // In order to export obj as a module, we must iterate over its properties
- // and export them each individually.
- // TODO(ry) Find a better way to do this.
- std::string src = "let globalEval = eval\nlet g = globalEval('this');\n";
- auto names = obj->GetOwnPropertyNames(context).ToLocalChecked();
- for (uint32_t i = 0; i < names->Length(); i++) {
- auto name = names->Get(context, i).ToLocalChecked();
- v8::String::Utf8Value name_utf8val(isolate, name);
- const char* name_cstr = *name_utf8val;
- // TODO(ry) use format string.
- src.append("export const ");
- src.append(name_cstr);
- src.append(" = g.libdeno.builtinModules.");
- src.append(specifier_cstr);
- src.append(".");
- src.append(name_cstr);
- src.append(";\n");
- }
- return src;
-}
-
v8::MaybeLocal<v8::Module> ResolveCallback(Local<Context> context,
Local<String> specifier,
Local<Module> referrer) {
@@ -66,8 +30,6 @@ v8::MaybeLocal<v8::Module> ResolveCallback(Local<Context> context,
v8::EscapableHandleScope handle_scope(isolate);
- auto builtin_modules = d->GetBuiltinModules();
-
deno_mod referrer_id = referrer->GetIdentityHash();
auto* referrer_info = d->GetModuleInfo(referrer_id);
CHECK_NOT_NULL(referrer_info);
@@ -79,21 +41,7 @@ v8::MaybeLocal<v8::Module> ResolveCallback(Local<Context> context,
v8::String::Utf8Value req_utf8(isolate, req);
std::string req_str(*req_utf8);
- deno_mod id = 0;
- {
- bool has_builtin = builtin_modules->Has(context, specifier).ToChecked();
- if (has_builtin) {
- auto it = d->mods_by_name_.find(req_str.c_str());
- if (it != d->mods_by_name_.end()) {
- id = it->second;
- } else {
- std::string src = BuiltinModuleSrc(context, specifier);
- id = d->RegisterModule(false, req_str.c_str(), src.c_str());
- }
- } else {
- id = d->resolve_cb_(d->user_data_, req_str.c_str(), referrer_id);
- }
- }
+ deno_mod id = d->resolve_cb_(d->user_data_, req_str.c_str(), referrer_id);
// Note: id might be zero, in which case GetModuleInfo will return
// nullptr.
diff --git a/libdeno/modules_test.cc b/libdeno/modules_test.cc
index cb800e89a..357c48641 100644
--- a/libdeno/modules_test.cc
+++ b/libdeno/modules_test.cc
@@ -64,157 +64,6 @@ TEST(ModulesTest, Resolution) {
deno_delete(d);
}
-TEST(ModulesTest, BuiltinModules) {
- exec_count = 0; // Reset
- Deno* d = deno_new(deno_config{0, empty, empty, recv_cb});
- EXPECT_EQ(0, exec_count);
-
- deno_execute(d, d, "setup.js",
- "libdeno.builtinModules['deno'] = { foo: 'bar' };");
- EXPECT_EQ(nullptr, deno_last_exception(d));
-
- static deno_mod a =
- deno_mod_new(d, true, "a.js",
- "import { b } from 'b.js'\n"
- "import * as deno from 'deno'\n"
- "if (b() != 'b') throw Error('b');\n"
- "if (deno.foo != 'bar') throw Error('foo');\n"
- "libdeno.send(new Uint8Array([4]));");
- EXPECT_NE(a, 0);
- EXPECT_EQ(nullptr, deno_last_exception(d));
-
- const char* b_src = "export function b() { return 'b' }";
- static deno_mod b = deno_mod_new(d, false, "b.js", b_src);
- EXPECT_NE(b, 0);
- EXPECT_EQ(nullptr, deno_last_exception(d));
-
- EXPECT_EQ(0, exec_count);
-
- EXPECT_EQ(2u, deno_mod_imports_len(d, a));
- EXPECT_EQ(0u, deno_mod_imports_len(d, b));
-
- EXPECT_STREQ("b.js", deno_mod_imports_get(d, a, 0));
- EXPECT_STREQ("deno", deno_mod_imports_get(d, a, 1));
- EXPECT_EQ(nullptr, deno_mod_imports_get(d, a, 2));
- EXPECT_EQ(nullptr, deno_mod_imports_get(d, b, 0));
-
- static int resolve_count = 0;
- auto resolve_cb = [](void* user_data, const char* specifier,
- deno_mod referrer) {
- EXPECT_EQ(referrer, a);
- EXPECT_STREQ(specifier, "b.js");
- resolve_count++;
- return b;
- };
-
- deno_mod_instantiate(d, d, b, resolve_cb);
- EXPECT_EQ(nullptr, deno_last_exception(d));
- EXPECT_EQ(0, resolve_count);
- EXPECT_EQ(0, exec_count);
-
- deno_mod_instantiate(d, d, a, resolve_cb);
- EXPECT_EQ(nullptr, deno_last_exception(d));
- EXPECT_EQ(1, resolve_count);
- EXPECT_EQ(0, exec_count);
-
- deno_mod_evaluate(d, d, a);
- EXPECT_EQ(nullptr, deno_last_exception(d));
- EXPECT_EQ(1, resolve_count);
- EXPECT_EQ(1, exec_count);
-
- deno_delete(d);
-}
-
-TEST(ModulesTest, BuiltinModules2) {
- exec_count = 0; // Reset
- Deno* d = deno_new(deno_config{0, empty, empty, recv_cb});
- EXPECT_EQ(0, exec_count);
-
- deno_execute(d, d, "setup.js",
- "libdeno.builtinModules['builtin1'] = { foo: 'bar' }; \n"
- "libdeno.builtinModules['builtin2'] = { hello: 'world' }; \n");
- EXPECT_EQ(nullptr, deno_last_exception(d));
-
- static deno_mod a =
- deno_mod_new(d, true, "a.js",
- "import * as b1 from 'builtin1'\n"
- "import * as b2 from 'builtin2'\n"
- "if (b1.foo != 'bar') throw Error('bad1');\n"
- "if (b2.hello != 'world') throw Error('bad2');\n"
- "libdeno.send(new Uint8Array([4]));");
- EXPECT_NE(a, 0);
- EXPECT_EQ(nullptr, deno_last_exception(d));
-
- EXPECT_EQ(2u, deno_mod_imports_len(d, a));
- EXPECT_STREQ("builtin1", deno_mod_imports_get(d, a, 0));
- EXPECT_STREQ("builtin2", deno_mod_imports_get(d, a, 1));
-
- deno_mod_instantiate(d, d, a, nullptr);
- EXPECT_EQ(nullptr, deno_last_exception(d));
- EXPECT_EQ(0, exec_count);
-
- deno_mod_evaluate(d, d, a);
- EXPECT_EQ(nullptr, deno_last_exception(d));
- EXPECT_EQ(1, exec_count);
-
- deno_delete(d);
-}
-
-TEST(ModulesTest, BuiltinModules3) {
- exec_count = 0; // Reset
- Deno* d = deno_new(deno_config{0, empty, empty, recv_cb});
- EXPECT_EQ(0, exec_count);
-
- deno_execute(d, d, "setup.js",
- "libdeno.builtinModules['builtin'] = { foo: 'bar' };");
- EXPECT_EQ(nullptr, deno_last_exception(d));
-
- static deno_mod a =
- deno_mod_new(d, true, "a.js",
- "import * as b1 from 'builtin'\n"
- "import * as b2 from 'b.js'\n"
- "if (b1.foo != 'bar') throw Error('bad1');\n"
- "if (b2.bar() != 'bar') throw Error('bad2');\n"
- "libdeno.send(new Uint8Array([4]));");
- EXPECT_NE(a, 0);
- EXPECT_EQ(nullptr, deno_last_exception(d));
-
- EXPECT_EQ(2u, deno_mod_imports_len(d, a));
- EXPECT_STREQ("builtin", deno_mod_imports_get(d, a, 0));
- EXPECT_STREQ("b.js", deno_mod_imports_get(d, a, 1));
-
- static deno_mod b = deno_mod_new(d, false, "b.js",
- "import { foo } from 'builtin';\n"
- "export function bar() { return foo }\n");
- EXPECT_NE(b, 0);
- EXPECT_EQ(nullptr, deno_last_exception(d));
-
- static int resolve_count = 0;
- auto resolve_cb = [](void* user_data, const char* specifier,
- deno_mod referrer) {
- EXPECT_EQ(referrer, a);
- EXPECT_STREQ(specifier, "b.js");
- resolve_count++;
- return b;
- };
-
- deno_mod_instantiate(d, d, a, resolve_cb);
- EXPECT_EQ(nullptr, deno_last_exception(d));
- EXPECT_EQ(1, resolve_count);
- EXPECT_EQ(0, exec_count);
-
- deno_mod_instantiate(d, d, b, resolve_cb);
- EXPECT_EQ(nullptr, deno_last_exception(d));
- EXPECT_EQ(1, resolve_count);
- EXPECT_EQ(0, exec_count);
-
- deno_mod_evaluate(d, d, a);
- EXPECT_EQ(nullptr, deno_last_exception(d));
- EXPECT_EQ(1, exec_count);
-
- deno_delete(d);
-}
-
TEST(ModulesTest, ResolutionError) {
exec_count = 0; // Reset
Deno* d = deno_new(deno_config{0, empty, empty, recv_cb});
diff --git a/src/isolate.rs b/src/isolate.rs
index 05af3e6bc..d4f0f2539 100644
--- a/src/isolate.rs
+++ b/src/isolate.rs
@@ -342,12 +342,6 @@ impl Isolate {
let specifier_c: &CStr = unsafe { CStr::from_ptr(specifier_ptr) };
let specifier: &str = specifier_c.to_str().unwrap();
- // TODO(ry) This shouldn't be necessary here. builtin modules should be
- // taken care of at the libdeno level.
- if specifier == "deno" {
- continue;
- }
-
let (name, _local_filename) = self
.state
.dir
diff --git a/tests/no_color.js b/tests/no_color.js
index 0963c94c4..cea11a52f 100644
--- a/tests/no_color.js
+++ b/tests/no_color.js
@@ -1,2 +1 @@
-import { noColor } from "deno";
-console.log("noColor", noColor);
+console.log("noColor", Deno.noColor);
diff --git a/tools/ts_library_builder/build_library.ts b/tools/ts_library_builder/build_library.ts
index abfb430d1..00f6fccf0 100644
--- a/tools/ts_library_builder/build_library.ts
+++ b/tools/ts_library_builder/build_library.ts
@@ -485,7 +485,6 @@ export function main({
declarationProject,
filePath: `${basePath}/js/deno.d.ts`,
globalInterfaceName: "Window",
- moduleName: `"deno"`,
namespaceName: "Deno",
targetSourceFile: libDTs
});