0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-03-03 17:34:47 -05:00

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,215 +36,181 @@
* }, { 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");
/** Escape copied from https://deno.land/std@0.192.0/html/entities.ts */ /** Escape copied from https://deno.land/std@0.192.0/html/entities.ts */
const rawToEntityEntries = [ const rawToEntityEntries = [
["&", "&amp;"], ["&", "&amp;"],
["<", "&lt;"], ["<", "&lt;"],
[">", "&gt;"], [">", "&gt;"],
['"', "&quot;"], ['"', "&quot;"],
["'", "&#39;"], ["'", "&#39;"],
]; ];
const rawToEntity = new Map(rawToEntityEntries); const rawToEntity = new Map(rawToEntityEntries);
const rawRe = new RegExp(`[${[...rawToEntity.keys()].join("")}]`, "g"); const rawRe = new RegExp(`[${[...rawToEntity.keys()].join("")}]`, "g");
function escapeHTML(str) { function escapeHTML(str) {
return str.replaceAll( return str.replaceAll(
rawRe, rawRe,
(m) => rawToEntity.has(m) ? rawToEntity.get(m) : m, (m) => rawToEntity.has(m) ? rawToEntity.get(m) : m,
); );
}
/** Duck typing our way to common visualization and tabular libraries */
/** Vegalite */
function isVegaLike(obj) {
return obj !== null && typeof obj === "object" && "toSpec" in obj;
}
function extractVega(obj) {
const spec = obj.toSpec();
if (!("$schema" in spec)) {
return null;
} }
if (typeof spec !== "object") {
return null;
}
let mediaType = "application/vnd.vega.v5+json";
if (spec.$schema === "https://vega.github.io/schema/vega-lite/v4.json") {
mediaType = "application/vnd.vegalite.v4+json";
} else if (
spec.$schema === "https://vega.github.io/schema/vega-lite/v5.json"
) {
mediaType = "application/vnd.vegalite.v5+json";
}
return {
[mediaType]: spec,
};
}
/** Polars */
function isDataFrameLike(obj) {
const isObject = obj !== null && typeof obj === "object";
if (!isObject) {
return false;
}
const df = obj;
return df.schema !== void 0 && typeof df.schema === "object" &&
df.head !== void 0 && typeof df.head === "function" &&
df.toRecords !== void 0 && typeof df.toRecords === "function";
}
/**
* Map Polars DataType to JSON Schema data types.
* @param dataType - The Polars DataType.
* @returns The corresponding JSON Schema data type.
*/
function mapPolarsTypeToJSONSchema(colType) {
const typeMapping = {
Null: "null",
Bool: "boolean",
Int8: "integer",
Int16: "integer",
Int32: "integer",
Int64: "integer",
UInt8: "integer",
UInt16: "integer",
UInt32: "integer",
UInt64: "integer",
Float32: "number",
Float64: "number",
Date: "string",
Datetime: "string",
Utf8: "string",
Categorical: "string",
List: "array",
Struct: "object",
};
// These colTypes are weird. When you console.dir or console.log them
// they show a `DataType` field, however you can't access it directly until you
// convert it to JSON
const dataType = colType.toJSON()["DataType"];
return typeMapping[dataType] || "string";
}
/** Duck typing our way to common visualization and tabular libraries */ function extractDataFrame(df) {
/** Vegalite */ const fields = [];
function isVegaLike(obj) { const schema = {
return obj !== null && typeof obj === "object" && "toSpec" in obj; fields,
} };
function extractVega(obj) { let data = [];
const spec = obj.toSpec(); // Convert DataFrame schema to Tabular DataResource schema
if (!("$schema" in spec)) { for (const [colName, colType] of Object.entries(df.schema)) {
return null; const dataType = mapPolarsTypeToJSONSchema(colType);
} schema.fields.push({
if (typeof spec !== "object") { name: colName,
return null; type: dataType,
} });
let mediaType = "application/vnd.vega.v5+json";
if (spec.$schema === "https://vega.github.io/schema/vega-lite/v4.json") {
mediaType = "application/vnd.vegalite.v4+json";
} else if (
spec.$schema === "https://vega.github.io/schema/vega-lite/v5.json"
) {
mediaType = "application/vnd.vegalite.v5+json";
}
return {
[mediaType]: spec,
};
}
/** Polars */
function isDataFrameLike(obj) {
const isObject = obj !== null && typeof obj === "object";
if (!isObject) {
return false;
}
const df = obj;
return df.schema !== void 0 && typeof df.schema === "object" &&
df.head !== void 0 && typeof df.head === "function" &&
df.toRecords !== void 0 && typeof df.toRecords === "function";
}
/**
* Map Polars DataType to JSON Schema data types.
* @param dataType - The Polars DataType.
* @returns The corresponding JSON Schema data type.
*/
function mapPolarsTypeToJSONSchema(colType) {
const typeMapping = {
Null: "null",
Bool: "boolean",
Int8: "integer",
Int16: "integer",
Int32: "integer",
Int64: "integer",
UInt8: "integer",
UInt16: "integer",
UInt32: "integer",
UInt64: "integer",
Float32: "number",
Float64: "number",
Date: "string",
Datetime: "string",
Utf8: "string",
Categorical: "string",
List: "array",
Struct: "object",
};
// These colTypes are weird. When you console.dir or console.log them
// they show a `DataType` field, however you can't access it directly until you
// convert it to JSON
const dataType = colType.toJSON()["DataType"];
return typeMapping[dataType] || "string";
} }
// Convert DataFrame data to row-oriented JSON
//
// TODO(rgbkrk): Determine how to get the polars format max rows
// Since pl.setTblRows just sets env var POLARS_FMT_MAX_ROWS,
// we probably just have to pick a number for now.
//
function extractDataFrame(df) { data = df.head(50).toRecords();
const fields = []; let htmlTable = "<table>";
const schema = { htmlTable += "<thead><tr>";
fields, schema.fields.forEach((field) => {
}; htmlTable += `<th>${escapeHTML(String(field.name))}</th>`;
let data = []; });
// Convert DataFrame schema to Tabular DataResource schema htmlTable += "</tr></thead>";
for (const [colName, colType] of Object.entries(df.schema)) { htmlTable += "<tbody>";
const dataType = mapPolarsTypeToJSONSchema(colType); df.head(10).toRecords().forEach((row) => {
schema.fields.push({ htmlTable += "<tr>";
name: colName,
type: dataType,
});
}
// Convert DataFrame data to row-oriented JSON
//
// TODO(rgbkrk): Determine how to get the polars format max rows
// Since pl.setTblRows just sets env var POLARS_FMT_MAX_ROWS,
// we probably just have to pick a number for now.
//
data = df.head(50).toRecords();
let htmlTable = "<table>";
htmlTable += "<thead><tr>";
schema.fields.forEach((field) => { schema.fields.forEach((field) => {
htmlTable += `<th>${escapeHTML(String(field.name))}</th>`; htmlTable += `<td>${escapeHTML(String(row[field.name]))}</td>`;
}); });
htmlTable += "</tr></thead>"; htmlTable += "</tr>";
htmlTable += "<tbody>"; });
df.head(10).toRecords().forEach((row) => { htmlTable += "</tbody></table>";
htmlTable += "<tr>"; return {
schema.fields.forEach((field) => { "application/vnd.dataresource+json": { data, schema },
htmlTable += `<td>${escapeHTML(String(row[field.name]))}</td>`; "text/html": htmlTable,
}); };
htmlTable += "</tr>"; }
});
htmlTable += "</tbody></table>"; /** Canvas */
return { function isCanvasLike(obj) {
"application/vnd.dataresource+json": { data, schema }, return obj !== null && typeof obj === "object" && "toDataURL" in obj;
"text/html": htmlTable, }
};
/** Possible HTML and SVG Elements */
function isSVGElementLike(obj) {
return obj !== null && typeof obj === "object" && "outerHTML" in obj &&
typeof obj.outerHTML === "string" && obj.outerHTML.startsWith("<svg");
}
function isHTMLElementLike(obj) {
return obj !== null && typeof obj === "object" && "outerHTML" in obj &&
typeof obj.outerHTML === "string";
}
/** Check to see if an object already contains a `Symbol.for("Jupyter.display") */
function hasDisplaySymbol(obj) {
return obj !== null && typeof obj === "object" && $display in obj &&
typeof obj[$display] === "function";
}
function makeDisplayable(obj) {
return {
[$display]: () => obj,
};
}
/**
* Format an object for displaying in Deno
*
* @param obj - The object to be displayed
* @returns MediaBundle
*/
async function format(obj) {
if (hasDisplaySymbol(obj)) {
return await obj[$display]();
} }
if (typeof obj !== "object") {
/** Canvas */
function isCanvasLike(obj) {
return obj !== null && typeof obj === "object" && "toDataURL" in obj;
}
/** Possible HTML and SVG Elements */
function isSVGElementLike(obj) {
return obj !== null && typeof obj === "object" && "outerHTML" in obj &&
typeof obj.outerHTML === "string" && obj.outerHTML.startsWith("<svg");
}
function isHTMLElementLike(obj) {
return obj !== null && typeof obj === "object" && "outerHTML" in obj &&
typeof obj.outerHTML === "string";
}
/** Check to see if an object already contains a `Symbol.for("Jupyter.display") */
function hasDisplaySymbol(obj) {
return obj !== null && typeof obj === "object" && $display in obj &&
typeof obj[$display] === "function";
}
function makeDisplayable(obj) {
return {
[$display]: () => obj,
};
}
/**
* Format an object for displaying in Deno
*
* @param obj - The object to be displayed
* @returns MediaBundle
*/
async function format(obj) {
if (hasDisplaySymbol(obj)) {
return await obj[$display]();
}
if (typeof obj !== "object") {
return {
"text/plain": Deno[Deno.internal].inspectArgs(["%o", obj], {
colors: !Deno.noColor,
}),
};
}
if (isCanvasLike(obj)) {
const dataURL = obj.toDataURL();
const parts = dataURL.split(",");
const mime = parts[0].split(":")[1].split(";")[0];
const data = parts[1];
return {
[mime]: data,
};
}
if (isVegaLike(obj)) {
return extractVega(obj);
}
if (isDataFrameLike(obj)) {
return extractDataFrame(obj);
}
if (isSVGElementLike(obj)) {
return {
"image/svg+xml": obj.outerHTML,
};
}
if (isHTMLElementLike(obj)) {
return {
"text/html": obj.outerHTML,
};
}
return { return {
"text/plain": Deno[Deno.internal].inspectArgs(["%o", obj], { "text/plain": Deno[Deno.internal].inspectArgs(["%o", obj], {
colors: !Deno.noColor, colors: !Deno.noColor,
@ -252,180 +218,211 @@
}; };
} }
/** if (isCanvasLike(obj)) {
* This function creates a tagged template function for a given media type. const dataURL = obj.toDataURL();
* The tagged template function takes a template string and returns a displayable object. const parts = dataURL.split(",");
* const mime = parts[0].split(":")[1].split(";")[0];
* @param mediatype - The media type for the tagged template function. const data = parts[1];
* @returns A function that takes a template string and returns a displayable object. return {
*/ [mime]: data,
function createTaggedTemplateDisplayable(mediatype) {
return (strings, ...values) => {
const payload = strings.reduce(
(acc, string, i) =>
acc + string + (values[i] !== undefined ? values[i] : ""),
"",
);
return makeDisplayable({ [mediatype]: payload });
}; };
} }
if (isVegaLike(obj)) {
return extractVega(obj);
}
if (isDataFrameLike(obj)) {
return extractDataFrame(obj);
}
if (isSVGElementLike(obj)) {
return {
"image/svg+xml": obj.outerHTML,
};
}
if (isHTMLElementLike(obj)) {
return {
"text/html": obj.outerHTML,
};
}
return {
"text/plain": Deno[Deno.internal].inspectArgs(["%o", obj], {
colors: !Deno.noColor,
}),
};
}
/** /**
* Show Markdown in Jupyter frontends with a tagged template function. * This function creates a tagged template function for a given media type.
* * The tagged template function takes a template string and returns a displayable object.
* Takes a template string and returns a displayable object for Jupyter frontends. *
* * @param mediatype - The media type for the tagged template function.
* @example * @returns A function that takes a template string and returns a displayable object.
* Create a Markdown view. */
* function createTaggedTemplateDisplayable(mediatype) {
* ```typescript return (strings, ...values) => {
* md`# Notebooks in TypeScript via Deno ![Deno logo](https://github.com/denoland.png?size=32) const payload = strings.reduce(
* (acc, string, i) =>
* * TypeScript ${Deno.version.typescript} acc + string + (values[i] !== undefined ? values[i] : ""),
* * V8 ${Deno.version.v8} "",
* * Deno ${Deno.version.deno} );
* return makeDisplayable({ [mediatype]: payload });
* Interactive compute with Jupyter _built into Deno_! };
* ` }
* ```
*/
const md = createTaggedTemplateDisplayable("text/markdown");
/** /**
* Show HTML in Jupyter frontends with a tagged template function. * Show Markdown in Jupyter frontends with a tagged template function.
* *
* Takes a template string and returns a displayable object for Jupyter frontends. * Takes a template string and returns a displayable object for Jupyter frontends.
* *
* @example * @example
* Create an HTML view. * Create a Markdown view.
* ```typescript *
* html`<h1>Hello, world!</h1>` * ```typescript
* ``` * md`# Notebooks in TypeScript via Deno ![Deno logo](https://github.com/denoland.png?size=32)
*/ *
const html = createTaggedTemplateDisplayable("text/html"); * * TypeScript ${Deno.version.typescript}
/** * * V8 ${Deno.version.v8}
* SVG Tagged Template Function. * * Deno ${Deno.version.deno}
* *
* Takes a template string and returns a displayable object for Jupyter frontends. * Interactive compute with Jupyter _built into Deno_!
* * `
* Example usage: * ```
* */
* svg`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"> const md = createTaggedTemplateDisplayable("text/markdown");
* <circle cx="50" cy="50" r="40" stroke="green" stroke-width="4" fill="yellow" />
* </svg>`
*/
const svg = createTaggedTemplateDisplayable("image/svg+xml");
function isMediaBundle(obj) { /**
if (obj == null || typeof obj !== "object" || Array.isArray(obj)) { * Show HTML in Jupyter frontends with a tagged template function.
*
* Takes a template string and returns a displayable object for Jupyter frontends.
*
* @example
* Create an HTML view.
* ```typescript
* html`<h1>Hello, world!</h1>`
* ```
*/
const html = createTaggedTemplateDisplayable("text/html");
/**
* SVG Tagged Template Function.
*
* Takes a template string and returns a displayable object for Jupyter frontends.
*
* Example usage:
*
* svg`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
* <circle cx="50" cy="50" r="40" stroke="green" stroke-width="4" fill="yellow" />
* </svg>`
*/
const svg = createTaggedTemplateDisplayable("image/svg+xml");
function isMediaBundle(obj) {
if (obj == null || typeof obj !== "object" || Array.isArray(obj)) {
return false;
}
for (const key in obj) {
if (typeof key !== "string") {
return false; return false;
} }
for (const key in obj) { }
if (typeof key !== "string") { return true;
return false; }
}
} async function formatInner(obj, raw) {
return true; if (raw && isMediaBundle(obj)) {
return obj;
} else {
return await format(obj);
}
}
internals.jupyter = { formatInner };
function enableJupyter() {
const {
op_jupyter_broadcast,
} = core.ensureFastOps();
async function broadcast(
msgType,
content,
{ metadata = {}, buffers = [] } = {},
) {
await op_jupyter_broadcast(msgType, content, metadata, buffers);
} }
async function formatInner(obj, raw) { async function broadcastResult(executionCount, result) {
if (raw && isMediaBundle(obj)) { try {
return obj; if (result === undefined) {
} else { return;
return await format(obj);
}
}
internals.jupyter = { formatInner };
function enableJupyter() {
const {
op_jupyter_broadcast,
} = core.ensureFastOps();
async function broadcast(
msgType,
content,
{ metadata = {}, buffers = [] } = {},
) {
await op_jupyter_broadcast(msgType, content, metadata, buffers);
}
async function broadcastResult(executionCount, result) {
try {
if (result === undefined) {
return;
}
const data = await format(result);
await broadcast("execute_result", {
execution_count: executionCount,
data,
metadata: {},
});
} catch (err) {
if (err instanceof Error) {
const stack = err.stack || "";
await broadcast("error", {
ename: err.name,
evalue: err.message,
traceback: stack.split("\n"),
});
} else if (typeof err == "string") {
await broadcast("error", {
ename: "Error",
evalue: err,
traceback: [],
});
} else {
await broadcast("error", {
ename: "Error",
evalue:
"An error occurred while formatting a result, but it could not be identified",
traceback: [],
});
}
} }
}
internals.jupyter.broadcastResult = broadcastResult; const data = await format(result);
await broadcast("execute_result", {
/** execution_count: executionCount,
* Display function for Jupyter Deno Kernel. data,
* Mimics the behavior of IPython's `display(obj, raw=True)` function to allow
* asynchronous displaying of objects in Jupyter.
*
* @param obj - The object to be displayed
* @param options - Display options
*/
async function display(obj, options = { raw: false, update: false }) {
const bundle = await formatInner(obj, options.raw);
let messageType = "display_data";
if (options.update) {
messageType = "update_display_data";
}
let transient = {};
if (options.display_id) {
transient = { display_id: options.display_id };
}
await broadcast(messageType, {
data: bundle,
metadata: {}, metadata: {},
transient,
}); });
return; } catch (err) {
if (err instanceof Error) {
const stack = err.stack || "";
await broadcast("error", {
ename: err.name,
evalue: err.message,
traceback: stack.split("\n"),
});
} else if (typeof err == "string") {
await broadcast("error", {
ename: "Error",
evalue: err,
traceback: [],
});
} else {
await broadcast("error", {
ename: "Error",
evalue:
"An error occurred while formatting a result, but it could not be identified",
traceback: [],
});
}
} }
globalThis.Deno.jupyter = {
broadcast,
display,
format,
md,
html,
svg,
$display,
};
} }
internals.enableJupyter = enableJupyter; internals.jupyter.broadcastResult = broadcastResult;
})();
/**
* Display function for Jupyter Deno Kernel.
* Mimics the behavior of IPython's `display(obj, raw=True)` function to allow
* asynchronous displaying of objects in Jupyter.
*
* @param obj - The object to be displayed
* @param options - Display options
*/
async function display(obj, options = { raw: false, update: false }) {
const bundle = await formatInner(obj, options.raw);
let messageType = "display_data";
if (options.update) {
messageType = "update_display_data";
}
let transient = {};
if (options.display_id) {
transient = { display_id: options.display_id };
}
await broadcast(messageType, {
data: bundle,
metadata: {},
transient,
});
return;
}
globalThis.Deno.jupyter = {
broadcast,
display,
format,
md,
html,
svg,
$display,
};
}
internals.enableJupyter = enableJupyter;

File diff suppressed because it is too large Load diff

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()),