Skip to content

Commit

Permalink
refactor(turbopack): remove next.js specific unsupported warn (#4697)
Browse files Browse the repository at this point in the history
### Description

WEB-953. 

This PR removes check for next.js specific unsupported packages.
Instead, let next-* (next-core) handles it via resolve plugin. See
vercel/next.js#48837 for the corresponding
change. This change makes turbopack does not need to aware specific
next.js package names.
  • Loading branch information
kwonoj committed Apr 26, 2023
1 parent 3b3243a commit 946307c
Showing 1 changed file with 3 additions and 54 deletions.
57 changes: 3 additions & 54 deletions crates/turbopack/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ use ecmascript::{
EcmascriptModuleAssetVc,
};
use graph::{aggregate, AggregatedGraphNodeContent, AggregatedGraphVc};
use lazy_static::lazy_static;
use module_options::{
ModuleOptionsContextVc, ModuleOptionsVc, ModuleRuleEffect, ModuleType, ModuleTypeVc,
};
Expand All @@ -36,16 +35,13 @@ use turbopack_core::{
compile_time_info::CompileTimeInfoVc,
context::{AssetContext, AssetContextVc},
ident::AssetIdentVc,
issue::{unsupported_module::UnsupportedModuleIssue, Issue, IssueVc},
issue::{Issue, IssueVc},
plugin::CustomModuleType,
reference::all_referenced_assets,
reference_type::{EcmaScriptModulesReferenceSubType, ReferenceType},
resolve::{
options::ResolveOptionsVc,
origin::PlainResolveOriginVc,
parse::{Request, RequestVc},
pattern::Pattern,
resolve, ModulePartVc, ResolveResultVc,
options::ResolveOptionsVc, origin::PlainResolveOriginVc, parse::RequestVc, resolve,
ModulePartVc, ResolveResultVc,
},
};

Expand All @@ -71,12 +67,6 @@ use self::{
transition::{TransitionVc, TransitionsByNameVc},
};

lazy_static! {
static ref UNSUPPORTED_PACKAGES: HashSet<String> = ["@vercel/og".to_owned()].into();
static ref UNSUPPORTED_PACKAGE_PATHS: HashSet<(String, String)> =
[("@next/font".to_owned(), "/local".to_owned())].into();
}

#[turbo_tasks::value]
struct ModuleIssue {
ident: AssetIdentVc,
Expand Down Expand Up @@ -393,8 +383,6 @@ impl AssetContext for ModuleAssetContext {
resolve_options: ResolveOptionsVc,
reference_type: Value<ReferenceType>,
) -> Result<ResolveResultVc> {
warn_on_unsupported_modules(request, origin_path).await?;

let context_path = origin_path.parent().resolve().await?;

let result = resolve(context_path, request, resolve_options);
Expand Down Expand Up @@ -574,45 +562,6 @@ async fn top_references(list: ReferencesListVc) -> Result<ReferencesListVc> {
.into())
}

async fn warn_on_unsupported_modules(
request: RequestVc,
origin_path: FileSystemPathVc,
) -> Result<()> {
if let Request::Module {
module,
path,
query: _,
} = &*request.await?
{
// Warn if the package is known not to be supported by Turbopack at the moment.
if UNSUPPORTED_PACKAGES.contains(module) {
UnsupportedModuleIssue {
context: origin_path,
package: module.into(),
package_path: None,
}
.cell()
.as_issue()
.emit();
}

if let Pattern::Constant(path) = path {
if UNSUPPORTED_PACKAGE_PATHS.contains(&(module.to_string(), path.to_owned())) {
UnsupportedModuleIssue {
context: origin_path,
package: module.into(),
package_path: Some(path.to_owned()),
}
.cell()
.as_issue()
.emit();
}
}
}

Ok(())
}

pub fn register() {
turbo_tasks::register();
turbo_tasks_fs::register();
Expand Down

0 comments on commit 946307c

Please sign in to comment.