diff --git a/cli/graph_util.rs b/cli/graph_util.rs index 46257cf785bab4..5ab6c3a33edb58 100644 --- a/cli/graph_util.rs +++ b/cli/graph_util.rs @@ -6,6 +6,7 @@ use crate::args::CliLockfile; use crate::args::CliOptions; use crate::args::DENO_DISABLE_PEDANTIC_NODE_WARNINGS; use crate::cache; +use crate::cache::EsmOrCjsChecker; use crate::cache::GlobalHttpCache; use crate::cache::ModuleInfoCache; use crate::cache::ParsedSourceCache; @@ -14,6 +15,7 @@ use crate::errors::get_error_class_name; use crate::file_fetcher::FileFetcher; use crate::npm::CliNpmResolver; use crate::resolver::CliGraphResolver; +use crate::resolver::CliNodeResolver; use crate::resolver::CliSloppyImportsResolver; use crate::resolver::SloppyImportsCachedFs; use crate::tools::check; @@ -48,7 +50,6 @@ use deno_runtime::deno_permissions::PermissionsContainer; use deno_semver::jsr::JsrDepPackageReq; use deno_semver::package::PackageNv; use import_map::ImportMapError; -use node_resolver::InNpmPackageChecker; use std::collections::HashSet; use std::error::Error; use std::ops::Deref; @@ -378,51 +379,54 @@ pub struct BuildFastCheckGraphOptions<'a> { } pub struct ModuleGraphBuilder { + options: Arc, caches: Arc, - cli_options: Arc, - file_fetcher: Arc, + esm_or_cjs_checker: Arc, fs: Arc, - global_http_cache: Arc, - in_npm_pkg_checker: Arc, - lockfile: Option>, - maybe_file_watcher_reporter: Option, - module_info_cache: Arc, + resolver: Arc, + node_resolver: Arc, npm_resolver: Arc, + module_info_cache: Arc, parsed_source_cache: Arc, - resolver: Arc, + lockfile: Option>, + maybe_file_watcher_reporter: Option, + file_fetcher: Arc, + global_http_cache: Arc, root_permissions_container: PermissionsContainer, } impl ModuleGraphBuilder { #[allow(clippy::too_many_arguments)] pub fn new( + options: Arc, caches: Arc, - cli_options: Arc, - file_fetcher: Arc, + esm_or_cjs_checker: Arc, fs: Arc, - global_http_cache: Arc, - in_npm_pkg_checker: Arc, - lockfile: Option>, - maybe_file_watcher_reporter: Option, - module_info_cache: Arc, + resolver: Arc, + node_resolver: Arc, npm_resolver: Arc, + module_info_cache: Arc, parsed_source_cache: Arc, - resolver: Arc, + lockfile: Option>, + maybe_file_watcher_reporter: Option, + file_fetcher: Arc, + global_http_cache: Arc, root_permissions_container: PermissionsContainer, ) -> Self { Self { + options, caches, - cli_options, - file_fetcher, + esm_or_cjs_checker, fs, - global_http_cache, - in_npm_pkg_checker, - lockfile, - maybe_file_watcher_reporter, - module_info_cache, + resolver, + node_resolver, npm_resolver, + module_info_cache, parsed_source_cache, - resolver, + lockfile, + maybe_file_watcher_reporter, + file_fetcher, + global_http_cache, root_permissions_container, } } @@ -508,11 +512,13 @@ impl ModuleGraphBuilder { } let maybe_imports = if options.graph_kind.include_types() { - self.cli_options.to_compiler_option_types()? + self.options.to_compiler_option_types()? } else { Vec::new() }; - let analyzer = self.module_info_cache.as_module_analyzer(); + let analyzer = self + .module_info_cache + .as_module_analyzer(&self.parsed_source_cache); let mut loader = match options.loader { Some(loader) => MutLoaderRef::Borrowed(loader), None => MutLoaderRef::Owned(self.create_graph_loader()), @@ -560,7 +566,7 @@ impl ModuleGraphBuilder { // ensure an "npm install" is done if the user has explicitly // opted into using a node_modules directory if self - .cli_options + .options .node_modules_dir()? .map(|m| m.uses_node_modules_dir()) .unwrap_or(false) @@ -671,10 +677,10 @@ impl ModuleGraphBuilder { graph.build_fast_check_type_graph( deno_graph::BuildFastCheckTypeGraphOptions { - es_parser: Some(&parser), + jsr_url_provider: &CliJsrUrlProvider, fast_check_cache: fast_check_cache.as_ref().map(|c| c as _), fast_check_dts: false, - jsr_url_provider: &CliJsrUrlProvider, + module_parser: Some(&parser), resolver: Some(graph_resolver), npm_resolver: Some(&graph_npm_resolver), workspace_fast_check: options.workspace_fast_check, @@ -693,18 +699,20 @@ impl ModuleGraphBuilder { permissions: PermissionsContainer, ) -> cache::FetchCacher { cache::FetchCacher::new( + self.esm_or_cjs_checker.clone(), self.file_fetcher.clone(), - self.fs.clone(), self.global_http_cache.clone(), - self.in_npm_pkg_checker.clone(), + self.node_resolver.clone(), + self.npm_resolver.clone(), self.module_info_cache.clone(), cache::FetchCacherOptions { - file_header_overrides: self.cli_options.resolve_file_header_overrides(), + file_header_overrides: self.options.resolve_file_header_overrides(), permissions, is_deno_publish: matches!( - self.cli_options.sub_command(), + self.options.sub_command(), crate::args::DenoSubcommand::Publish { .. } ), + unstable_detect_cjs: self.options.unstable_detect_cjs(), }, ) } @@ -729,12 +737,12 @@ impl ModuleGraphBuilder { &self.fs, roots, GraphValidOptions { - kind: if self.cli_options.type_check_mode().is_true() { + kind: if self.options.type_check_mode().is_true() { GraphKind::All } else { GraphKind::CodeOnly }, - check_js: self.cli_options.check_js(), + check_js: self.options.check_js(), exit_integrity_errors: true, }, ) @@ -749,7 +757,8 @@ pub fn enhanced_resolution_error_message(error: &ResolutionError) -> String { get_resolution_error_bare_node_specifier(error) { if !*DENO_DISABLE_PEDANTIC_NODE_WARNINGS { - Some(format!("If you want to use a built-in Node module, add a \"node:\" prefix (ex. \"node:{specifier}\").")) + Some(format!("If you want to use a built-in Node module, add a \"node:\" prefix (ex. \"node:{specifier}\"), or use + --unstable-bare-node-builtins flag, or specify `bare-node-builtins` in the `unstable` option in the config file.")) } else { None } diff --git a/cli/resolver.rs b/cli/resolver.rs index 710b97509345a6..27b6a15fc727a3 100644 --- a/cli/resolver.rs +++ b/cli/resolver.rs @@ -4,7 +4,6 @@ use async_trait::async_trait; use dashmap::DashMap; use dashmap::DashSet; use deno_ast::MediaType; -use deno_ast::ModuleKind; use deno_config::workspace::MappedResolution; use deno_config::workspace::MappedResolutionDiagnostic; use deno_config::workspace::MappedResolutionError; @@ -12,7 +11,6 @@ use deno_config::workspace::WorkspaceResolver; use deno_core::anyhow::anyhow; use deno_core::anyhow::Context; use deno_core::error::AnyError; -use deno_core::url::Url; use deno_core::ModuleSourceCode; use deno_core::ModuleSpecifier; use deno_graph::source::ResolutionMode; @@ -31,7 +29,6 @@ use deno_runtime::deno_fs; use deno_runtime::deno_fs::FileSystem; use deno_runtime::deno_node::is_builtin_node_module; use deno_runtime::deno_node::NodeResolver; -use deno_runtime::deno_node::PackageJsonResolver; use deno_semver::npm::NpmPackageReqReference; use deno_semver::package::PackageReq; use node_resolver::errors::ClosestPkgJsonError; @@ -41,22 +38,21 @@ use node_resolver::errors::PackageFolderResolveErrorKind; use node_resolver::errors::PackageFolderResolveIoError; use node_resolver::errors::PackageNotFoundError; use node_resolver::errors::PackageResolveErrorKind; -use node_resolver::errors::PackageSubpathResolveError; -use node_resolver::InNpmPackageChecker; +use node_resolver::errors::UrlToNodeResolutionError; use node_resolver::NodeModuleKind; use node_resolver::NodeResolution; use node_resolver::NodeResolutionMode; -use std::borrow::Cow; +use node_resolver::PackageJson; use std::path::Path; use std::path::PathBuf; use std::sync::Arc; -use thiserror::Error; use crate::args::JsxImportSourceConfig; use crate::args::DENO_DISABLE_PEDANTIC_NODE_WARNINGS; use crate::node::CliNodeCodeTranslator; use crate::npm::CliNpmResolver; use crate::npm::InnerCliNpmResolverRef; +use crate::util::path::specifier_has_extension; use crate::util::sync::AtomicFlag; use crate::util::text_encoding::from_utf8_lossy_owned; @@ -108,32 +104,36 @@ impl deno_resolver::fs::DenoResolverFs for CliDenoResolverFs { #[derive(Debug)] pub struct CliNodeResolver { - cjs_tracker: Arc, + cjs_resolutions: Arc, fs: Arc, - in_npm_pkg_checker: Arc, node_resolver: Arc, npm_resolver: Arc, } impl CliNodeResolver { pub fn new( - cjs_tracker: Arc, + cjs_resolutions: Arc, fs: Arc, - in_npm_pkg_checker: Arc, node_resolver: Arc, npm_resolver: Arc, ) -> Self { Self { - cjs_tracker, + cjs_resolutions, fs, - in_npm_pkg_checker, node_resolver, npm_resolver, } } pub fn in_npm_package(&self, specifier: &ModuleSpecifier) -> bool { - self.in_npm_pkg_checker.in_npm_package(specifier) + self.npm_resolver.in_npm_package(specifier) + } + + pub fn get_closest_package_json( + &self, + referrer: &ModuleSpecifier, + ) -> Result>, ClosestPkgJsonError> { + self.node_resolver.get_closest_package_json(referrer) } pub fn resolve_if_for_npm_pkg( @@ -153,7 +153,8 @@ impl CliNodeResolver { | NodeResolveErrorKind::UnsupportedEsmUrlScheme(_) | NodeResolveErrorKind::DataUrlReferrer(_) | NodeResolveErrorKind::TypesNotFound(_) - | NodeResolveErrorKind::FinalizeResolution(_) => Err(err.into()), + | NodeResolveErrorKind::FinalizeResolution(_) + | NodeResolveErrorKind::UrlToNodeResolution(_) => Err(err.into()), NodeResolveErrorKind::PackageResolve(err) => { let err = err.into_kind(); match err { @@ -215,11 +216,7 @@ impl CliNodeResolver { referrer: &ModuleSpecifier, mode: NodeResolutionMode, ) -> Result { - let referrer_kind = if self - .cjs_tracker - .is_maybe_cjs(referrer, MediaType::from_specifier(referrer)) - .map_err(|err| NodeResolveErrorKind::PackageResolve(err.into()))? - { + let referrer_kind = if self.cjs_resolutions.is_known_cjs(referrer) { NodeModuleKind::Cjs } else { NodeModuleKind::Esm @@ -229,7 +226,7 @@ impl CliNodeResolver { self .node_resolver .resolve(specifier, referrer, referrer_kind, mode)?; - Ok(res) + Ok(self.handle_node_resolution(res)) } pub fn resolve_req_reference( @@ -237,7 +234,7 @@ impl CliNodeResolver { req_ref: &NpmPackageReqReference, referrer: &ModuleSpecifier, mode: NodeResolutionMode, - ) -> Result { + ) -> Result { self.resolve_req_with_sub_path( req_ref.req(), req_ref.sub_path(), @@ -252,7 +249,7 @@ impl CliNodeResolver { sub_path: Option<&str>, referrer: &ModuleSpecifier, mode: NodeResolutionMode, - ) -> Result { + ) -> Result { let package_folder = self .npm_resolver .resolve_pkg_folder_from_deno_module_req(req, referrer)?; @@ -263,7 +260,7 @@ impl CliNodeResolver { mode, ); match resolution_result { - Ok(url) => Ok(url), + Ok(resolution) => Ok(resolution), Err(err) => { if self.npm_resolver.as_byonm().is_some() { let package_json_path = package_folder.join("package.json"); @@ -274,7 +271,7 @@ impl CliNodeResolver { )); } } - Err(err.into()) + Err(err) } } } @@ -285,13 +282,16 @@ impl CliNodeResolver { sub_path: Option<&str>, maybe_referrer: Option<&ModuleSpecifier>, mode: NodeResolutionMode, - ) -> Result { - self.node_resolver.resolve_package_subpath_from_deno_module( - package_folder, - sub_path, - maybe_referrer, - mode, - ) + ) -> Result { + let res = self + .node_resolver + .resolve_package_subpath_from_deno_module( + package_folder, + sub_path, + maybe_referrer, + mode, + )?; + Ok(self.handle_node_resolution(res)) } pub fn handle_if_in_node_modules( @@ -306,45 +306,71 @@ impl CliNodeResolver { // so canoncalize then check if it's in the node_modules directory. // If so, check if we need to store this specifier as being a CJS // resolution. - let specifier = crate::node::resolve_specifier_into_node_modules( - specifier, - self.fs.as_ref(), - ); - return Ok(Some(specifier)); + let specifier = + crate::node::resolve_specifier_into_node_modules(specifier); + if self.in_npm_package(&specifier) { + let resolution = + self.node_resolver.url_to_node_resolution(specifier)?; + let resolution = self.handle_node_resolution(resolution); + return Ok(Some(resolution.into_url())); + } } Ok(None) } -} -#[derive(Debug, Error)] -#[error("{media_type} files are not supported in npm packages: {specifier}")] -pub struct NotSupportedKindInNpmError { - pub media_type: MediaType, - pub specifier: Url, + pub fn url_to_node_resolution( + &self, + specifier: ModuleSpecifier, + ) -> Result { + self.node_resolver.url_to_node_resolution(specifier) + } + + fn handle_node_resolution( + &self, + resolution: NodeResolution, + ) -> NodeResolution { + if let NodeResolution::CommonJs(specifier) = &resolution { + // remember that this was a common js resolution + self.mark_cjs_resolution(specifier.clone()); + } + resolution + } + + pub fn mark_cjs_resolution(&self, specifier: ModuleSpecifier) { + self.cjs_resolutions.insert(specifier); + } } -// todo(dsherret): move to module_loader.rs (it seems to be here due to use in standalone) +// todo(dsherret): move to module_loader.rs #[derive(Clone)] pub struct NpmModuleLoader { - cjs_tracker: Arc, - fs: Arc, + cjs_resolutions: Arc, node_code_translator: Arc, + fs: Arc, + node_resolver: Arc, } impl NpmModuleLoader { pub fn new( - cjs_tracker: Arc, - fs: Arc, + cjs_resolutions: Arc, node_code_translator: Arc, + fs: Arc, + node_resolver: Arc, ) -> Self { Self { - cjs_tracker, + cjs_resolutions, node_code_translator, fs, + node_resolver, } } + pub fn if_in_npm_package(&self, specifier: &ModuleSpecifier) -> bool { + self.node_resolver.in_npm_package(specifier) + || self.cjs_resolutions.is_known_cjs(specifier) + } + pub async fn load( &self, specifier: &ModuleSpecifier, @@ -387,30 +413,20 @@ impl NpmModuleLoader { } })?; - let media_type = MediaType::from_specifier(specifier); - if media_type.is_emittable() { - return Err(AnyError::from(NotSupportedKindInNpmError { - media_type, - specifier: specifier.clone(), - })); - } - - let code = if self.cjs_tracker.is_maybe_cjs(specifier, media_type)? { + let code = if self.cjs_resolutions.is_known_cjs(specifier) { // translate cjs to esm if it's cjs and inject node globals let code = from_utf8_lossy_owned(code); ModuleSourceCode::String( self .node_code_translator - .translate_cjs_to_esm(specifier, Some(Cow::Owned(code))) + .translate_cjs_to_esm(specifier, Some(code)) .await? - .into_owned() .into(), ) } else { // esm and json code is untouched ModuleSourceCode::Bytes(code.into_boxed_slice().into()) }; - Ok(ModuleCodeStringSource { code, found_url: specifier.clone(), @@ -419,165 +435,21 @@ impl NpmModuleLoader { } } -pub struct CjsTrackerOptions { - pub unstable_detect_cjs: bool, -} - /// Keeps track of what module specifiers were resolved as CJS. -/// -/// Modules that are `.js` or `.ts` are only known to be CJS or -/// ESM after they're loaded based on their contents. So these files -/// will be "maybe CJS" until they're loaded. -#[derive(Debug)] -pub struct CjsTracker { - in_npm_pkg_checker: Arc, - pkg_json_resolver: Arc, - unstable_detect_cjs: bool, - known: DashMap, -} - -impl CjsTracker { - pub fn new( - in_npm_pkg_checker: Arc, - pkg_json_resolver: Arc, - options: CjsTrackerOptions, - ) -> Self { - Self { - in_npm_pkg_checker, - pkg_json_resolver, - unstable_detect_cjs: options.unstable_detect_cjs, - known: Default::default(), - } - } +#[derive(Debug, Default)] +pub struct CjsResolutionStore(DashSet); - /// Checks whether the file might be treated as CJS, but it's not for sure - /// yet because the source hasn't been loaded to see whether it contains - /// imports or exports. - pub fn is_maybe_cjs( - &self, - specifier: &ModuleSpecifier, - media_type: MediaType, - ) -> Result { - self.treat_as_cjs_with_is_script(specifier, media_type, None) - } - - /// Gets whether the file is CJS. If true, this is for sure - /// cjs because `is_script` is provided. - /// - /// `is_script` should be `true` when the contents of the file at the - /// provided specifier are known to be a script and not an ES module. - pub fn is_cjs_with_known_is_script( - &self, - specifier: &ModuleSpecifier, - media_type: MediaType, - is_script: bool, - ) -> Result { - self.treat_as_cjs_with_is_script(specifier, media_type, Some(is_script)) - } - - fn treat_as_cjs_with_is_script( - &self, - specifier: &ModuleSpecifier, - media_type: MediaType, - is_script: Option, - ) -> Result { - let kind = match self - .get_known_kind_with_is_script(specifier, media_type, is_script) - { - Some(kind) => kind, - None => self.check_based_on_pkg_json(specifier)?, - }; - Ok(kind.is_cjs()) - } - - pub fn get_known_kind( - &self, - specifier: &ModuleSpecifier, - media_type: MediaType, - ) -> Option { - self.get_known_kind_with_is_script(specifier, media_type, None) - } - - fn get_known_kind_with_is_script( - &self, - specifier: &ModuleSpecifier, - media_type: MediaType, - is_script: Option, - ) -> Option { +impl CjsResolutionStore { + pub fn is_known_cjs(&self, specifier: &ModuleSpecifier) -> bool { if specifier.scheme() != "file" { - return Some(ModuleKind::Esm); + return false; } - match media_type { - MediaType::Mts | MediaType::Mjs | MediaType::Dmts => Some(ModuleKind::Esm), - MediaType::Cjs | MediaType::Cts | MediaType::Dcts => Some(ModuleKind::Cjs), - MediaType::Dts => { - // dts files are always determined based on the package.json because - // they contain imports/exports even when considered CJS - if let Some(value) = self.known.get(specifier).map(|v| *v) { - Some(value) - } else { - let value = self.check_based_on_pkg_json(specifier).ok(); - if let Some(value) = value { - self.known.insert(specifier.clone(), value); - } - Some(value.unwrap_or(ModuleKind::Esm)) - } - } - MediaType::Wasm | - MediaType::Json => Some(ModuleKind::Esm), - MediaType::JavaScript - | MediaType::Jsx - | MediaType::TypeScript - | MediaType::Tsx - // treat these as unknown - | MediaType::Css - | MediaType::SourceMap - | MediaType::Unknown => { - if let Some(value) = self.known.get(specifier).map(|v| *v) { - if value.is_cjs() && is_script == Some(false) { - // we now know this is actually esm - self.known.insert(specifier.clone(), ModuleKind::Esm); - Some(ModuleKind::Esm) - } else { - Some(value) - } - } else if is_script == Some(false) { - // we know this is esm - self.known.insert(specifier.clone(), ModuleKind::Esm); - Some(ModuleKind::Esm) - } else { - None - } - } - } + specifier_has_extension(specifier, "cjs") || self.0.contains(specifier) } - fn check_based_on_pkg_json( - &self, - specifier: &ModuleSpecifier, - ) -> Result { - if self.in_npm_pkg_checker.in_npm_package(specifier) { - if let Some(pkg_json) = - self.pkg_json_resolver.get_closest_package_json(specifier)? - { - let is_file_location_cjs = pkg_json.typ != "module"; - Ok(ModuleKind::from_is_cjs(is_file_location_cjs)) - } else { - Ok(ModuleKind::Cjs) - } - } else if self.unstable_detect_cjs { - if let Some(pkg_json) = - self.pkg_json_resolver.get_closest_package_json(specifier)? - { - let is_cjs_type = pkg_json.typ == "commonjs"; - Ok(ModuleKind::from_is_cjs(is_cjs_type)) - } else { - Ok(ModuleKind::Esm) - } - } else { - Ok(ModuleKind::Esm) - } + pub fn insert(&self, specifier: ModuleSpecifier) { + self.0.insert(specifier); } } @@ -761,7 +633,8 @@ impl Resolver for CliGraphResolver { Some(referrer), to_node_mode(mode), ) - .map_err(|e| ResolveError::Other(e.into())), + .map_err(ResolveError::Other) + .map(|res| res.into_url()), MappedResolution::PackageJson { dep_result, alias, @@ -792,17 +665,19 @@ impl Resolver for CliGraphResolver { ) .map_err(|e| ResolveError::Other(e.into())) .and_then(|pkg_folder| { - self - .node_resolver - .as_ref() - .unwrap() - .resolve_package_sub_path_from_deno_module( - pkg_folder, - sub_path.as_deref(), - Some(referrer), - to_node_mode(mode), - ) - .map_err(|e| ResolveError::Other(e.into())) + Ok( + self + .node_resolver + .as_ref() + .unwrap() + .resolve_package_sub_path_from_deno_module( + pkg_folder, + sub_path.as_deref(), + Some(referrer), + to_node_mode(mode), + )? + .into_url(), + ) }), }) } @@ -842,20 +717,23 @@ impl Resolver for CliGraphResolver { npm_req_ref.req(), ) { - return node_resolver - .resolve_package_sub_path_from_deno_module( - pkg_folder, - npm_req_ref.sub_path(), - Some(referrer), - to_node_mode(mode), - ) - .map_err(|e| ResolveError::Other(e.into())); + return Ok( + node_resolver + .resolve_package_sub_path_from_deno_module( + pkg_folder, + npm_req_ref.sub_path(), + Some(referrer), + to_node_mode(mode), + )? + .into_url(), + ); } // do npm resolution for byonm if is_byonm { return node_resolver .resolve_req_reference(&npm_req_ref, referrer, to_node_mode(mode)) + .map(|res| res.into_url()) .map_err(|err| err.into()); } } @@ -873,7 +751,9 @@ impl Resolver for CliGraphResolver { .map_err(ResolveError::Other)?; if let Some(res) = maybe_resolution { match res { - NodeResolution::Module(url) => return Ok(url), + NodeResolution::Esm(url) | NodeResolution::CommonJs(url) => { + return Ok(url) + } NodeResolution::BuiltIn(_) => { // don't resolve bare specifiers for built-in modules via node resolution } @@ -923,7 +803,7 @@ impl<'a> deno_graph::source::NpmResolver for WorkerCliNpmGraphResolver<'a> { let line = start.line + 1; let column = start.character + 1; if !*DENO_DISABLE_PEDANTIC_NODE_WARNINGS { - log::warn!("{} Resolving \"{module_name}\" as \"node:{module_name}\" at {specifier}:{line}:{column}. If you want to use a built-in Node module, add a \"node:\" prefix.", colors::yellow("Warning")) + log::warn!("{} Resolving \"{module_name}\" as \"node:{module_name}\" at {specifier}:{line}:{column}.\n If you want to use a built-in Node module, add a \"node:\" prefix, or use\n --unstable-bare-node-builtins flag, or specify `bare-node-builtins` in the `unstable` option in the config file.", colors::yellow("Warning")) } } diff --git a/tests/integration/lsp_tests.rs b/tests/integration/lsp_tests.rs index 2376aebd90f567..c8eddb5edcda11 100644 --- a/tests/integration/lsp_tests.rs +++ b/tests/integration/lsp_tests.rs @@ -9480,7 +9480,7 @@ fn lsp_completions_node_builtin() { "severity": 1, "code": "import-node-prefix-missing", "source": "deno", - "message": "Relative import path \"fs\" not prefixed with / or ./ or ../\n \u{1b}[0m\u{1b}[36mhint:\u{1b}[0m If you want to use a built-in Node module, add a \"node:\" prefix (ex. \"node:fs\").", + "message": "Relative import path \"fs\" not prefixed with / or ./ or ../\n \u{1b}[0m\u{1b}[36mhint:\u{1b}[0m If you want to use a built-in Node module, add a \"node:\" prefix (ex. \"node:fs\"), or use\n --unstable-bare-node-builtins flag, or specify `bare-node-builtins` in the `unstable` option in the config file.", "data": { "specifier": "fs" }, diff --git a/tests/specs/publish/bare_node_builtins/bare_node_builtins.out b/tests/specs/publish/bare_node_builtins/bare_node_builtins.out index 6baedd906f767e..69a7359f7ea54f 100644 --- a/tests/specs/publish/bare_node_builtins/bare_node_builtins.out +++ b/tests/specs/publish/bare_node_builtins/bare_node_builtins.out @@ -1,5 +1,9 @@ -Warning Resolving "url" as "node:url" at file:///[WILDLINE]/mod.ts:1:22. If you want to use a built-in Node module, add a "node:" prefix. -Warning Resolving "url" as "node:url" at file:///[WILDLINE]/mod.ts:1:22. If you want to use a built-in Node module, add a "node:" prefix. +Warning Resolving "url" as "node:url" at file:///[WILDLINE]/mod.ts:1:22. + If you want to use a built-in Node module, add a "node:" prefix, or use + --unstable-bare-node-builtins flag, or specify `bare-node-builtins` in the `unstable` option in the config file. +Warning Resolving "url" as "node:url" at file:///[WILDLINE]/mod.ts:1:22. + If you want to use a built-in Node module, add a "node:" prefix, or use + --unstable-bare-node-builtins flag, or specify `bare-node-builtins` in the `unstable` option in the config file. [UNORDERED_START] Download http://localhost:4260/@types%2fnode Download http://localhost:4260/undici-types diff --git a/tests/specs/run/node_prefix_missing/byonm/missing.out b/tests/specs/run/node_prefix_missing/byonm/missing.out index 4129e79a519512..8ce67262357aa8 100644 --- a/tests/specs/run/node_prefix_missing/byonm/missing.out +++ b/tests/specs/run/node_prefix_missing/byonm/missing.out @@ -1,3 +1,4 @@ error: Relative import path "fs" not prefixed with / or ./ or ../ - hint: If you want to use a built-in Node module, add a "node:" prefix (ex. "node:fs"). + hint: If you want to use a built-in Node module, add a "node:" prefix (ex. "node:fs"), or use + --unstable-bare-node-builtins flag, or specify `bare-node-builtins` in the `unstable` option in the config file. at file:///[WILDLINE]/missing.ts:1:16 diff --git a/tests/specs/run/node_prefix_missing/feature_enabled.out b/tests/specs/run/node_prefix_missing/feature_enabled.out index 3eff4bc32443cd..c9abf339e4c3b2 100644 --- a/tests/specs/run/node_prefix_missing/feature_enabled.out +++ b/tests/specs/run/node_prefix_missing/feature_enabled.out @@ -1,2 +1,4 @@ -[WILDCARD]Warning Resolving "fs" as "node:fs" at file:///[WILDCARD]/main.ts:1:16. If you want to use a built-in Node module, add a "node:" prefix. +[WILDCARD]Warning Resolving "fs" as "node:fs" at file:///[WILDCARD]/main.ts:1:16. + If you want to use a built-in Node module, add a "node:" prefix, or use + --unstable-bare-node-builtins flag, or specify `bare-node-builtins` in the `unstable` option in the config file. [Function: writeFile] diff --git a/tests/specs/run/node_prefix_missing/main.ts.out b/tests/specs/run/node_prefix_missing/main.ts.out index 48b4e37e277569..cad883e130d514 100644 --- a/tests/specs/run/node_prefix_missing/main.ts.out +++ b/tests/specs/run/node_prefix_missing/main.ts.out @@ -1,3 +1,4 @@ error: Relative import path "fs" not prefixed with / or ./ or ../ - hint: If you want to use a built-in Node module, add a "node:" prefix (ex. "node:fs"). + hint: If you want to use a built-in Node module, add a "node:" prefix (ex. "node:fs"), or use + --unstable-bare-node-builtins flag, or specify `bare-node-builtins` in the `unstable` option in the config file. at file:///[WILDCARD]/main.ts:1:16