Unverified Commit 2a9e7560 authored by Niklas Mischkulnig's avatar Niklas Mischkulnig Committed by GitHub

Turbopack: handle invalid RSC imports via importmap (#88146)

We have two lines of defense:
1. crates/next-custom-transforms/src/transforms/react_server_components.rs validates ESM imports of server-only and client-only and throws an issue if something is wrong. Notably, `require('server-only')` isn't caught by this
2. additionally, we had an `BeforeResolvePlugin` for server-only, client-only and styled-jsx. 

We should probably get rid of the first one completely for consistency (it's brittle)
https://github.com/vercel/next.js/blob/79040a318d29641eb3d96a5a47c92a5f8506e826/crates/next-custom-transforms/src/transforms/react_server_components.rs#L663-L674

This PR is about improving the second one:

The error message isn't ideal yet, but better than before (note: no import trace):

```
./bench/basic-app/app
Invalid import
'server-only' cannot be imported from a Client Component module. It should only be used from a Server Component.
The error was caused by importing 'bench/basic-app/app'
```

now

<img width="708" height="386" alt="Bildschirmfoto 2026-01-07 um 17 21 59" src="https://github.com/user-attachments/assets/4d49eff3-4959-4b70-aa47-6f3c10c75588" />
parent 9dad4cd9
...@@ -50,10 +50,7 @@ use crate::{ ...@@ -50,10 +50,7 @@ use crate::{
get_next_client_resolved_map, get_next_client_resolved_map,
}, },
next_shared::{ next_shared::{
resolve::{ resolve::{ModuleFeatureReportResolvePlugin, NextSharedRuntimeResolvePlugin},
ModuleFeatureReportResolvePlugin, NextSharedRuntimeResolvePlugin,
get_invalid_server_only_resolve_plugin,
},
transforms::{ transforms::{
emotion::get_emotion_transform_rule, emotion::get_emotion_transform_rule,
react_remove_properties::get_react_remove_properties_transform_rule, react_remove_properties::get_react_remove_properties_transform_rule,
...@@ -181,11 +178,6 @@ pub async fn get_client_resolve_options_context( ...@@ -181,11 +178,6 @@ pub async fn get_client_resolve_options_context(
browser: true, browser: true,
module: true, module: true,
before_resolve_plugins: vec![ before_resolve_plugins: vec![
ResolvedVc::upcast(
get_invalid_server_only_resolve_plugin(project_path.clone())
.to_resolved()
.await?,
),
ResolvedVc::upcast( ResolvedVc::upcast(
ModuleFeatureReportResolvePlugin::new(project_path.clone()) ModuleFeatureReportResolvePlugin::new(project_path.clone())
.to_resolved() .to_resolved()
......
...@@ -27,10 +27,7 @@ use crate::{ ...@@ -27,10 +27,7 @@ use crate::{
next_font::local::NextFontLocalResolvePlugin, next_font::local::NextFontLocalResolvePlugin,
next_import_map::{get_next_edge_and_server_fallback_import_map, get_next_edge_import_map}, next_import_map::{get_next_edge_and_server_fallback_import_map, get_next_edge_import_map},
next_server::context::ServerContextType, next_server::context::ServerContextType,
next_shared::resolve::{ next_shared::resolve::{ModuleFeatureReportResolvePlugin, NextSharedRuntimeResolvePlugin},
ModuleFeatureReportResolvePlugin, NextSharedRuntimeResolvePlugin,
get_invalid_client_only_resolve_plugin, get_invalid_styled_jsx_resolve_plugin,
},
util::{ util::{
NextRuntime, OptionEnvMap, defines, foreign_code_context_condition, NextRuntime, OptionEnvMap, defines, foreign_code_context_condition,
free_var_references_with_vercel_system_env_warnings, worker_forwarded_globals, free_var_references_with_vercel_system_env_warnings, worker_forwarded_globals,
...@@ -130,25 +127,6 @@ pub async fn get_edge_resolve_options_context( ...@@ -130,25 +127,6 @@ pub async fn get_edge_resolve_options_context(
)); ));
}; };
if matches!(
ty,
ServerContextType::AppRSC { .. }
| ServerContextType::AppRoute { .. }
| ServerContextType::Middleware { .. }
| ServerContextType::Instrumentation { .. }
) {
before_resolve_plugins.push(ResolvedVc::upcast(
get_invalid_client_only_resolve_plugin(project_path.clone())
.to_resolved()
.await?,
));
before_resolve_plugins.push(ResolvedVc::upcast(
get_invalid_styled_jsx_resolve_plugin(project_path.clone())
.to_resolved()
.await?,
));
}
let after_resolve_plugins = vec![ResolvedVc::upcast( let after_resolve_plugins = vec![ResolvedVc::upcast(
NextSharedRuntimeResolvePlugin::new(project_path.clone()) NextSharedRuntimeResolvePlugin::new(project_path.clone())
.to_resolved() .to_resolved()
......
...@@ -10,7 +10,7 @@ use turbo_tasks_fs::{ ...@@ -10,7 +10,7 @@ use turbo_tasks_fs::{
}; };
use turbopack_core::{ use turbopack_core::{
asset::AssetContent, asset::AssetContent,
issue::{Issue, IssueExt, IssueSeverity, IssueStage, StyledString}, issue::{Issue, IssueSeverity, IssueStage, StyledString},
reference_type::ReferenceType, reference_type::ReferenceType,
resolve::{ resolve::{
ResolveResult, ResolveResultItem, ResolveResultOption, ResolveResult, ResolveResultItem, ResolveResultOption,
...@@ -108,16 +108,12 @@ impl BeforeResolvePlugin for NextFontLocalResolvePlugin { ...@@ -108,16 +108,12 @@ impl BeforeResolvePlugin for NextFontLocalResolvePlugin {
let font_fallbacks = &*get_font_fallbacks(lookup_path.clone(), options_vc).await?; let font_fallbacks = &*get_font_fallbacks(lookup_path.clone(), options_vc).await?;
let font_fallbacks = match font_fallbacks { let font_fallbacks = match font_fallbacks {
FontFallbackResult::FontFileNotFound(err) => { FontFallbackResult::FontFileNotFound(err) => {
return Ok(ResolveResultOption::some(
ResolveResult::primary(ResolveResultItem::Error(ResolvedVc::upcast(
FontResolvingIssue { FontResolvingIssue {
origin_path: lookup_path.clone(),
font_path: ResolvedVc::cell(err.0.clone()), font_path: ResolvedVc::cell(err.0.clone()),
} }
.resolved_cell() .resolved_cell(),
.emit();
return Ok(ResolveResultOption::some(
ResolveResult::primary(ResolveResultItem::Error(ResolvedVc::cell(
err.to_string().into(),
))) )))
.cell(), .cell(),
)); ));
...@@ -183,16 +179,12 @@ impl BeforeResolvePlugin for NextFontLocalResolvePlugin { ...@@ -183,16 +179,12 @@ impl BeforeResolvePlugin for NextFontLocalResolvePlugin {
let fallback = &*get_font_fallbacks(lookup_path.clone(), options).await?; let fallback = &*get_font_fallbacks(lookup_path.clone(), options).await?;
let fallback = match fallback { let fallback = match fallback {
FontFallbackResult::FontFileNotFound(err) => { FontFallbackResult::FontFileNotFound(err) => {
return Ok(ResolveResultOption::some(
ResolveResult::primary(ResolveResultItem::Error(ResolvedVc::upcast(
FontResolvingIssue { FontResolvingIssue {
origin_path: lookup_path.clone(),
font_path: ResolvedVc::cell(err.0.clone()), font_path: ResolvedVc::cell(err.0.clone()),
} }
.resolved_cell() .resolved_cell(),
.emit();
return Ok(ResolveResultOption::some(
ResolveResult::primary(ResolveResultItem::Error(ResolvedVc::cell(
err.to_string().into(),
))) )))
.cell(), .cell(),
)); ));
...@@ -320,9 +312,6 @@ fn font_file_options_from_query_map(query: &RcStr) -> Result<NextFontLocalFontFi ...@@ -320,9 +312,6 @@ fn font_file_options_from_query_map(query: &RcStr) -> Result<NextFontLocalFontFi
#[turbo_tasks::value(shared)] #[turbo_tasks::value(shared)]
struct FontResolvingIssue { struct FontResolvingIssue {
font_path: ResolvedVc<RcStr>, font_path: ResolvedVc<RcStr>,
// TODO(PACK-4879): The filepath is incorrect and there should be a fine grained source
// location pointing at the import/require
origin_path: FileSystemPath,
} }
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
...@@ -333,7 +322,7 @@ impl Issue for FontResolvingIssue { ...@@ -333,7 +322,7 @@ impl Issue for FontResolvingIssue {
#[turbo_tasks::function] #[turbo_tasks::function]
fn file_path(&self) -> Vc<FileSystemPath> { fn file_path(&self) -> Vc<FileSystemPath> {
self.origin_path.clone().cell() panic!("FontResolvingIssue::file_path should not be called");
} }
#[turbo_tasks::function] #[turbo_tasks::function]
......
...@@ -7,7 +7,7 @@ use turbo_rcstr::{RcStr, rcstr}; ...@@ -7,7 +7,7 @@ use turbo_rcstr::{RcStr, rcstr};
use turbo_tasks::{FxIndexMap, ResolvedVc, Vc, fxindexmap}; use turbo_tasks::{FxIndexMap, ResolvedVc, Vc, fxindexmap};
use turbo_tasks_fs::{FileSystem, FileSystemPath, to_sys_path}; use turbo_tasks_fs::{FileSystem, FileSystemPath, to_sys_path};
use turbopack_core::{ use turbopack_core::{
issue::{Issue, IssueExt, IssueSeverity, IssueStage, StyledString}, issue::{Issue, IssueExt, IssueSeverity, IssueStage, OptionStyledString, StyledString},
reference_type::{CommonJsReferenceSubType, ReferenceType}, reference_type::{CommonJsReferenceSubType, ReferenceType},
resolve::{ resolve::{
AliasPattern, ExternalTraced, ExternalType, ResolveAliasMap, SubpathValue, AliasPattern, ExternalTraced, ExternalType, ResolveAliasMap, SubpathValue,
...@@ -280,6 +280,8 @@ pub async fn get_next_client_import_map( ...@@ -280,6 +280,8 @@ pub async fn get_next_client_import_map(
insert_turbopack_dev_alias(&mut import_map).await?; insert_turbopack_dev_alias(&mut import_map).await?;
insert_instrumentation_client_alias(&mut import_map, project_path).await?; insert_instrumentation_client_alias(&mut import_map, project_path).await?;
insert_server_only_error_alias(&mut import_map);
Ok(import_map.cell()) Ok(import_map.cell())
} }
...@@ -551,6 +553,16 @@ pub async fn get_next_edge_import_map( ...@@ -551,6 +553,16 @@ pub async fn get_next_edge_import_map(
} }
} }
if matches!(
ty,
ServerContextType::AppRSC { .. }
| ServerContextType::AppRoute { .. }
| ServerContextType::Middleware { .. }
| ServerContextType::Instrumentation { .. }
) {
insert_client_only_error_alias(&mut import_map);
}
Ok(import_map.cell()) Ok(import_map.cell())
} }
...@@ -704,9 +716,7 @@ async fn insert_next_server_special_aliases( ...@@ -704,9 +716,7 @@ async fn insert_next_server_special_aliases(
match &ty { match &ty {
ServerContextType::Pages { .. } | ServerContextType::PagesApi { .. } => {} ServerContextType::Pages { .. } | ServerContextType::PagesApi { .. } => {}
// the logic closely follows the one in createRSCAliases in webpack-config.ts // the logic closely follows the one in createRSCAliases in webpack-config.ts
ServerContextType::AppSSR { app_dir } ServerContextType::AppSSR { app_dir } => {
| ServerContextType::AppRSC { app_dir, .. }
| ServerContextType::AppRoute { app_dir, .. } => {
let next_package = get_next_package(app_dir.clone()).await?; let next_package = get_next_package(app_dir.clone()).await?;
import_map.insert_exact_alias( import_map.insert_exact_alias(
rcstr!("styled-jsx"), rcstr!("styled-jsx"),
...@@ -726,7 +736,10 @@ async fn insert_next_server_special_aliases( ...@@ -726,7 +736,10 @@ async fn insert_next_server_special_aliases(
) )
.await?; .await?;
} }
ServerContextType::Middleware { .. } | ServerContextType::Instrumentation { .. } => { ServerContextType::AppRSC { .. }
| ServerContextType::AppRoute { .. }
| ServerContextType::Middleware { .. }
| ServerContextType::Instrumentation { .. } => {
rsc_aliases( rsc_aliases(
import_map, import_map,
project_path.clone(), project_path.clone(),
...@@ -766,11 +779,11 @@ async fn insert_next_server_special_aliases( ...@@ -766,11 +779,11 @@ async fn insert_next_server_special_aliases(
project_path.clone(), project_path.clone(),
fxindexmap! { fxindexmap! {
rcstr!("server-only") => rcstr!("next/dist/compiled/server-only/empty"), rcstr!("server-only") => rcstr!("next/dist/compiled/server-only/empty"),
rcstr!("client-only") => rcstr!("next/dist/compiled/client-only/error"),
rcstr!("next/dist/compiled/server-only") => rcstr!("next/dist/compiled/server-only/empty"), rcstr!("next/dist/compiled/server-only") => rcstr!("next/dist/compiled/server-only/empty"),
rcstr!("next/dist/compiled/client-only") => rcstr!("next/dist/compiled/client-only/error"), rcstr!("next/dist/compiled/client-only") => rcstr!("next/dist/compiled/client-only/error"),
}, },
); );
insert_client_only_error_alias(import_map);
} }
ServerContextType::AppSSR { .. } => { ServerContextType::AppSSR { .. } => {
insert_exact_alias_map( insert_exact_alias_map(
...@@ -1458,6 +1471,113 @@ async fn insert_instrumentation_client_alias( ...@@ -1458,6 +1471,113 @@ async fn insert_instrumentation_client_alias(
Ok(()) Ok(())
} }
fn insert_client_only_error_alias(import_map: &mut ImportMap) {
import_map.insert_exact_alias(
rcstr!("client-only"),
ImportMapping::Error(ResolvedVc::upcast(
InvalidImportIssue {
title: StyledString::Line(vec![
StyledString::Code(rcstr!("'client-only'")),
StyledString::Text(rcstr!(
" cannot be imported from a Server Component module"
)),
])
.resolved_cell(),
description: ResolvedVc::cell(Some(
StyledString::Line(vec![StyledString::Text(
"It should only be used from a Client Component.".into(),
)])
.resolved_cell(),
)),
}
.resolved_cell(),
))
.resolved_cell(),
);
// styled-jsx imports client-only. So this is effectively the same as above but produces a nicer
// import trace.
let mapping = ImportMapping::Error(ResolvedVc::upcast(
InvalidImportIssue {
title: StyledString::Line(vec![
StyledString::Code(rcstr!("'styled-jsx'")),
StyledString::Text(rcstr!(" cannot be imported from a Server Component module")),
])
.resolved_cell(),
description: ResolvedVc::cell(Some(
StyledString::Line(vec![StyledString::Text(
"It only works in a Client Component but none of its parents are marked with \
'use client', so they're Server Components by default."
.into(),
)])
.resolved_cell(),
)),
}
.resolved_cell(),
))
.resolved_cell();
import_map.insert_exact_alias(rcstr!("styled-jsx"), mapping);
import_map.insert_wildcard_alias(rcstr!("styled-jsx/"), mapping);
}
fn insert_server_only_error_alias(import_map: &mut ImportMap) {
import_map.insert_exact_alias(
rcstr!("server-only"),
ImportMapping::Error(ResolvedVc::upcast(
InvalidImportIssue {
title: StyledString::Line(vec![
StyledString::Code(rcstr!("'server-only'")),
StyledString::Text(rcstr!(
" cannot be imported from a Client Component module"
)),
])
.resolved_cell(),
description: ResolvedVc::cell(Some(
StyledString::Line(vec![StyledString::Text(
"It should only be used from a Server Component.".into(),
)])
.resolved_cell(),
)),
}
.resolved_cell(),
))
.resolved_cell(),
);
}
#[turbo_tasks::value(shared)]
struct InvalidImportIssue {
title: ResolvedVc<StyledString>,
description: ResolvedVc<OptionStyledString>,
}
#[turbo_tasks::value_impl]
impl Issue for InvalidImportIssue {
fn severity(&self) -> IssueSeverity {
IssueSeverity::Error
}
#[turbo_tasks::function]
fn file_path(&self) -> Vc<FileSystemPath> {
panic!("InvalidImportIssue::file_path should not be called");
}
#[turbo_tasks::function]
fn stage(self: Vc<Self>) -> Vc<IssueStage> {
IssueStage::Resolve.cell()
}
#[turbo_tasks::function]
fn title(&self) -> Vc<StyledString> {
*self.title
}
#[turbo_tasks::function]
fn description(&self) -> Vc<OptionStyledString> {
*self.description
}
}
// To alias e.g. both `import "next/link"` and `import "next/link.js"` // To alias e.g. both `import "next/link"` and `import "next/link.js"`
fn insert_exact_alias_or_js( fn insert_exact_alias_or_js(
import_map: &mut ImportMap, import_map: &mut ImportMap,
......
...@@ -53,8 +53,7 @@ use crate::{ ...@@ -53,8 +53,7 @@ use crate::{
next_shared::{ next_shared::{
resolve::{ resolve::{
ModuleFeatureReportResolvePlugin, NextExternalResolvePlugin, ModuleFeatureReportResolvePlugin, NextExternalResolvePlugin,
NextNodeSharedRuntimeResolvePlugin, get_invalid_client_only_resolve_plugin, NextNodeSharedRuntimeResolvePlugin,
get_invalid_styled_jsx_resolve_plugin,
}, },
transforms::{ transforms::{
EcmascriptTransformStage, emotion::get_emotion_transform_rule, get_ecma_transform_rule, EcmascriptTransformStage, emotion::get_emotion_transform_rule, get_ecma_transform_rule,
...@@ -153,14 +152,6 @@ pub async fn get_server_resolve_options_context( ...@@ -153,14 +152,6 @@ pub async fn get_server_resolve_options_context(
ModuleFeatureReportResolvePlugin::new(project_path.clone()) ModuleFeatureReportResolvePlugin::new(project_path.clone())
.to_resolved() .to_resolved()
.await?; .await?;
let invalid_client_only_resolve_plugin =
get_invalid_client_only_resolve_plugin(project_path.clone())
.to_resolved()
.await?;
let invalid_styled_jsx_client_only_resolve_plugin =
get_invalid_styled_jsx_resolve_plugin(project_path.clone())
.to_resolved()
.await?;
// Always load these predefined packages as external. // Always load these predefined packages as external.
let mut external_packages: Vec<RcStr> = load_next_js_jsonc_file( let mut external_packages: Vec<RcStr> = load_next_js_jsonc_file(
...@@ -241,7 +232,7 @@ pub async fn get_server_resolve_options_context( ...@@ -241,7 +232,7 @@ pub async fn get_server_resolve_options_context(
.to_resolved() .to_resolved()
.await?; .await?;
let mut before_resolve_plugins = match &ty { let before_resolve_plugins = match &ty {
ServerContextType::Pages { .. } ServerContextType::Pages { .. }
| ServerContextType::AppSSR { .. } | ServerContextType::AppSSR { .. }
| ServerContextType::AppRSC { .. } => { | ServerContextType::AppRSC { .. } => {
...@@ -288,32 +279,6 @@ pub async fn get_server_resolve_options_context( ...@@ -288,32 +279,6 @@ pub async fn get_server_resolve_options_context(
} }
}; };
// Inject resolve plugin to assert incorrect import to client|server-only for
// the corresponding context. Refer https://github.com/vercel/next.js/blob/ad15817f0368ba154bed6d85320335d4b67b7348/packages/next/src/build/webpack-config.ts#L1205-L1235
// how it is applied in the webpack config.
// Unlike webpack which alias client-only -> runtime code -> build-time error
// code, we use resolve plugin to detect original import directly. This
// means each resolve plugin must be injected only for the context where the
// alias resolves into the error. The alias lives in here: https://github.com/vercel/next.js/blob/0060de1c4905593ea875fa7250d4b5d5ce10897d/packages/next-swc/crates/next-core/src/next_import_map.rs#L534
match ty {
ServerContextType::Pages { .. } | ServerContextType::PagesApi { .. } => {
//noop
}
ServerContextType::AppRSC { .. }
| ServerContextType::AppRoute { .. }
| ServerContextType::Middleware { .. }
| ServerContextType::Instrumentation { .. } => {
before_resolve_plugins.push(ResolvedVc::upcast(invalid_client_only_resolve_plugin));
before_resolve_plugins.push(ResolvedVc::upcast(
invalid_styled_jsx_client_only_resolve_plugin,
));
}
ServerContextType::AppSSR { .. } => {
//[TODO] Build error in this context makes rsc-build-error.ts fail which expects runtime error code
// looks like webpack and turbopack have different order, webpack runs rsc transform first, turbopack triggers resolve plugin first.
}
}
let resolve_options_context = ResolveOptionsContext { let resolve_options_context = ResolveOptionsContext {
enable_node_modules: Some(root_dir.clone()), enable_node_modules: Some(root_dir.clone()),
enable_node_externals: true, enable_node_externals: true,
......
...@@ -11,7 +11,7 @@ use turbo_tasks_fs::{ ...@@ -11,7 +11,7 @@ use turbo_tasks_fs::{
use turbopack_core::{ use turbopack_core::{
diagnostics::DiagnosticExt, diagnostics::DiagnosticExt,
file_source::FileSource, file_source::FileSource,
issue::{Issue, IssueExt, IssueSeverity, IssueStage, OptionStyledString, StyledString}, issue::{Issue, IssueSeverity, IssueStage, OptionStyledString, StyledString},
reference_type::ReferenceType, reference_type::ReferenceType,
resolve::{ resolve::{
ExternalTraced, ExternalType, ResolveResult, ResolveResultItem, ResolveResultOption, ExternalTraced, ExternalType, ResolveResult, ResolveResultItem, ResolveResultOption,
...@@ -101,115 +101,6 @@ impl Issue for InvalidImportModuleIssue { ...@@ -101,115 +101,6 @@ impl Issue for InvalidImportModuleIssue {
} }
} }
/// A resolver plugin emits an error when specific context imports
/// specified import requests. It doesn't detect if the import is correctly
/// aliased or not unlike webpack-config does; Instead it should be correctly
/// configured when each context sets up its resolve options.
#[turbo_tasks::value]
pub(crate) struct InvalidImportResolvePlugin {
root: FileSystemPath,
invalid_import: RcStr,
message: Vec<RcStr>,
}
#[turbo_tasks::value_impl]
impl InvalidImportResolvePlugin {
#[turbo_tasks::function]
pub fn new(root: FileSystemPath, invalid_import: RcStr, message: Vec<RcStr>) -> Vc<Self> {
InvalidImportResolvePlugin {
root,
invalid_import,
message,
}
.cell()
}
}
#[turbo_tasks::value_impl]
impl BeforeResolvePlugin for InvalidImportResolvePlugin {
#[turbo_tasks::function]
fn before_resolve_condition(&self) -> Vc<BeforeResolvePluginCondition> {
BeforeResolvePluginCondition::from_modules(Vc::cell(vec![self.invalid_import.clone()]))
}
#[turbo_tasks::function]
fn before_resolve(
&self,
lookup_path: FileSystemPath,
_reference_type: ReferenceType,
_request: Vc<Request>,
) -> Vc<ResolveResultOption> {
InvalidImportModuleIssue {
file_path: lookup_path,
messages: self.message.clone(),
// styled-jsx specific resolve error has its own message
skip_context_message: self.invalid_import == "styled-jsx",
}
.resolved_cell()
.emit();
ResolveResultOption::some(
ResolveResult::primary(ResolveResultItem::Error(ResolvedVc::cell(
self.message.join("\n").into(),
)))
.cell(),
)
}
}
/// Returns a resolve plugin if context have imports to `client-only`.
/// Only the contexts that aliases `client-only` to
/// `next/dist/compiled/client-only/error` should use this.
pub(crate) fn get_invalid_client_only_resolve_plugin(
root: FileSystemPath,
) -> Vc<InvalidImportResolvePlugin> {
InvalidImportResolvePlugin::new(
root,
rcstr!("client-only"),
vec![
"'client-only' cannot be imported from a Server Component module. It should only be \
used from a Client Component."
.into(),
],
)
}
/// Returns a resolve plugin if context have imports to `server-only`.
/// Only the contexts that aliases `server-only` to
/// `next/dist/compiled/server-only/index` should use this.
pub(crate) fn get_invalid_server_only_resolve_plugin(
root: FileSystemPath,
) -> Vc<InvalidImportResolvePlugin> {
InvalidImportResolvePlugin::new(
root,
rcstr!("server-only"),
vec![
"'server-only' cannot be imported from a Client Component module. It should only be \
used from a Server Component."
.into(),
],
)
}
/// Returns a resolve plugin if context have imports to `styled-jsx`.
pub(crate) fn get_invalid_styled_jsx_resolve_plugin(
root: FileSystemPath,
) -> Vc<InvalidImportResolvePlugin> {
InvalidImportResolvePlugin::new(
root,
rcstr!("styled-jsx"),
vec![
"'client-only' cannot be imported from a Server Component module. It should only be \
used from a Client Component."
.into(),
"The error was caused by using 'styled-jsx'. It only works in a Client Component but \
none of its parents are marked with \"use client\", so they're Server Components by \
default."
.into(),
],
)
}
#[turbo_tasks::value] #[turbo_tasks::value]
pub(crate) struct NextExternalResolvePlugin { pub(crate) struct NextExternalResolvePlugin {
project_path: FileSystemPath, project_path: FileSystemPath,
......
...@@ -74,7 +74,7 @@ pub async fn get_swc_ecma_transform_rule_impl( ...@@ -74,7 +74,7 @@ pub async fn get_swc_ecma_transform_rule_impl(
asset::Asset, asset::Asset,
module::Module, module::Module,
reference_type::{CommonJsReferenceSubType, ReferenceType}, reference_type::{CommonJsReferenceSubType, ReferenceType},
resolve::{ResolveErrorMode, handle_resolve_error, parse::Request, resolve}, resolve::{ResolveErrorMode, error::handle_resolve_error, parse::Request, resolve},
}; };
use turbopack_ecmascript_plugins::transform::swc_ecma_transform_plugins::{ use turbopack_ecmascript_plugins::transform::swc_ecma_transform_plugins::{
SwcEcmaTransformPluginsTransformer, SwcPluginModule, SwcEcmaTransformPluginsTransformer, SwcPluginModule,
......
...@@ -66,10 +66,15 @@ describe('Error Overlay invalid imports', () => { ...@@ -66,10 +66,15 @@ describe('Error Overlay invalid imports', () => {
await session.waitForRedbox() await session.waitForRedbox()
if (process.env.IS_TURBOPACK_TEST) { if (process.env.IS_TURBOPACK_TEST) {
expect(await session.getRedboxSource()).toMatchInlineSnapshot(` expect(await session.getRedboxSource()).toMatchInlineSnapshot(`
"./app "./app/comp2.js
Invalid import 'styled-jsx' cannot be imported from a Server Component module
'client-only' cannot be imported from a Server Component module. It should only be used from a Client Component. It only works in a Client Component but none of its parents are marked with 'use client', so they're Server Components by default.
The error was caused by using 'styled-jsx'. It only works in a Client Component but none of its parents are marked with "use client", so they're Server Components by default."
Import trace:
Server Component:
./app/comp2.js
./app/comp1.js
./app/page.js"
`) `)
} else if (process.env.NEXT_RSPACK) { } else if (process.env.NEXT_RSPACK) {
expect(await session.getRedboxSource()).toMatchInlineSnapshot(` expect(await session.getRedboxSource()).toMatchInlineSnapshot(`
...@@ -98,6 +103,75 @@ describe('Error Overlay invalid imports', () => { ...@@ -98,6 +103,75 @@ describe('Error Overlay invalid imports', () => {
} }
}) })
it('should show error when require-ing client-only in server component', async () => {
await using sandbox = await createSandbox(
next,
new Map([
[
'app/foo.js',
outdent`
require("client-only")
`,
],
[
'app/page.js',
outdent`
'use client'
import './foo'
export default function Page() {
return "Hello"
}
`,
],
])
)
const { session } = sandbox
const pageFile = 'app/page.js'
const content = await next.readFile(pageFile)
const withoutUseClient = content.replace("'use client'", '')
await session.patch(pageFile, withoutUseClient)
await session.waitForRedbox()
if (process.env.IS_TURBOPACK_TEST) {
expect(await session.getRedboxSource()).toMatchInlineSnapshot(`
"./app/foo.js (1:1)
'client-only' cannot be imported from a Server Component module
> 1 | require("client-only")
| ^^^^^^^^^^^^^^^^^^^^^^
It should only be used from a Client Component.
Import trace:
Server Component:
./app/foo.js
./app/page.js"
`)
} else if (process.env.NEXT_RSPACK) {
expect(await session.getRedboxSource()).toMatchInlineSnapshot(`
"./app/foo.js
× 'client-only' cannot be imported from a Server Component module. It should only be used from a Client Component.
│
│ The error was caused by importing 'next/dist/compiled/client-only/error.js' in './app/foo.js'.
│
│ Import trace for requested module:
│ ./app/foo.js
│ ./app/page.js"
`)
} else {
expect(await session.getRedboxSource()).toMatchInlineSnapshot(`
"./app/foo.js
'client-only' cannot be imported from a Server Component module. It should only be used from a Client Component.
The error was caused by importing 'next/dist/compiled/client-only/error.js' in './app/foo.js'.
Import trace for requested module:
./app/foo.js
./app/page.js"
`)
}
})
it('should show error when external package imports client-only in server component', async () => { it('should show error when external package imports client-only in server component', async () => {
await using sandbox = await createSandbox( await using sandbox = await createSandbox(
next, next,
...@@ -160,10 +234,19 @@ describe('Error Overlay invalid imports', () => { ...@@ -160,10 +234,19 @@ describe('Error Overlay invalid imports', () => {
await session.waitForRedbox() await session.waitForRedbox()
if (process.env.IS_TURBOPACK_TEST) { if (process.env.IS_TURBOPACK_TEST) {
expect(await session.getRedboxSource()).toMatchInlineSnapshot(` expect(await session.getRedboxSource()).toMatchInlineSnapshot(`
"./node_modules/client-only-package "./node_modules/client-only-package/index.js (1:1)
Invalid import 'client-only' cannot be imported from a Server Component module
'client-only' cannot be imported from a Server Component module. It should only be used from a Client Component. > 1 | require("client-only")
The error was caused by importing 'node_modules/client-only-package'" | ^^^^^^^^^^^^^^^^^^^^^^
It should only be used from a Client Component.
Import trace:
Server Component:
./node_modules/client-only-package/index.js
./app/comp2.js
./app/comp1.js
./app/page.js"
`) `)
} else if (process.env.NEXT_RSPACK) { } else if (process.env.NEXT_RSPACK) {
expect(await session.getRedboxSource()).toMatchInlineSnapshot(` expect(await session.getRedboxSource()).toMatchInlineSnapshot(`
...@@ -252,10 +335,27 @@ describe('Error Overlay invalid imports', () => { ...@@ -252,10 +335,27 @@ describe('Error Overlay invalid imports', () => {
await session.waitForRedbox() await session.waitForRedbox()
if (process.env.IS_TURBOPACK_TEST) { if (process.env.IS_TURBOPACK_TEST) {
expect(await session.getRedboxSource()).toMatchInlineSnapshot(` expect(await session.getRedboxSource()).toMatchInlineSnapshot(`
"./node_modules/server-only-package "./node_modules/server-only-package/index.js (1:1)
Invalid import 'server-only' cannot be imported from a Client Component module
'server-only' cannot be imported from a Client Component module. It should only be used from a Server Component. > 1 | require("server-only")
The error was caused by importing 'node_modules/server-only-package'" | ^^^^^^^^^^^^^^^^^^^^^^
It should only be used from a Server Component.
Import traces:
Client Component Browser:
./node_modules/server-only-package/index.js [Client Component Browser]
./app/comp2.js [Client Component Browser]
./app/comp1.js [Client Component Browser]
./app/page.js [Client Component Browser]
./app/page.js [Server Component]
Client Component SSR:
./node_modules/server-only-package/index.js [Client Component SSR]
./app/comp2.js [Client Component SSR]
./app/comp1.js [Client Component SSR]
./app/page.js [Client Component SSR]
./app/page.js [Server Component]"
`) `)
} else if (process.env.NEXT_RSPACK) { } else if (process.env.NEXT_RSPACK) {
expect(await session.getRedboxSource()).toMatchInlineSnapshot(` expect(await session.getRedboxSource()).toMatchInlineSnapshot(`
......
import { nextTestSetup } from 'e2e-utils' import { nextTestSetup } from 'e2e-utils'
import { waitForRedbox, getRedboxSource, retry } from 'next-test-utils' import {
waitForRedbox,
getRedboxSource,
retry,
waitForNoRedbox,
} from 'next-test-utils'
describe('module layer', () => { describe('module layer', () => {
const { next, isNextStart, isNextDev } = nextTestSetup({ const { next, isNextStart, isNextDev } = nextTestSetup({
...@@ -95,25 +100,19 @@ describe('module layer', () => { ...@@ -95,25 +100,19 @@ describe('module layer', () => {
if (isNextDev) { if (isNextDev) {
describe('client packages in middleware', () => { describe('client packages in middleware', () => {
const middlewareFile = 'middleware.js'
let middlewareContent = ''
afterAll(async () => {
await next.patchFile(middlewareFile, middlewareContent)
})
it('should error when import server packages in middleware', async () => { it('should error when import server packages in middleware', async () => {
const browser = await next.browser('/') const browser = await next.browser('/')
middlewareContent = await next.readFile(middlewareFile)
await next.patchFile( await next.patchFile(
middlewareFile, 'middleware.js',
middlewareContent (c) =>
c
.replace("import 'server-only'", "// import 'server-only'") .replace("import 'server-only'", "// import 'server-only'")
.replace("// import './lib/mixed-lib'", "import './lib/mixed-lib'") .replace(
) "// import './lib/mixed-lib'",
"import './lib/mixed-lib'"
),
async () => {
await retry(async () => { await retry(async () => {
await waitForRedbox(browser) await waitForRedbox(browser)
const source = await getRedboxSource(browser) const source = await getRedboxSource(browser)
...@@ -121,6 +120,10 @@ describe('module layer', () => { ...@@ -121,6 +120,10 @@ describe('module layer', () => {
`You're importing a component that imports client-only. It only works in a Client Component but none of its parents are marked with "use client"` `You're importing a component that imports client-only. It only works in a Client Component but none of its parents are marked with "use client"`
) )
}) })
}
)
await waitForNoRedbox(browser)
}) })
}) })
} }
......
use anyhow::Result;
use turbo_rcstr::RcStr;
use turbo_tasks::{IntoTraitRef, PrettyPrintError, ResolvedVc, Vc};
use turbo_tasks_fs::FileSystemPath;
use crate::{
issue::{
Issue, IssueExt, IssueSeverity, IssueSource, IssueStage, OptionIssueSource,
OptionStyledString, StyledString, resolve::ResolvingIssue,
},
reference_type::ReferenceType,
resolve::{
ModuleResolveResult, ResolveErrorMode, ResolveResult, options::ResolveOptions,
origin::ResolveOrigin, parse::Request,
},
};
pub async fn handle_resolve_error(
result: Vc<ModuleResolveResult>,
reference_type: ReferenceType,
origin: Vc<Box<dyn ResolveOrigin>>,
request: Vc<Request>,
resolve_options: Vc<ResolveOptions>,
error_mode: ResolveErrorMode,
source: Option<IssueSource>,
) -> Result<Vc<ModuleResolveResult>> {
Ok(match result.await {
Ok(result_ref) => {
if result_ref.is_unresolvable_ref() {
emit_unresolvable_issue(
error_mode,
origin,
reference_type,
request,
resolve_options,
source,
)
.await?;
}
handle_item_issues(result_ref.errors(), origin, source).await?;
result
}
Err(err) => {
emit_resolve_error_issue(
error_mode,
origin,
reference_type,
request,
resolve_options,
err,
source,
)
.await?;
*ModuleResolveResult::unresolvable()
}
})
}
pub async fn handle_resolve_source_error(
result: Vc<ResolveResult>,
reference_type: ReferenceType,
origin: Vc<Box<dyn ResolveOrigin>>,
request: Vc<Request>,
resolve_options: Vc<ResolveOptions>,
error_mode: ResolveErrorMode,
source: Option<IssueSource>,
) -> Result<Vc<ResolveResult>> {
Ok(match result.await {
Ok(result_ref) => {
if result_ref.is_unresolvable_ref() {
emit_unresolvable_issue(
error_mode,
origin,
reference_type,
request,
resolve_options,
source,
)
.await?;
}
handle_item_issues(result_ref.errors(), origin, source).await?;
result
}
Err(err) => {
emit_resolve_error_issue(
error_mode,
origin,
reference_type,
request,
resolve_options,
err,
source,
)
.await?;
ResolveResult::unresolvable().cell()
}
})
}
async fn handle_item_issues(
items: impl Iterator<Item = ResolvedVc<Box<dyn Issue>>>,
origin: Vc<Box<dyn ResolveOrigin>>,
source: Option<IssueSource>,
) -> Result<()> {
let mut items = items.peekable();
if items.peek().is_some() {
let file_path = origin.origin_path().owned().await?;
for item in items {
ResolvingIssueWithLocation {
inner: item,
severity: item.into_trait_ref().await?.severity(),
file_path: file_path.clone(),
source,
}
.resolved_cell()
.emit();
}
}
Ok(())
}
async fn emit_resolve_error_issue(
error_mode: ResolveErrorMode,
origin: Vc<Box<dyn ResolveOrigin>>,
reference_type: ReferenceType,
request: Vc<Request>,
resolve_options: Vc<ResolveOptions>,
err: anyhow::Error,
source: Option<IssueSource>,
) -> Result<()> {
if error_mode == ResolveErrorMode::Ignore {
return Ok(());
}
let severity = if error_mode == ResolveErrorMode::Warn || resolve_options.await?.loose_errors {
IssueSeverity::Warning
} else {
IssueSeverity::Error
};
ResolvingIssue {
severity,
file_path: origin.origin_path().owned().await?,
request_type: format!("{reference_type} request"),
request: request.to_resolved().await?,
resolve_options: resolve_options.to_resolved().await?,
error_message: Some(format!("{}", PrettyPrintError(&err))),
source,
}
.resolved_cell()
.emit();
Ok(())
}
async fn emit_unresolvable_issue(
error_mode: ResolveErrorMode,
origin: Vc<Box<dyn ResolveOrigin>>,
reference_type: ReferenceType,
request: Vc<Request>,
resolve_options: Vc<ResolveOptions>,
source: Option<IssueSource>,
) -> Result<()> {
if error_mode == ResolveErrorMode::Ignore {
return Ok(());
}
let severity = if error_mode == ResolveErrorMode::Warn || resolve_options.await?.loose_errors {
IssueSeverity::Warning
} else {
IssueSeverity::Error
};
ResolvingIssue {
severity,
file_path: origin.origin_path().owned().await?,
request_type: format!("{reference_type} request"),
request: request.to_resolved().await?,
resolve_options: resolve_options.to_resolved().await?,
error_message: None,
source,
}
.resolved_cell()
.emit();
Ok(())
}
pub async fn resolve_error_severity(resolve_options: Vc<ResolveOptions>) -> Result<IssueSeverity> {
Ok(if resolve_options.await?.loose_errors {
IssueSeverity::Warning
} else {
IssueSeverity::Error
})
}
/// Delegates to the inner issue but overrides the file path and source information.
#[turbo_tasks::value(shared)]
pub struct ResolvingIssueWithLocation {
pub inner: ResolvedVc<Box<dyn Issue>>,
pub severity: IssueSeverity,
pub file_path: FileSystemPath,
pub source: Option<IssueSource>,
}
#[turbo_tasks::value_impl]
impl Issue for ResolvingIssueWithLocation {
fn severity(&self) -> IssueSeverity {
self.severity
}
#[turbo_tasks::function]
fn file_path(&self) -> Vc<FileSystemPath> {
self.file_path.clone().cell()
}
#[turbo_tasks::function]
fn stage(&self) -> Vc<IssueStage> {
self.inner.stage()
}
#[turbo_tasks::function]
fn title(&self) -> Vc<StyledString> {
self.inner.title()
}
#[turbo_tasks::function]
fn description(&self) -> Vc<OptionStyledString> {
self.inner.description()
}
#[turbo_tasks::function]
fn detail(&self) -> Vc<OptionStyledString> {
self.inner.detail()
}
#[turbo_tasks::function]
fn documentation_link(&self) -> Vc<RcStr> {
self.inner.documentation_link()
}
#[turbo_tasks::function]
fn source(&self) -> Vc<OptionIssueSource> {
Vc::cell(self.source)
}
}
...@@ -9,12 +9,15 @@ use turbo_tasks::{ ...@@ -9,12 +9,15 @@ use turbo_tasks::{
}; };
use turbo_tasks_fs::{FileSystemPath, glob::Glob}; use turbo_tasks_fs::{FileSystemPath, glob::Glob};
use crate::resolve::{ use crate::{
issue::Issue,
resolve::{
AliasPattern, ExternalTraced, ExternalType, ResolveResult, ResolveResultItem, AliasPattern, ExternalTraced, ExternalType, ResolveResult, ResolveResultItem,
alias_map::{AliasMap, AliasTemplate}, alias_map::{AliasMap, AliasTemplate},
parse::Request, parse::Request,
pattern::Pattern, pattern::Pattern,
plugin::{AfterResolvePlugin, BeforeResolvePlugin}, plugin::{AfterResolvePlugin, BeforeResolvePlugin},
},
}; };
#[turbo_tasks::value(shared)] #[turbo_tasks::value(shared)]
...@@ -112,8 +115,12 @@ pub enum ImportMapping { ...@@ -112,8 +115,12 @@ pub enum ImportMapping {
/// the original request if it fails. Useful for the tsconfig.json /// the original request if it fails. Useful for the tsconfig.json
/// `compilerOptions.paths` option and Next aliases. /// `compilerOptions.paths` option and Next aliases.
PrimaryAlternative(RcStr, Option<FileSystemPath>), PrimaryAlternative(RcStr, Option<FileSystemPath>),
/// See [`ResolveResultItem::Ignore`]
Ignore, Ignore,
/// See [`ResolveResultItem::Empty`]
Empty, Empty,
/// See [`ResolveResultItem::Error`]
Error(ResolvedVc<Box<dyn Issue>>),
Alternatives(Vec<ResolvedVc<ImportMapping>>), Alternatives(Vec<ResolvedVc<ImportMapping>>),
Dynamic(ResolvedVc<Box<dyn ImportMappingReplacement>>), Dynamic(ResolvedVc<Box<dyn ImportMappingReplacement>>),
} }
...@@ -141,6 +148,7 @@ pub enum ReplacedImportMapping { ...@@ -141,6 +148,7 @@ pub enum ReplacedImportMapping {
Empty, Empty,
Alternatives(Vec<ResolvedVc<ReplacedImportMapping>>), Alternatives(Vec<ResolvedVc<ReplacedImportMapping>>),
Dynamic(ResolvedVc<Box<dyn ImportMappingReplacement>>), Dynamic(ResolvedVc<Box<dyn ImportMappingReplacement>>),
Error(ResolvedVc<Box<dyn Issue>>),
} }
impl ImportMapping { impl ImportMapping {
...@@ -219,6 +227,7 @@ impl AliasTemplate for Vc<ImportMapping> { ...@@ -219,6 +227,7 @@ impl AliasTemplate for Vc<ImportMapping> {
.await?, .await?,
), ),
ImportMapping::Dynamic(replacement) => ReplacedImportMapping::Dynamic(*replacement), ImportMapping::Dynamic(replacement) => ReplacedImportMapping::Dynamic(*replacement),
ImportMapping::Error(issue) => ReplacedImportMapping::Error(*issue),
} }
.resolved_cell()) .resolved_cell())
}) })
...@@ -293,6 +302,7 @@ impl AliasTemplate for Vc<ImportMapping> { ...@@ -293,6 +302,7 @@ impl AliasTemplate for Vc<ImportMapping> {
.owned() .owned()
.await? .await?
} }
ImportMapping::Error(issue) => ReplacedImportMapping::Error(*issue),
} }
.resolved_cell()) .resolved_cell())
}) })
...@@ -415,6 +425,7 @@ pub enum ImportMapResult { ...@@ -415,6 +425,7 @@ pub enum ImportMapResult {
Alias(ResolvedVc<Request>, Option<FileSystemPath>), Alias(ResolvedVc<Request>, Option<FileSystemPath>),
Alternatives(Vec<ImportMapResult>), Alternatives(Vec<ImportMapResult>),
NoEntry, NoEntry,
Error(ResolvedVc<Box<dyn Issue>>),
} }
async fn import_mapping_to_result( async fn import_mapping_to_result(
...@@ -489,6 +500,7 @@ async fn import_mapping_to_result( ...@@ -489,6 +500,7 @@ async fn import_mapping_to_result(
ReplacedImportMapping::Dynamic(replacement) => { ReplacedImportMapping::Dynamic(replacement) => {
replacement.result(lookup_path, request).owned().await? replacement.result(lookup_path, request).owned().await?
} }
ReplacedImportMapping::Error(issue) => ImportMapResult::Error(*issue),
}) })
} }
...@@ -529,6 +541,9 @@ impl ValueToString for ImportMapResult { ...@@ -529,6 +541,9 @@ impl ValueToString for ImportMapResult {
Ok(Vc::cell(strings.join(" | ").into())) Ok(Vc::cell(strings.join(" | ").into()))
} }
ImportMapResult::NoEntry => Ok(Vc::cell(rcstr!("No import map entry"))), ImportMapResult::NoEntry => Ok(Vc::cell(rcstr!("No import map entry"))),
ImportMapResult::Error(issue) => Ok(Vc::cell(
format!("error: {}", issue.title().await?.to_unstyled_string()).into(),
)),
} }
} }
} }
......
...@@ -18,7 +18,7 @@ use turbo_tasks::{ ...@@ -18,7 +18,7 @@ use turbo_tasks::{
use turbopack_core::{ use turbopack_core::{
chunk::{ChunkableModule, ChunkingContext, ModuleChunkItemIdExt, ModuleId}, chunk::{ChunkableModule, ChunkingContext, ModuleChunkItemIdExt, ModuleId},
issue::{ issue::{
IssueExt, IssueSeverity, StyledString, code_gen::CodeGenerationIssue, Issue, IssueExt, IssueSeverity, StyledString, code_gen::CodeGenerationIssue,
module::emit_unknown_module_type_error, module::emit_unknown_module_type_error,
}, },
resolve::{ resolve::{
...@@ -324,8 +324,10 @@ async fn to_single_pattern_mapping( ...@@ -324,8 +324,10 @@ async fn to_single_pattern_mapping(
"unknown module type".to_string(), "unknown module type".to_string(),
)); ));
} }
ModuleResolveResultItem::Error(str) => { ModuleResolveResultItem::Error(issue) => {
return Ok(SinglePatternMapping::Unresolvable(str.await?.to_string())); return Ok(SinglePatternMapping::Unresolvable(
issue.title().await?.to_unstyled_string(),
));
} }
ModuleResolveResultItem::OutputAsset(_) ModuleResolveResultItem::OutputAsset(_)
| ModuleResolveResultItem::Empty | ModuleResolveResultItem::Empty
......
...@@ -18,8 +18,9 @@ use turbopack_core::{ ...@@ -18,8 +18,9 @@ use turbopack_core::{
reference::ModuleReference, reference::ModuleReference,
reference_type::{ReferenceType, WorkerReferenceSubType}, reference_type::{ReferenceType, WorkerReferenceSubType},
resolve::{ resolve::{
ModuleResolveResult, ModuleResolveResultItem, ResolveErrorMode, handle_resolve_error, ModuleResolveResult, ModuleResolveResultItem, ResolveErrorMode,
origin::ResolveOrigin, parse::Request, pattern::Pattern, resolve_raw, url_resolve, error::handle_resolve_error, origin::ResolveOrigin, parse::Request, pattern::Pattern,
resolve_raw, url_resolve,
}, },
}; };
......
...@@ -5,8 +5,8 @@ use turbopack_core::{ ...@@ -5,8 +5,8 @@ use turbopack_core::{
issue::IssueSource, issue::IssueSource,
reference_type::{CommonJsReferenceSubType, EcmaScriptModulesReferenceSubType, ReferenceType}, reference_type::{CommonJsReferenceSubType, EcmaScriptModulesReferenceSubType, ReferenceType},
resolve::{ resolve::{
ModuleResolveResult, ResolveErrorMode, ResolveResult, handle_resolve_error, ModuleResolveResult, ResolveErrorMode, ResolveResult,
handle_resolve_source_error, error::{handle_resolve_error, handle_resolve_source_error},
options::{ options::{
ConditionValue, ResolutionConditions, ResolveInPackage, ResolveIntoPackage, ConditionValue, ResolutionConditions, ResolveInPackage, ResolveIntoPackage,
ResolveOptions, ResolveOptions,
......
...@@ -15,7 +15,8 @@ use turbopack_core::{ ...@@ -15,7 +15,8 @@ use turbopack_core::{
}, },
reference_type::{ReferenceType, TypeScriptReferenceSubType}, reference_type::{ReferenceType, TypeScriptReferenceSubType},
resolve::{ resolve::{
AliasPattern, ModuleResolveResult, RequestKey, ResolveErrorMode, handle_resolve_error, AliasPattern, ModuleResolveResult, RequestKey, ResolveErrorMode,
error::handle_resolve_error,
node::node_cjs_resolve_options, node::node_cjs_resolve_options,
options::{ options::{
ConditionValue, ImportMap, ImportMapping, ResolveIntoPackage, ResolveModules, ConditionValue, ImportMap, ImportMapping, ResolveIntoPackage, ResolveModules,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment