1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-24 15:19:26 -05:00

perf: move jupyter esm out of main snapshot (#21163)

Towards https://github.com/denoland/deno/issues/21136
This commit is contained in:
Divy Srivastava 2023-11-14 13:06:00 -08:00 committed by GitHub
parent d342c0df71
commit ab0c637425
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 383 additions and 368 deletions

View file

@ -206,7 +206,7 @@ pub struct ReplFlags {
pub is_default_command: bool,
}
#[derive(Clone, Debug, Eq, PartialEq)]
#[derive(Clone, Debug, Eq, PartialEq, Default)]
pub struct RunFlags {
pub script: String,
pub watch: Option<WatchFlagsWithPaths>,
@ -311,6 +311,10 @@ impl DenoSubcommand {
pub fn is_run(&self) -> bool {
matches!(self, Self::Run(_))
}
pub fn is_test_or_jupyter(&self) -> bool {
matches!(self, Self::Test(_) | Self::Jupyter(_))
}
}
impl Default for DenoSubcommand {

View file

@ -332,7 +332,6 @@ deno_core::extension!(
esm = [
dir "js",
"40_testing.js",
"40_jupyter.js",
"99_main.js"
],
customizer = |ext: &mut deno_core::Extension| {

View file

@ -634,6 +634,7 @@ impl CliFactory {
Ok(CliMainWorkerFactory::new(
StorageKeyResolver::from_options(&self.options),
self.options.sub_command().clone(),
npm_resolver.clone(),
node_resolver.clone(),
self.blob_store().clone(),

View file

@ -1,4 +1,5 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
// deno-lint-ignore-file
/*
* @module mod
@ -35,10 +36,9 @@
* }, { raw: true });
* ```
*/
const core = globalThis.Deno.core;
const internals = globalThis.__bootstrap.internals;
{
const internals = Deno[Deno.internal];
const core = internals.core;
const $display = Symbol.for("Jupyter.display");
@ -428,3 +428,4 @@ function enableJupyter() {
}
internals.enableJupyter = enableJupyter;
}

View file

@ -1,4 +1,3 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
import "ext:cli/40_testing.js";
import "ext:cli/40_jupyter.js";
import "ext:cli/runtime/js/99_main.js";

View file

@ -22,7 +22,6 @@ deno_core::extension!(cli,
esm = [
dir "js",
"40_testing.js",
"40_jupyter.js",
"99_main.js"
],
customizer = |ext: &mut deno_core::Extension| {

View file

@ -438,6 +438,7 @@ pub async fn run(
});
let worker_factory = CliMainWorkerFactory::new(
StorageKeyResolver::empty(),
crate::args::DenoSubcommand::Run(Default::default()),
npm_resolver,
node_resolver,
Default::default(),

View file

@ -46,6 +46,7 @@ use deno_semver::package::PackageReqReference;
use tokio::select;
use crate::args::package_json::PackageJsonDeps;
use crate::args::DenoSubcommand;
use crate::args::StorageKeyResolver;
use crate::emit::Emitter;
use crate::errors;
@ -107,6 +108,7 @@ pub struct CliMainWorkerOptions {
struct SharedWorkerState {
options: CliMainWorkerOptions,
subcommand: DenoSubcommand,
storage_key_resolver: StorageKeyResolver,
npm_resolver: Arc<dyn CliNpmResolver>,
node_resolver: Arc<NodeResolver>,
@ -372,6 +374,7 @@ impl CliMainWorkerFactory {
#[allow(clippy::too_many_arguments)]
pub fn new(
storage_key_resolver: StorageKeyResolver,
subcommand: DenoSubcommand,
npm_resolver: Arc<dyn CliNpmResolver>,
node_resolver: Arc<NodeResolver>,
blob_store: Arc<BlobStore>,
@ -388,6 +391,7 @@ impl CliMainWorkerFactory {
Self {
shared: Arc::new(SharedWorkerState {
options,
subcommand,
storage_key_resolver,
npm_resolver,
node_resolver,
@ -600,12 +604,19 @@ impl CliMainWorkerFactory {
skip_op_registration: shared.options.skip_op_registration,
};
let worker = MainWorker::bootstrap_from_options(
let mut worker = MainWorker::bootstrap_from_options(
main_module.clone(),
permissions,
options,
);
if self.shared.subcommand.is_test_or_jupyter() {
worker.js_runtime.execute_script_static(
"40_jupyter.js",
include_str!("js/40_jupyter.js"),
)?;
}
Ok(CliMainWorker {
main_module,
is_main_cjs,