From 13a91a69f87df98a31030d602f629a9a20f8a9c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Wed, 31 Jan 2024 22:39:56 +0100 Subject: refactor: remove imported ops from Deno.core.ops (#22194) This commit adds a list of ops to `runtime/99_main.js` that are currently relying on getting them from `Deno.core.ops`. All ops that are not present in the list are removed from `Deno.core.ops` on startup (they are imported from "virtual op module" - `ext:core/ops`) making them effectively inaccessible to user code. This change lowers the number of ops exposed to user code from 650 to around 260. This number should be gradually decreased in follow-up PRs. --- cli/tests/unit/ops_test.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 cli/tests/unit/ops_test.ts (limited to 'cli/tests/unit/ops_test.ts') diff --git a/cli/tests/unit/ops_test.ts b/cli/tests/unit/ops_test.ts new file mode 100644 index 000000000..e62d85728 --- /dev/null +++ b/cli/tests/unit/ops_test.ts @@ -0,0 +1,17 @@ +// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. + +const EXPECTED_OP_COUNT = 157; + +Deno.test(function checkExposedOps() { + // @ts-ignore TS doesn't allow to index with symbol + const core = Deno[Deno.internal].core; + const opNames = Object.keys(core.ops); + + if (opNames.length !== EXPECTED_OP_COUNT) { + throw new Error( + `Expected ${EXPECTED_OP_COUNT} ops, but got ${opNames.length}:\n${ + opNames.join("\n") + }`, + ); + } +}); -- cgit v1.2.3