From b1c6142f741a507ba6594ab174065e00213100b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Fri, 30 Aug 2024 18:58:58 +0100 Subject: BREAKING: `DENO_FUTURE=1` by default, or welcome to Deno 2.0 (#25213) This commit effectively turns Deno into Deno 2.0. This is done by forcing `DENO_FUTURE=1` env var, that was available in the past few months to try Deno 2 changes. This commit contains several breaking changes scheduled for Deno 2: - all deprecated JavaScript APIs are not available any more, mostly `Deno.*` APIs - `window` global is removed - FFI, WebGPU and FS APIs are now stable and don't require `--unstable-*` flags - import assertions are no longer supported - "bring your own node modules" is enabled by default This is the first commit in a series that are scheduled before the Deno 2 release. Follow up work is tracked in https://github.com/denoland/deno/issues/25241. --------- Co-authored-by: Asher Gomez Co-authored-by: Nayeem Rahman Co-authored-by: Nathan Whitaker --- cli/lsp/config.rs | 30 +++++++++++++++++++++++++----- cli/lsp/language_server.rs | 5 ----- 2 files changed, 25 insertions(+), 10 deletions(-) (limited to 'cli/lsp') diff --git a/cli/lsp/config.rs b/cli/lsp/config.rs index ec2690506..4ac9b4d0a 100644 --- a/cli/lsp/config.rs +++ b/cli/lsp/config.rs @@ -1398,7 +1398,12 @@ impl ConfigData { || ( *DENO_FUTURE && member_dir.workspace.package_jsons().next().is_some() - && member_dir.workspace.node_modules_dir().is_none() + && member_dir + .workspace + .node_modules_mode() + .ok() + .flatten() + .is_none() // TODO(2.0): remove ); if byonm { @@ -1874,13 +1879,28 @@ fn resolve_node_modules_dir( // `nodeModulesDir: true` setting in the deno.json file. This is to // reduce the chance of modifying someone's node_modules directory // without them having asked us to do so. - let explicitly_disabled = workspace.node_modules_dir() == Some(false); + let node_modules_mode = workspace.node_modules_mode().ok().flatten(); + let node_modules_dir_option = workspace.node_modules_dir(); + let explicitly_disabled = if *DENO_FUTURE { + node_modules_mode == Some(NodeModulesMode::GlobalAuto) + } else { + node_modules_dir_option == Some(false) + }; if explicitly_disabled { return None; } - let enabled = byonm - || workspace.node_modules_dir() == Some(true) - || workspace.vendor_dir_path().is_some(); + let enabled = if *DENO_FUTURE { + byonm + || node_modules_mode + .map(|m| m.uses_node_modules_dir()) + .unwrap_or(false) + || workspace.vendor_dir_path().is_some() + } else { + byonm + || workspace.node_modules_dir() == Some(true) + || workspace.vendor_dir_path().is_some() + }; + if !enabled { return None; } diff --git a/cli/lsp/language_server.rs b/cli/lsp/language_server.rs index 37e1aa0be..05c54dfc6 100644 --- a/cli/lsp/language_server.rs +++ b/cli/lsp/language_server.rs @@ -3611,11 +3611,6 @@ impl Inner { .as_ref() .map(|url| url.to_string()) }), - node_modules_dir: Some( - config_data - .and_then(|d| d.node_modules_dir.as_ref()) - .is_some(), - ), // bit of a hack to force the lsp to cache the @types/node package type_check_mode: crate::args::TypeCheckMode::Local, ..Default::default() -- cgit v1.2.3