chore: use primordials in 40_testing.js (#21422)

This commit brings back usage of primordials in "40_testing.js" by
turning it back into an ES module and using new "lazy loading" functionality
of ES modules coming from "deno_core".

The same approach was applied to "40_jupyter.js".

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
This commit is contained in:
Divy Srivastava 2023-12-08 13:03:25 +05:30 committed by GitHub
parent 2235a1a359
commit c5c5dea90d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 1561 additions and 1566 deletions

12
Cargo.lock generated
View file

@ -1065,9 +1065,9 @@ dependencies = [
[[package]] [[package]]
name = "deno_core" name = "deno_core"
version = "0.236.0" version = "0.237.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ea0ab6f78d50bc3c9730f3a7faa3b9b32463b25f4af3dd0f02c6a18d995047e" checksum = "a2ea708c221abdb5734e3c4b72075379c3046eb0ac54afa0ecb5e58509cce72c"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"bytes", "bytes",
@ -1493,9 +1493,9 @@ dependencies = [
[[package]] [[package]]
name = "deno_ops" name = "deno_ops"
version = "0.112.0" version = "0.113.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8050c4964e689fb05cac12df6c52727950b44ce48bdd6b5e4d3c0332f2e7aa76" checksum = "e5b9c0f6360795fb625774a8b5955c87c470c43159670cf5d2052df5ce9d84bc"
dependencies = [ dependencies = [
"proc-macro-rules", "proc-macro-rules",
"proc-macro2", "proc-macro2",
@ -4638,9 +4638,9 @@ dependencies = [
[[package]] [[package]]
name = "serde_v8" name = "serde_v8"
version = "0.145.0" version = "0.146.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cbd782806b3088c7083a142be36ceb734ccfb1da6f82b5eb84a2bff2b4a68efe" checksum = "78309bd1ec4d14d165f271e203bdc45ad5bf45525da57bb70901f57942f6c0f7"
dependencies = [ dependencies = [
"bytes", "bytes",
"derive_more", "derive_more",

View file

@ -40,7 +40,7 @@ repository = "https://github.com/denoland/deno"
[workspace.dependencies] [workspace.dependencies]
deno_ast = { version = "0.31.6", features = ["transpiling"] } deno_ast = { version = "0.31.6", features = ["transpiling"] }
deno_core = { version = "0.236.0" } deno_core = { version = "0.237.0" }
deno_runtime = { version = "0.135.0", path = "./runtime" } deno_runtime = { version = "0.135.0", path = "./runtime" }
napi_sym = { version = "0.57.0", path = "./cli/napi/sym" } napi_sym = { version = "0.57.0", path = "./cli/napi/sym" }

View file

@ -36,9 +36,7 @@
* }, { raw: true }); * }, { raw: true });
* ``` * ```
*/ */
(() => { import { core, internals } from "ext:core/mod.js";
const internals = Deno[Deno.internal];
const core = internals.core;
const $display = Symbol.for("Jupyter.display"); const $display = Symbol.for("Jupyter.display");
@ -428,4 +426,3 @@
} }
internals.enableJupyter = enableJupyter; internals.enableJupyter = enableJupyter;
})();

View file

@ -1,19 +1,36 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
// Do not use primordials because we do not want to depend on the __bootstrap
// namespace.
//
// deno-lint-ignore-file // deno-lint-ignore-file
(() => {
const internals = Deno[Deno.internal]; import { core, internals, primordials } from "ext:core/mod.js";
const core = internals.core;
const ops = core.ops; const ops = core.ops;
import { setExitHandler } from "ext:runtime/30_os.js";
import { Console } from "ext:deno_console/01_console.js";
import { serializePermissions } from "ext:runtime/10_permissions.js";
import { setTimeout } from "ext:deno_web/02_timers.js";
const { const {
setExitHandler, ArrayPrototypeFilter,
Console, ArrayPrototypeJoin,
serializePermissions, ArrayPrototypePush,
} = internals; ArrayPrototypeShift,
DateNow,
Error,
FunctionPrototype,
Map,
MapPrototypeGet,
MapPrototypeHas,
MapPrototypeSet,
MathCeil,
ObjectKeys,
ObjectPrototypeIsPrototypeOf,
Promise,
SafeArrayIterator,
Set,
StringPrototypeReplaceAll,
SymbolToStringTag,
TypeError,
} = primordials;
const opSanitizerDelayResolveQueue = []; const opSanitizerDelayResolveQueue = [];
let hasSetOpSanitizerDelayMacrotask = false; let hasSetOpSanitizerDelayMacrotask = false;
@ -43,14 +60,14 @@
// timeout callback will mean that the resolver gets called in the same // timeout callback will mean that the resolver gets called in the same
// event loop tick as the timeout callback. // event loop tick as the timeout callback.
setTimeout(() => { setTimeout(() => {
opSanitizerDelayResolveQueue.push(resolve); ArrayPrototypePush(opSanitizerDelayResolveQueue, resolve);
}, hasPendingWorkerOps ? 1 : 0); }, hasPendingWorkerOps ? 1 : 0);
}); });
return p; return p;
} }
function handleOpSanitizerDelayMacrotask() { function handleOpSanitizerDelayMacrotask() {
const resolve = opSanitizerDelayResolveQueue.shift(); const resolve = ArrayPrototypeShift(opSanitizerDelayResolveQueue);
if (resolve) { if (resolve) {
resolve(); resolve();
return opSanitizerDelayResolveQueue.length === 0; return opSanitizerDelayResolveQueue.length === 0;
@ -219,17 +236,17 @@
const traces = []; const traces = [];
for (const [id, { opName: traceOpName, stack }] of postTraces) { for (const [id, { opName: traceOpName, stack }] of postTraces) {
if (traceOpName !== opName) continue; if (traceOpName !== opName) continue;
if (preTraces.has(id)) continue; if (MapPrototypeHas(preTraces, id)) continue;
traces.push(stack); ArrayPrototypePush(traces, stack);
} }
if (traces.length === 1) { if (traces.length === 1) {
message += " The operation was started here:\n"; message += " The operation was started here:\n";
message += traces[0]; message += traces[0];
} else if (traces.length > 1) { } else if (traces.length > 1) {
message += " The operations were started here:\n"; message += " The operations were started here:\n";
message += traces.join("\n\n"); message += ArrayPrototypeJoin(traces, "\n\n");
} }
details.push(message); ArrayPrototypePush(details, message);
} else if (diff < 0) { } else if (diff < 0) {
const [name, hint] = OP_DETAILS[opName] || [opName, null]; const [name, hint] = OP_DETAILS[opName] || [opName, null];
const count = -diff; const count = -diff;
@ -246,17 +263,17 @@
const traces = []; const traces = [];
for (const [id, { opName: traceOpName, stack }] of preTraces) { for (const [id, { opName: traceOpName, stack }] of preTraces) {
if (opName !== traceOpName) continue; if (opName !== traceOpName) continue;
if (postTraces.has(id)) continue; if (MapPrototypeHas(postTraces, id)) continue;
traces.push(stack); ArrayPrototypePush(traces, stack);
} }
if (traces.length === 1) { if (traces.length === 1) {
message += " The operation was started here:\n"; message += " The operation was started here:\n";
message += traces[0]; message += traces[0];
} else if (traces.length > 1) { } else if (traces.length > 1) {
message += " The operations were started here:\n"; message += " The operations were started here:\n";
message += traces.join("\n\n"); message += ArrayPrototypeJoin(traces, "\n\n");
} }
details.push(message); ArrayPrototypePush(details, message);
} else { } else {
throw new Error("unreachable"); throw new Error("unreachable");
} }
@ -414,8 +431,8 @@
const post = core.resources(); const post = core.resources();
const allResources = new Set([ const allResources = new Set([
...Object.keys(pre), ...new SafeArrayIterator(ObjectKeys(pre)),
...Object.keys(post), ...new SafeArrayIterator(ObjectKeys(post)),
]); ]);
const details = []; const details = [];
@ -429,12 +446,12 @@
const hint = resourceCloseHint(postResource); const hint = resourceCloseHint(postResource);
const detail = const detail =
`${name} (rid ${resource}) was ${action1} during the test, but not ${action2} during the test. ${hint}`; `${name} (rid ${resource}) was ${action1} during the test, but not ${action2} during the test. ${hint}`;
details.push(detail); ArrayPrototypePush(details, detail);
} else { } else {
const [name, action1, action2] = prettyResourceNames(preResource); const [name, action1, action2] = prettyResourceNames(preResource);
const detail = const detail =
`${name} (rid ${resource}) was ${action1} before the test started, but was ${action2} during the test. Do not close resources in a test that were not created during that test.`; `${name} (rid ${resource}) was ${action1} before the test started, but was ${action2} during the test. Do not close resources in a test that were not created during that test.`;
details.push(detail); ArrayPrototypePush(details, detail);
} }
} }
if (details.length == 0) { if (details.length == 0) {
@ -457,7 +474,7 @@
}); });
try { try {
const innerResult = await fn(...params); const innerResult = await fn(...new SafeArrayIterator(params));
if (innerResult) return innerResult; if (innerResult) return innerResult;
} finally { } finally {
setExitHandler(null); setExitHandler(null);
@ -475,7 +492,7 @@
} catch (error) { } catch (error) {
return { failed: { jsError: core.destructureError(error) } }; return { failed: { jsError: core.destructureError(error) } };
} finally { } finally {
const state = testStates.get(desc.id); const state = MapPrototypeGet(testStates, desc.id);
for (const childDesc of state.children) { for (const childDesc of state.children) {
stepReportResult(childDesc, { failed: "incomplete" }, 0); stepReportResult(childDesc, { failed: "incomplete" }, 0);
} }
@ -491,14 +508,14 @@
const results = []; const results = [];
let childDesc = desc; let childDesc = desc;
while (childDesc.parent != null) { while (childDesc.parent != null) {
const state = testStates.get(childDesc.parent.id); const state = MapPrototypeGet(testStates, childDesc.parent.id);
for (const siblingDesc of state.children) { for (const siblingDesc of state.children) {
if (siblingDesc.id == childDesc.id) { if (siblingDesc.id == childDesc.id) {
continue; continue;
} }
const siblingState = testStates.get(siblingDesc.id); const siblingState = MapPrototypeGet(testStates, siblingDesc.id);
if (!siblingState.completed) { if (!siblingState.completed) {
results.push(siblingDesc); ArrayPrototypePush(results, siblingDesc);
} }
} }
childDesc = childDesc.parent; childDesc = childDesc.parent;
@ -506,7 +523,8 @@
return results; return results;
} }
const runningStepDescs = getRunningStepDescs(); const runningStepDescs = getRunningStepDescs();
const runningStepDescsWithSanitizers = runningStepDescs.filter( const runningStepDescsWithSanitizers = ArrayPrototypeFilter(
runningStepDescs,
(d) => usesSanitizer(d), (d) => usesSanitizer(d),
); );
@ -527,10 +545,10 @@
}, },
}; };
} }
await fn(testStates.get(desc.id).context); await fn(MapPrototypeGet(testStates, desc.id).context);
let failedSteps = 0; let failedSteps = 0;
for (const childDesc of testStates.get(desc.id).children) { for (const childDesc of MapPrototypeGet(testStates, desc.id).children) {
const state = testStates.get(childDesc.id); const state = MapPrototypeGet(testStates, childDesc.id);
if (!state.completed) { if (!state.completed) {
return { failed: "incompleteSteps" }; return { failed: "incompleteSteps" };
} }
@ -557,7 +575,7 @@
const token = pledgePermissions(permissions); const token = pledgePermissions(permissions);
try { try {
return await fn(...params); return await fn(...new SafeArrayIterator(params));
} finally { } finally {
restorePermissions(token); restorePermissions(token);
} }
@ -584,7 +602,7 @@
if (ch <= 13 && ch >= 8) { if (ch <= 13 && ch >= 8) {
// Slow path: We do need to escape it // Slow path: We do need to escape it
for (const [escape, replaceWith] of ESCAPE_ASCII_CHARS) { for (const [escape, replaceWith] of ESCAPE_ASCII_CHARS) {
name = name.replaceAll(escape, replaceWith); name = StringPrototypeReplaceAll(name, escape, replaceWith);
} }
return name; return name;
} }
@ -776,7 +794,7 @@
); );
testDesc.id = registerTestIdRetBuf[0]; testDesc.id = registerTestIdRetBuf[0];
testDesc.origin = origin; testDesc.origin = origin;
testStates.set(testDesc.id, { MapPrototypeSet(testStates, testDesc.id, {
context: createTestContext(testDesc), context: createTestContext(testDesc),
children: [], children: [],
completed: false, completed: false,
@ -945,11 +963,11 @@
n, n,
min, min,
max, max,
p75: all[Math.ceil(n * (75 / 100)) - 1], p75: all[MathCeil(n * (75 / 100)) - 1],
p99: all[Math.ceil(n * (99 / 100)) - 1], p99: all[MathCeil(n * (99 / 100)) - 1],
p995: all[Math.ceil(n * (99.5 / 100)) - 1], p995: all[MathCeil(n * (99.5 / 100)) - 1],
p999: all[Math.ceil(n * (99.9 / 100)) - 1], p999: all[MathCeil(n * (99.9 / 100)) - 1],
avg: !highPrecision ? (avg / n) : Math.ceil(avg / n), avg: !highPrecision ? (avg / n) : MathCeil(avg / n),
highPrecision, highPrecision,
usedExplicitTimers, usedExplicitTimers,
}; };
@ -1036,7 +1054,7 @@
n++; n++;
avg += measuredTime; avg += measuredTime;
budget -= totalTime; budget -= totalTime;
all.push(measuredTime); ArrayPrototypePush(all, measuredTime);
if (measuredTime < min) min = measuredTime; if (measuredTime < min) min = measuredTime;
if (measuredTime > max) max = measuredTime; if (measuredTime > max) max = measuredTime;
} }
@ -1059,7 +1077,7 @@
n++; n++;
avg += measuredTime; avg += measuredTime;
budget -= totalTime; budget -= totalTime;
all.push(measuredTime); ArrayPrototypePush(all, measuredTime);
if (measuredTime < min) min = measuredTime; if (measuredTime < min) min = measuredTime;
if (measuredTime > max) max = measuredTime; if (measuredTime > max) max = measuredTime;
} }
@ -1080,7 +1098,7 @@
n++; n++;
avg += iterationTime; avg += iterationTime;
all.push(iterationTime); ArrayPrototypePush(all, iterationTime);
if (iterationTime < min) min = iterationTime; if (iterationTime < min) min = iterationTime;
if (iterationTime > max) max = iterationTime; if (iterationTime > max) max = iterationTime;
budget -= iterationTime * lowPrecisionThresholdInNs; budget -= iterationTime * lowPrecisionThresholdInNs;
@ -1097,7 +1115,7 @@
n++; n++;
avg += iterationTime; avg += iterationTime;
all.push(iterationTime); ArrayPrototypePush(all, iterationTime);
if (iterationTime < min) min = iterationTime; if (iterationTime < min) min = iterationTime;
if (iterationTime > max) max = iterationTime; if (iterationTime > max) max = iterationTime;
budget -= iterationTime * lowPrecisionThresholdInNs; budget -= iterationTime * lowPrecisionThresholdInNs;
@ -1120,7 +1138,7 @@
/** @param desc {BenchDescription} */ /** @param desc {BenchDescription} */
function createBenchContext(desc) { function createBenchContext(desc) {
return { return {
[Symbol.toStringTag]: "BenchContext", [SymbolToStringTag]: "BenchContext",
name: desc.name, name: desc.name,
origin: desc.origin, origin: desc.origin,
start() { start() {
@ -1215,7 +1233,7 @@
} }
function stepReportResult(desc, result, elapsed) { function stepReportResult(desc, result, elapsed) {
const state = testStates.get(desc.id); const state = MapPrototypeGet(testStates, desc.id);
for (const childDesc of state.children) { for (const childDesc of state.children) {
stepReportResult(childDesc, { failed: "incomplete" }, 0); stepReportResult(childDesc, { failed: "incomplete" }, 0);
} }
@ -1235,7 +1253,7 @@
let rootId; let rootId;
let rootName; let rootName;
if ("parent" in desc) { if ("parent" in desc) {
parent = testStates.get(desc.parent.id).context; parent = MapPrototypeGet(testStates, desc.parent.id).context;
level = desc.level; level = desc.level;
rootId = desc.rootId; rootId = desc.rootId;
rootName = desc.rootName; rootName = desc.rootName;
@ -1246,7 +1264,7 @@
rootName = desc.name; rootName = desc.name;
} }
return { return {
[Symbol.toStringTag]: "TestContext", [SymbolToStringTag]: "TestContext",
/** /**
* The current test name. * The current test name.
*/ */
@ -1264,7 +1282,7 @@
* @param maybeFn {((t: TestContext) => void | Promise<void>) | undefined} * @param maybeFn {((t: TestContext) => void | Promise<void>) | undefined}
*/ */
async step(nameOrFnOrOptions, maybeFn) { async step(nameOrFnOrOptions, maybeFn) {
if (testStates.get(desc.id).completed) { if (MapPrototypeGet(testStates, desc.id).completed) {
throw new Error( throw new Error(
"Cannot run test step after parent scope has finished execution. " + "Cannot run test step after parent scope has finished execution. " +
"Ensure any `.step(...)` calls are executed before their parent scope completes execution.", "Ensure any `.step(...)` calls are executed before their parent scope completes execution.",
@ -1273,9 +1291,7 @@
let stepDesc; let stepDesc;
if (typeof nameOrFnOrOptions === "string") { if (typeof nameOrFnOrOptions === "string") {
if ( if (!(ObjectPrototypeIsPrototypeOf(FunctionPrototype, maybeFn))) {
!Object.prototype.isPrototypeOf.call(Function.prototype, maybeFn)
) {
throw new TypeError("Expected function for second argument."); throw new TypeError("Expected function for second argument.");
} }
stepDesc = { stepDesc = {
@ -1331,15 +1347,16 @@
failed: false, failed: false,
completed: false, completed: false,
}; };
testStates.set(stepDesc.id, state); MapPrototypeSet(testStates, stepDesc.id, state);
testStates.get(stepDesc.parent.id).children.push( ArrayPrototypePush(
MapPrototypeGet(testStates, stepDesc.parent.id).children,
stepDesc, stepDesc,
); );
ops.op_test_event_step_wait(stepDesc.id); ops.op_test_event_step_wait(stepDesc.id);
const earlier = Date.now(); const earlier = DateNow();
const result = await stepDesc.fn(stepDesc); const result = await stepDesc.fn(stepDesc);
const elapsed = Date.now() - earlier; const elapsed = DateNow() - earlier;
state.failed = !!result.failed; state.failed = !!result.failed;
stepReportResult(stepDesc, result, elapsed); stepReportResult(stepDesc, result, elapsed);
return result == "ok"; return result == "ok";
@ -1373,4 +1390,3 @@
globalThis.Deno.bench = bench; globalThis.Deno.bench = bench;
globalThis.Deno.test = test; globalThis.Deno.test = test;
})();

View file

@ -637,13 +637,13 @@ impl CliMainWorkerFactory {
); );
if self.shared.subcommand.needs_test() { if self.shared.subcommand.needs_test() {
worker.js_runtime.execute_script_static( worker.js_runtime.lazy_load_es_module_from_code(
"ext:cli/40_testing.js", "ext:cli/40_testing.js",
include_str!("js/40_testing.js"), deno_core::FastString::StaticAscii(include_str!("js/40_testing.js")),
)?; )?;
worker.js_runtime.execute_script_static( worker.js_runtime.lazy_load_es_module_from_code(
"ext:cli/40_jupyter.js", "ext:cli/40_jupyter.js",
include_str!("js/40_jupyter.js"), deno_core::FastString::StaticAscii(include_str!("js/40_jupyter.js")),
)?; )?;
} }

View file

@ -1,6 +1,6 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
import { core, internals, primordials } from "ext:core/mod.js"; import { core, primordials } from "ext:core/mod.js";
const ops = core.ops; const ops = core.ops;
import { pathFromURL } from "ext:deno_web/00_infra.js"; import { pathFromURL } from "ext:deno_web/00_infra.js";
import { Event, EventTarget } from "ext:deno_web/02_event.js"; import { Event, EventTarget } from "ext:deno_web/02_event.js";
@ -290,6 +290,4 @@ function serializePermissions(permissions) {
return permissions; return permissions;
} }
internals.serializePermissions = serializePermissions;
export { Permissions, permissions, PermissionStatus, serializePermissions }; export { Permissions, permissions, PermissionStatus, serializePermissions };

View file

@ -1,6 +1,6 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
import { core, internals, primordials } from "ext:core/mod.js"; import { core, primordials } from "ext:core/mod.js";
const ops = core.ops; const ops = core.ops;
import { Event, EventTarget } from "ext:deno_web/02_event.js"; import { Event, EventTarget } from "ext:deno_web/02_event.js";
const { const {
@ -105,8 +105,6 @@ function execPath() {
return ops.op_exec_path(); return ops.op_exec_path();
} }
internals.setExitHandler = setExitHandler;
export { export {
env, env,
execPath, execPath,

View file

@ -43,7 +43,6 @@ use deno_fs::FileSystem;
use deno_http::DefaultHttpPropertyExtractor; use deno_http::DefaultHttpPropertyExtractor;
use deno_io::Stdio; use deno_io::Stdio;
use deno_kv::dynamic::MultiBackendDbHandler; use deno_kv::dynamic::MultiBackendDbHandler;
use deno_node::SUPPORTED_BUILTIN_NODE_MODULES_WITH_PREFIX;
use deno_tls::RootCertStoreProvider; use deno_tls::RootCertStoreProvider;
use deno_web::create_entangled_message_port; use deno_web::create_entangled_message_port;
use deno_web::BlobStore; use deno_web::BlobStore;
@ -523,11 +522,6 @@ impl WebWorker {
(None, None) (None, None)
}; };
// Clear extension modules from the module map, except preserve `node:*`
// modules as `node:` specifiers.
let preserve_snapshotted_modules =
Some(SUPPORTED_BUILTIN_NODE_MODULES_WITH_PREFIX);
let mut js_runtime = JsRuntime::new(RuntimeOptions { let mut js_runtime = JsRuntime::new(RuntimeOptions {
module_loader: Some(options.module_loader.clone()), module_loader: Some(options.module_loader.clone()),
startup_snapshot: options startup_snapshot: options
@ -539,7 +533,6 @@ impl WebWorker {
compiled_wasm_module_store: options.compiled_wasm_module_store.clone(), compiled_wasm_module_store: options.compiled_wasm_module_store.clone(),
extensions, extensions,
inspector: options.maybe_inspector_server.is_some(), inspector: options.maybe_inspector_server.is_some(),
preserve_snapshotted_modules,
feature_checker: Some(options.feature_checker.clone()), feature_checker: Some(options.feature_checker.clone()),
op_metrics_factory_fn, op_metrics_factory_fn,
..Default::default() ..Default::default()

View file

@ -39,7 +39,6 @@ use deno_fs::FileSystem;
use deno_http::DefaultHttpPropertyExtractor; use deno_http::DefaultHttpPropertyExtractor;
use deno_io::Stdio; use deno_io::Stdio;
use deno_kv::dynamic::MultiBackendDbHandler; use deno_kv::dynamic::MultiBackendDbHandler;
use deno_node::SUPPORTED_BUILTIN_NODE_MODULES_WITH_PREFIX;
use deno_tls::RootCertStoreProvider; use deno_tls::RootCertStoreProvider;
use deno_web::BlobStore; use deno_web::BlobStore;
use log::debug; use log::debug;
@ -420,11 +419,6 @@ impl MainWorker {
#[cfg(all(feature = "include_js_files_for_snapshotting", feature = "dont_create_runtime_snapshot", not(feature = "__runtime_js_sources")))] #[cfg(all(feature = "include_js_files_for_snapshotting", feature = "dont_create_runtime_snapshot", not(feature = "__runtime_js_sources")))]
options.startup_snapshot.as_ref().expect("Sources are not embedded, snapshotting was disabled and a user snapshot was not provided."); options.startup_snapshot.as_ref().expect("Sources are not embedded, snapshotting was disabled and a user snapshot was not provided.");
// Clear extension modules from the module map, except preserve `node:*`
// modules.
let preserve_snapshotted_modules =
Some(SUPPORTED_BUILTIN_NODE_MODULES_WITH_PREFIX);
let mut js_runtime = JsRuntime::new(RuntimeOptions { let mut js_runtime = JsRuntime::new(RuntimeOptions {
module_loader: Some(options.module_loader.clone()), module_loader: Some(options.module_loader.clone()),
startup_snapshot: options startup_snapshot: options
@ -437,7 +431,6 @@ impl MainWorker {
shared_array_buffer_store: options.shared_array_buffer_store.clone(), shared_array_buffer_store: options.shared_array_buffer_store.clone(),
compiled_wasm_module_store: options.compiled_wasm_module_store.clone(), compiled_wasm_module_store: options.compiled_wasm_module_store.clone(),
extensions, extensions,
preserve_snapshotted_modules,
inspector: options.maybe_inspector_server.is_some(), inspector: options.maybe_inspector_server.is_some(),
is_main: true, is_main: true,
feature_checker: Some(options.feature_checker.clone()), feature_checker: Some(options.feature_checker.clone()),