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:
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,
|
||||
}
|
||||
|
||||
#[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 {
|
||||
|
|
|
@ -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| {
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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| {
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue