mirror of
https://github.com/denoland/deno.git
synced 2024-11-28 16:20:57 -05:00
perf: move jupyter esm out of main snapshot (#21163)
Towards https://github.com/denoland/deno/issues/21136
This commit is contained in:
parent
d342c0df71
commit
ab0c637425
8 changed files with 383 additions and 368 deletions
|
@ -206,7 +206,7 @@ pub struct ReplFlags {
|
||||||
pub is_default_command: bool,
|
pub is_default_command: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
#[derive(Clone, Debug, Eq, PartialEq, Default)]
|
||||||
pub struct RunFlags {
|
pub struct RunFlags {
|
||||||
pub script: String,
|
pub script: String,
|
||||||
pub watch: Option<WatchFlagsWithPaths>,
|
pub watch: Option<WatchFlagsWithPaths>,
|
||||||
|
@ -311,6 +311,10 @@ impl DenoSubcommand {
|
||||||
pub fn is_run(&self) -> bool {
|
pub fn is_run(&self) -> bool {
|
||||||
matches!(self, Self::Run(_))
|
matches!(self, Self::Run(_))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_test_or_jupyter(&self) -> bool {
|
||||||
|
matches!(self, Self::Test(_) | Self::Jupyter(_))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for DenoSubcommand {
|
impl Default for DenoSubcommand {
|
||||||
|
|
|
@ -332,7 +332,6 @@ deno_core::extension!(
|
||||||
esm = [
|
esm = [
|
||||||
dir "js",
|
dir "js",
|
||||||
"40_testing.js",
|
"40_testing.js",
|
||||||
"40_jupyter.js",
|
|
||||||
"99_main.js"
|
"99_main.js"
|
||||||
],
|
],
|
||||||
customizer = |ext: &mut deno_core::Extension| {
|
customizer = |ext: &mut deno_core::Extension| {
|
||||||
|
|
|
@ -634,6 +634,7 @@ impl CliFactory {
|
||||||
|
|
||||||
Ok(CliMainWorkerFactory::new(
|
Ok(CliMainWorkerFactory::new(
|
||||||
StorageKeyResolver::from_options(&self.options),
|
StorageKeyResolver::from_options(&self.options),
|
||||||
|
self.options.sub_command().clone(),
|
||||||
npm_resolver.clone(),
|
npm_resolver.clone(),
|
||||||
node_resolver.clone(),
|
node_resolver.clone(),
|
||||||
self.blob_store().clone(),
|
self.blob_store().clone(),
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
||||||
|
// deno-lint-ignore-file
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @module mod
|
* @module mod
|
||||||
|
@ -35,10 +36,9 @@
|
||||||
* }, { raw: true });
|
* }, { raw: true });
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
|
{
|
||||||
const core = globalThis.Deno.core;
|
const internals = Deno[Deno.internal];
|
||||||
|
const core = internals.core;
|
||||||
const internals = globalThis.__bootstrap.internals;
|
|
||||||
|
|
||||||
const $display = Symbol.for("Jupyter.display");
|
const $display = Symbol.for("Jupyter.display");
|
||||||
|
|
||||||
|
@ -428,3 +428,4 @@ function enableJupyter() {
|
||||||
}
|
}
|
||||||
|
|
||||||
internals.enableJupyter = enableJupyter;
|
internals.enableJupyter = enableJupyter;
|
||||||
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
|
||||||
import "ext:cli/40_testing.js";
|
import "ext:cli/40_testing.js";
|
||||||
import "ext:cli/40_jupyter.js";
|
|
||||||
import "ext:cli/runtime/js/99_main.js";
|
import "ext:cli/runtime/js/99_main.js";
|
||||||
|
|
|
@ -22,7 +22,6 @@ deno_core::extension!(cli,
|
||||||
esm = [
|
esm = [
|
||||||
dir "js",
|
dir "js",
|
||||||
"40_testing.js",
|
"40_testing.js",
|
||||||
"40_jupyter.js",
|
|
||||||
"99_main.js"
|
"99_main.js"
|
||||||
],
|
],
|
||||||
customizer = |ext: &mut deno_core::Extension| {
|
customizer = |ext: &mut deno_core::Extension| {
|
||||||
|
|
|
@ -438,6 +438,7 @@ pub async fn run(
|
||||||
});
|
});
|
||||||
let worker_factory = CliMainWorkerFactory::new(
|
let worker_factory = CliMainWorkerFactory::new(
|
||||||
StorageKeyResolver::empty(),
|
StorageKeyResolver::empty(),
|
||||||
|
crate::args::DenoSubcommand::Run(Default::default()),
|
||||||
npm_resolver,
|
npm_resolver,
|
||||||
node_resolver,
|
node_resolver,
|
||||||
Default::default(),
|
Default::default(),
|
||||||
|
|
|
@ -46,6 +46,7 @@ use deno_semver::package::PackageReqReference;
|
||||||
use tokio::select;
|
use tokio::select;
|
||||||
|
|
||||||
use crate::args::package_json::PackageJsonDeps;
|
use crate::args::package_json::PackageJsonDeps;
|
||||||
|
use crate::args::DenoSubcommand;
|
||||||
use crate::args::StorageKeyResolver;
|
use crate::args::StorageKeyResolver;
|
||||||
use crate::emit::Emitter;
|
use crate::emit::Emitter;
|
||||||
use crate::errors;
|
use crate::errors;
|
||||||
|
@ -107,6 +108,7 @@ pub struct CliMainWorkerOptions {
|
||||||
|
|
||||||
struct SharedWorkerState {
|
struct SharedWorkerState {
|
||||||
options: CliMainWorkerOptions,
|
options: CliMainWorkerOptions,
|
||||||
|
subcommand: DenoSubcommand,
|
||||||
storage_key_resolver: StorageKeyResolver,
|
storage_key_resolver: StorageKeyResolver,
|
||||||
npm_resolver: Arc<dyn CliNpmResolver>,
|
npm_resolver: Arc<dyn CliNpmResolver>,
|
||||||
node_resolver: Arc<NodeResolver>,
|
node_resolver: Arc<NodeResolver>,
|
||||||
|
@ -372,6 +374,7 @@ impl CliMainWorkerFactory {
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub fn new(
|
pub fn new(
|
||||||
storage_key_resolver: StorageKeyResolver,
|
storage_key_resolver: StorageKeyResolver,
|
||||||
|
subcommand: DenoSubcommand,
|
||||||
npm_resolver: Arc<dyn CliNpmResolver>,
|
npm_resolver: Arc<dyn CliNpmResolver>,
|
||||||
node_resolver: Arc<NodeResolver>,
|
node_resolver: Arc<NodeResolver>,
|
||||||
blob_store: Arc<BlobStore>,
|
blob_store: Arc<BlobStore>,
|
||||||
|
@ -388,6 +391,7 @@ impl CliMainWorkerFactory {
|
||||||
Self {
|
Self {
|
||||||
shared: Arc::new(SharedWorkerState {
|
shared: Arc::new(SharedWorkerState {
|
||||||
options,
|
options,
|
||||||
|
subcommand,
|
||||||
storage_key_resolver,
|
storage_key_resolver,
|
||||||
npm_resolver,
|
npm_resolver,
|
||||||
node_resolver,
|
node_resolver,
|
||||||
|
@ -600,12 +604,19 @@ impl CliMainWorkerFactory {
|
||||||
skip_op_registration: shared.options.skip_op_registration,
|
skip_op_registration: shared.options.skip_op_registration,
|
||||||
};
|
};
|
||||||
|
|
||||||
let worker = MainWorker::bootstrap_from_options(
|
let mut worker = MainWorker::bootstrap_from_options(
|
||||||
main_module.clone(),
|
main_module.clone(),
|
||||||
permissions,
|
permissions,
|
||||||
options,
|
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 {
|
Ok(CliMainWorker {
|
||||||
main_module,
|
main_module,
|
||||||
is_main_cjs,
|
is_main_cjs,
|
||||||
|
|
Loading…
Reference in a new issue