turbopack_core/issue/
module.rs1use anyhow::Result;
2use turbo_tasks::{ResolvedVc, Vc};
3use turbo_tasks_fs::FileSystemPath;
4
5use super::{Issue, IssueStage, OptionStyledString, StyledString};
6use crate::{ident::AssetIdent, issue::IssueExt, source::Source};
7
8#[turbo_tasks::value(shared)]
9pub struct ModuleIssue {
10 pub ident: ResolvedVc<AssetIdent>,
11 pub title: ResolvedVc<StyledString>,
12 pub description: ResolvedVc<StyledString>,
13}
14
15#[turbo_tasks::value_impl]
16impl Issue for ModuleIssue {
17 #[turbo_tasks::function]
18 fn stage(&self) -> Vc<IssueStage> {
19 IssueStage::ProcessModule.cell()
20 }
21
22 #[turbo_tasks::function]
23 fn file_path(&self) -> Vc<FileSystemPath> {
24 self.ident.path()
25 }
26
27 #[turbo_tasks::function]
28 fn title(&self) -> Vc<StyledString> {
29 *self.title
30 }
31
32 #[turbo_tasks::function]
33 fn description(&self) -> Vc<OptionStyledString> {
34 Vc::cell(Some(self.description))
35 }
36}
37
38#[turbo_tasks::function]
39pub async fn emit_unknown_module_type_error(source: Vc<Box<dyn Source>>) -> Result<()> {
40 ModuleIssue {
41 ident: source.ident().to_resolved().await?,
42 title: StyledString::Text("Unknown module type".into()).resolved_cell(),
43 description: StyledString::Text(
44 r"This module doesn't have an associated type. Use a known file extension, or register a loader for it.
45
46Read more: https://nextjs.org/docs/app/api-reference/next-config-js/turbo#webpack-loaders".into(),
47 )
48 .resolved_cell(),
49 }
50 .resolved_cell()
51 .emit();
52
53 Ok(())
54}