Unverified Commit bcabce70 authored by Donny/강동윤's avatar Donny/강동윤 Committed by GitHub

refactor(turbopack): Use `ResolvedVc` for `turbopack-ecmascript` (#72564)

### What?

Use `ResolvedVc` for struct fields in `turbopack-ecmascript` crate

### Why?

Follow-up of https://github.com/vercel/next.js/pull/72200,
https://github.com/vercel/next.js/pull/72382,
https://github.com/vercel/next.js/pull/72320

### How?

Closes PACK-3438

---------
Co-authored-by: 's avatarBenjamin Woodruff <benjamin.woodruff@vercel.com>
parent 16bee25a
......@@ -2,15 +2,16 @@ use anyhow::Result;
use async_trait::async_trait;
use next_custom_transforms::transforms::debug_fn_name::debug_fn_name;
use swc_core::ecma::{ast::Program, visit::VisitMutWith};
use turbo_tasks::{ResolvedVc, Vc};
use turbo_tasks::ResolvedVc;
use turbopack::module_options::{ModuleRule, ModuleRuleEffect};
use turbopack_ecmascript::{CustomTransformer, EcmascriptInputTransform, TransformContext};
use super::module_rule_match_js_no_url;
pub fn get_debug_fn_name_rule(enable_mdx_rs: bool) -> ModuleRule {
let debug_fn_name_transform =
EcmascriptInputTransform::Plugin(Vc::cell(Box::new(DebugFnNameTransformer {}) as _));
let debug_fn_name_transform = EcmascriptInputTransform::Plugin(ResolvedVc::cell(Box::new(
DebugFnNameTransformer {},
) as _));
ModuleRule::new(
module_rule_match_js_no_url(enable_mdx_rs),
......
......@@ -31,7 +31,7 @@ pub use next_font::get_next_font_transform_rule;
pub use next_lint::get_next_lint_transform_rule;
pub use next_strip_page_exports::get_next_pages_transforms_rule;
pub use server_actions::get_server_actions_transform_rule;
use turbo_tasks::{ReadRef, ResolvedVc, Value, Vc};
use turbo_tasks::{ReadRef, ResolvedVc, Value};
use turbo_tasks_fs::FileSystemPath;
use turbopack::module_options::{ModuleRule, ModuleRuleEffect, ModuleType, RuleCondition};
use turbopack_core::reference_type::{ReferenceType, UrlReferenceSubType};
......@@ -136,7 +136,7 @@ pub(crate) fn get_ecma_transform_rule(
enable_mdx_rs: bool,
prepend: bool,
) -> ModuleRule {
let transformer = EcmascriptInputTransform::Plugin(Vc::cell(transformer as _));
let transformer = EcmascriptInputTransform::Plugin(ResolvedVc::cell(transformer as _));
let (prepend, append) = if prepend {
(
ResolvedVc::cell(vec![transformer]),
......
......@@ -5,7 +5,7 @@ use async_trait::async_trait;
use modularize_imports::{modularize_imports, PackageConfig};
use serde::{Deserialize, Serialize};
use swc_core::ecma::ast::Program;
use turbo_tasks::{trace::TraceRawVcs, FxIndexMap, ResolvedVc, Vc};
use turbo_tasks::{trace::TraceRawVcs, FxIndexMap, ResolvedVc};
use turbopack::module_options::{ModuleRule, ModuleRuleEffect};
use turbopack_ecmascript::{CustomTransformer, EcmascriptInputTransform, TransformContext};
......@@ -35,7 +35,7 @@ pub fn get_next_modularize_imports_rule(
modularize_imports_config: &FxIndexMap<String, ModularizeImportPackageConfig>,
enable_mdx_rs: bool,
) -> ModuleRule {
let transformer = EcmascriptInputTransform::Plugin(Vc::cell(Box::new(
let transformer = EcmascriptInputTransform::Plugin(ResolvedVc::cell(Box::new(
ModularizeImportsTransformer::new(modularize_imports_config),
) as _));
ModuleRule::new(
......
......@@ -2,7 +2,7 @@ use anyhow::Result;
use async_trait::async_trait;
use next_custom_transforms::transforms::amp_attributes::amp_attributes;
use swc_core::ecma::ast::*;
use turbo_tasks::{ResolvedVc, Vc};
use turbo_tasks::ResolvedVc;
use turbopack::module_options::{ModuleRule, ModuleRuleEffect};
use turbopack_ecmascript::{CustomTransformer, EcmascriptInputTransform, TransformContext};
......@@ -10,7 +10,7 @@ use super::module_rule_match_js_no_url;
pub fn get_next_amp_attr_rule(enable_mdx_rs: bool) -> ModuleRule {
let transformer =
EcmascriptInputTransform::Plugin(Vc::cell(Box::new(NextAmpAttributes {}) as _));
EcmascriptInputTransform::Plugin(ResolvedVc::cell(Box::new(NextAmpAttributes {}) as _));
ModuleRule::new(
module_rule_match_js_no_url(enable_mdx_rs),
vec![ModuleRuleEffect::ExtendEcmascriptTransforms {
......
......@@ -6,7 +6,7 @@ use swc_core::{
common::SyntaxContext,
ecma::{ast::*, visit::VisitMutWith},
};
use turbo_tasks::{ResolvedVc, Vc};
use turbo_tasks::ResolvedVc;
use turbopack::module_options::{ModuleRule, ModuleRuleEffect};
use turbopack_ecmascript::{CustomTransformer, EcmascriptInputTransform, TransformContext};
......@@ -47,8 +47,9 @@ pub fn get_next_cjs_optimizer_rule(enable_mdx_rs: bool) -> ModuleRule {
)]),
};
let transformer =
EcmascriptInputTransform::Plugin(Vc::cell(Box::new(NextCjsOptimizer { config }) as _));
let transformer = EcmascriptInputTransform::Plugin(ResolvedVc::cell(
Box::new(NextCjsOptimizer { config }) as _,
));
ModuleRule::new(
module_rule_match_js_no_url(enable_mdx_rs),
vec![ModuleRuleEffect::ExtendEcmascriptTransforms {
......
......@@ -2,7 +2,7 @@ use anyhow::Result;
use async_trait::async_trait;
use next_custom_transforms::transforms::disallow_re_export_all_in_page::disallow_re_export_all_in_page;
use swc_core::ecma::ast::*;
use turbo_tasks::{ReadRef, ResolvedVc, Vc};
use turbo_tasks::{ReadRef, ResolvedVc};
use turbo_tasks_fs::FileSystemPath;
use turbopack::module_options::{ModuleRule, ModuleRuleEffect};
use turbopack_ecmascript::{CustomTransformer, EcmascriptInputTransform, TransformContext};
......@@ -13,8 +13,9 @@ pub fn get_next_disallow_export_all_in_page_rule(
enable_mdx_rs: bool,
pages_dir: ReadRef<FileSystemPath>,
) -> ModuleRule {
let transformer =
EcmascriptInputTransform::Plugin(Vc::cell(Box::new(NextDisallowReExportAllInPage) as _));
let transformer = EcmascriptInputTransform::Plugin(ResolvedVc::cell(Box::new(
NextDisallowReExportAllInPage,
) as _));
ModuleRule::new(
module_rule_match_pages_page_file(enable_mdx_rs, pages_dir),
vec![ModuleRuleEffect::ExtendEcmascriptTransforms {
......
......@@ -17,12 +17,13 @@ pub async fn get_next_dynamic_transform_rule(
mode: Vc<NextMode>,
enable_mdx_rs: bool,
) -> Result<ModuleRule> {
let dynamic_transform = EcmascriptInputTransform::Plugin(Vc::cell(Box::new(NextJsDynamic {
is_server_compiler,
is_react_server_layer,
is_app_dir,
mode: *mode.await?,
}) as _));
let dynamic_transform =
EcmascriptInputTransform::Plugin(ResolvedVc::cell(Box::new(NextJsDynamic {
is_server_compiler,
is_react_server_layer,
is_app_dir,
mode: *mode.await?,
}) as _));
Ok(ModuleRule::new(
module_rule_match_js_no_url(enable_mdx_rs),
vec![ModuleRuleEffect::ExtendEcmascriptTransforms {
......
......@@ -5,7 +5,7 @@ use swc_core::{
common::SyntaxContext,
ecma::{ast::*, utils::ExprCtx, visit::VisitWith},
};
use turbo_tasks::{ResolvedVc, Vc};
use turbo_tasks::ResolvedVc;
use turbopack::module_options::{ModuleRule, ModuleRuleEffect};
use turbopack_ecmascript::{CustomTransformer, EcmascriptInputTransform, TransformContext};
......@@ -16,10 +16,11 @@ pub fn next_edge_node_api_assert(
should_error_for_node_apis: bool,
is_production: bool,
) -> ModuleRule {
let transformer = EcmascriptInputTransform::Plugin(Vc::cell(Box::new(NextEdgeNodeApiAssert {
should_error_for_node_apis,
is_production,
}) as _));
let transformer =
EcmascriptInputTransform::Plugin(ResolvedVc::cell(Box::new(NextEdgeNodeApiAssert {
should_error_for_node_apis,
is_production,
}) as _));
ModuleRule::new(
module_rule_match_js_no_url(enable_mdx_rs),
vec![ModuleRuleEffect::ExtendEcmascriptTransforms {
......
......@@ -2,7 +2,7 @@ use anyhow::Result;
use async_trait::async_trait;
use next_custom_transforms::transforms::fonts::*;
use swc_core::ecma::{ast::Program, atoms::JsWord, visit::VisitMutWith};
use turbo_tasks::{ResolvedVc, Vc};
use turbo_tasks::ResolvedVc;
use turbopack::module_options::{ModuleRule, ModuleRuleEffect};
use turbopack_ecmascript::{CustomTransformer, EcmascriptInputTransform, TransformContext};
......@@ -18,7 +18,9 @@ pub fn get_next_font_transform_rule(enable_mdx_rs: bool) -> ModuleRule {
];
let transformer =
EcmascriptInputTransform::Plugin(Vc::cell(Box::new(NextJsFont { font_loaders }) as _));
EcmascriptInputTransform::Plugin(ResolvedVc::cell(
Box::new(NextJsFont { font_loaders }) as _
));
ModuleRule::new(
// TODO: Only match in pages (not pages/api), app/, etc.
module_rule_match_js_no_url(enable_mdx_rs),
......
......@@ -2,15 +2,16 @@ use anyhow::Result;
use async_trait::async_trait;
use next_custom_transforms::transforms::middleware_dynamic::next_middleware_dynamic;
use swc_core::ecma::{ast::*, visit::VisitMutWith};
use turbo_tasks::{ResolvedVc, Vc};
use turbo_tasks::ResolvedVc;
use turbopack::module_options::{ModuleRule, ModuleRuleEffect};
use turbopack_ecmascript::{CustomTransformer, EcmascriptInputTransform, TransformContext};
use super::module_rule_match_js_no_url;
pub fn get_middleware_dynamic_assert_rule(enable_mdx_rs: bool) -> ModuleRule {
let transformer =
EcmascriptInputTransform::Plugin(Vc::cell(Box::new(NextMiddlewareDynamicAssert {}) as _));
let transformer = EcmascriptInputTransform::Plugin(ResolvedVc::cell(Box::new(
NextMiddlewareDynamicAssert {},
) as _));
ModuleRule::new(
module_rule_match_js_no_url(enable_mdx_rs),
vec![ModuleRuleEffect::ExtendEcmascriptTransforms {
......
......@@ -2,7 +2,7 @@ use anyhow::Result;
use async_trait::async_trait;
use next_custom_transforms::transforms::optimize_server_react::{optimize_server_react, Config};
use swc_core::ecma::ast::*;
use turbo_tasks::{ResolvedVc, Vc};
use turbo_tasks::ResolvedVc;
use turbopack::module_options::{ModuleRule, ModuleRuleEffect};
use turbopack_ecmascript::{CustomTransformer, EcmascriptInputTransform, TransformContext};
......@@ -14,7 +14,7 @@ pub fn get_next_optimize_server_react_rule(
optimize_use_state: bool,
) -> ModuleRule {
let transformer =
EcmascriptInputTransform::Plugin(Vc::cell(Box::new(NextOptimizeServerReact {
EcmascriptInputTransform::Plugin(ResolvedVc::cell(Box::new(NextOptimizeServerReact {
optimize_use_state,
}) as _));
ModuleRule::new(
......
......@@ -2,7 +2,7 @@ use anyhow::Result;
use async_trait::async_trait;
use next_custom_transforms::transforms::page_config::page_config;
use swc_core::ecma::ast::*;
use turbo_tasks::{ReadRef, ResolvedVc, Vc};
use turbo_tasks::{ReadRef, ResolvedVc};
use turbo_tasks_fs::FileSystemPath;
use turbopack::module_options::{ModuleRule, ModuleRuleEffect};
use turbopack_ecmascript::{CustomTransformer, EcmascriptInputTransform, TransformContext};
......@@ -13,7 +13,7 @@ pub fn get_next_page_config_rule(
enable_mdx_rs: bool,
pages_dir: ReadRef<FileSystemPath>,
) -> ModuleRule {
let transformer = EcmascriptInputTransform::Plugin(Vc::cell(Box::new(NextPageConfig {
let transformer = EcmascriptInputTransform::Plugin(ResolvedVc::cell(Box::new(NextPageConfig {
// [TODO]: update once turbopack build works
is_development: true,
}) as _));
......
......@@ -25,10 +25,11 @@ pub fn get_next_page_static_info_assert_rule(
server_context: Option<ServerContextType>,
client_context: Option<ClientContextType>,
) -> ModuleRule {
let transformer = EcmascriptInputTransform::Plugin(Vc::cell(Box::new(NextPageStaticInfo {
server_context,
client_context,
}) as _));
let transformer =
EcmascriptInputTransform::Plugin(ResolvedVc::cell(Box::new(NextPageStaticInfo {
server_context,
client_context,
}) as _));
ModuleRule::new(
module_rule_match_js_no_url(enable_mdx_rs),
vec![ModuleRuleEffect::ExtendEcmascriptTransforms {
......@@ -129,7 +130,7 @@ impl CustomTransformer for NextPageStaticInfo {
#[turbo_tasks::value(shared)]
pub struct PageStaticInfoIssue {
pub file_path: Vc<FileSystemPath>,
pub file_path: ResolvedVc<FileSystemPath>,
pub messages: Vec<String>,
pub severity: IssueSeverity,
}
......@@ -153,7 +154,7 @@ impl Issue for PageStaticInfoIssue {
#[turbo_tasks::function]
fn file_path(&self) -> Vc<FileSystemPath> {
self.file_path
*self.file_path
}
#[turbo_tasks::function]
......
......@@ -2,14 +2,15 @@ use anyhow::Result;
use async_trait::async_trait;
use next_custom_transforms::transforms::pure::pure_magic;
use swc_core::ecma::{ast::*, visit::VisitMutWith};
use turbo_tasks::{ResolvedVc, Vc};
use turbo_tasks::ResolvedVc;
use turbopack::module_options::{ModuleRule, ModuleRuleEffect};
use turbopack_ecmascript::{CustomTransformer, EcmascriptInputTransform, TransformContext};
use super::module_rule_match_js_no_url;
pub fn get_next_pure_rule(enable_mdx_rs: bool) -> ModuleRule {
let transformer = EcmascriptInputTransform::Plugin(Vc::cell(Box::new(NextPure {}) as _));
let transformer =
EcmascriptInputTransform::Plugin(ResolvedVc::cell(Box::new(NextPure {}) as _));
ModuleRule::new(
module_rule_match_js_no_url(enable_mdx_rs),
vec![ModuleRuleEffect::ExtendEcmascriptTransforms {
......
......@@ -2,7 +2,7 @@ use anyhow::Result;
use async_trait::async_trait;
use next_custom_transforms::transforms::shake_exports::{shake_exports, Config};
use swc_core::ecma::ast::*;
use turbo_tasks::{ResolvedVc, Vc};
use turbo_tasks::ResolvedVc;
use turbopack::module_options::{ModuleRule, ModuleRuleEffect};
use turbopack_ecmascript::{CustomTransformer, EcmascriptInputTransform, TransformContext};
......@@ -10,8 +10,9 @@ use super::module_rule_match_js_no_url;
#[allow(dead_code)]
pub fn get_next_shake_exports_rule(enable_mdx_rs: bool, ignore: Vec<String>) -> ModuleRule {
let transformer =
EcmascriptInputTransform::Plugin(Vc::cell(Box::new(NextShakeExports { ignore }) as _));
let transformer = EcmascriptInputTransform::Plugin(ResolvedVc::cell(
Box::new(NextShakeExports { ignore }) as _,
));
ModuleRule::new(
module_rule_match_js_no_url(enable_mdx_rs),
vec![ModuleRuleEffect::ExtendEcmascriptTransforms {
......
......@@ -18,9 +18,10 @@ pub async fn get_next_pages_transforms_rule(
enable_mdx_rs: bool,
) -> Result<ModuleRule> {
// Apply the Next SSG transform to all pages.
let strip_transform = EcmascriptInputTransform::Plugin(Vc::cell(Box::new(
NextJsStripPageExports { export_filter },
) as _));
let strip_transform =
EcmascriptInputTransform::Plugin(ResolvedVc::cell(Box::new(NextJsStripPageExports {
export_filter,
}) as _));
Ok(ModuleRule::new(
RuleCondition::all(vec![
RuleCondition::all(vec![
......
......@@ -2,7 +2,7 @@ use anyhow::Result;
use async_trait::async_trait;
use next_custom_transforms::transforms::server_actions::{server_actions, Config};
use swc_core::{common::FileName, ecma::ast::Program};
use turbo_tasks::{ResolvedVc, Vc};
use turbo_tasks::ResolvedVc;
use turbopack::module_options::{ModuleRule, ModuleRuleEffect};
use turbopack_ecmascript::{CustomTransformer, EcmascriptInputTransform, TransformContext};
......@@ -20,10 +20,11 @@ pub fn get_server_actions_transform_rule(
enable_mdx_rs: bool,
dynamic_io_enabled: bool,
) -> ModuleRule {
let transformer = EcmascriptInputTransform::Plugin(Vc::cell(Box::new(NextServerActions {
transform,
dynamic_io_enabled,
}) as _));
let transformer =
EcmascriptInputTransform::Plugin(ResolvedVc::cell(Box::new(NextServerActions {
transform,
dynamic_io_enabled,
}) as _));
ModuleRule::new(
module_rule_match_js_no_url(enable_mdx_rs),
vec![ModuleRuleEffect::ExtendEcmascriptTransforms {
......
......@@ -145,16 +145,16 @@ async fn get_client_module_options_context(
conditions,
vec![ModuleRuleEffect::ExtendEcmascriptTransforms {
prepend: ResolvedVc::cell(vec![
EcmascriptInputTransform::Plugin(Vc::cell(Box::new(
EcmascriptInputTransform::Plugin(ResolvedVc::cell(Box::new(
EmotionTransformer::new(&EmotionTransformConfig::default())
.expect("Should be able to create emotion transformer"),
) as _)),
EcmascriptInputTransform::Plugin(Vc::cell(Box::new(
EcmascriptInputTransform::Plugin(ResolvedVc::cell(Box::new(
StyledComponentsTransformer::new(&StyledComponentsTransformConfig::default()),
) as _)),
EcmascriptInputTransform::Plugin(Vc::cell(Box::new(StyledJsxTransformer::new(
versions,
)) as _)),
EcmascriptInputTransform::Plugin(ResolvedVc::cell(Box::new(
StyledJsxTransformer::new(versions),
) as _)),
]),
append: ResolvedVc::cell(vec![]),
}],
......
......@@ -64,10 +64,10 @@ pub async fn children_from_module_references(
let key = reference_ty();
let mut children = FxIndexSet::default();
let references = references.await?;
for reference in &*references {
for &reference in &*references {
let mut key = key;
if let Some(chunkable) =
Vc::try_resolve_downcast::<Box<dyn ChunkableModuleReference>>(*reference).await?
Vc::try_resolve_downcast::<Box<dyn ChunkableModuleReference>>(reference).await?
{
match &*chunkable.chunking_type().await? {
None => {}
......
use anyhow::Result;
use async_trait::async_trait;
use swc_core::ecma::ast::Program;
use turbo_tasks::Vc;
use turbo_tasks::{ResolvedVc, Vc};
use turbo_tasks_fs::FileSystemPath;
use turbopack_core::issue::{Issue, IssueSeverity, IssueStage, OptionStyledString, StyledString};
use turbopack_ecmascript::{CustomTransformer, TransformContext};
......@@ -49,7 +49,7 @@ impl SwcPluginModule {
#[turbo_tasks::value(shared)]
struct UnsupportedSwcEcmaTransformPluginsIssue {
pub file_path: Vc<FileSystemPath>,
pub file_path: ResolvedVc<FileSystemPath>,
}
#[turbo_tasks::value_impl]
......@@ -72,7 +72,7 @@ impl Issue for UnsupportedSwcEcmaTransformPluginsIssue {
#[turbo_tasks::function]
fn file_path(&self) -> Vc<FileSystemPath> {
self.file_path
*self.file_path
}
#[turbo_tasks::function]
......
......@@ -26,7 +26,7 @@ use swc_core::{
},
};
use turbo_rcstr::RcStr;
use turbo_tasks::{FxIndexMap, FxIndexSet, Vc};
use turbo_tasks::{FxIndexMap, FxIndexSet, ResolvedVc, Vc};
use turbopack_core::compile_time_info::{
CompileTimeDefineValue, DefineableNameSegment, FreeVarReference,
};
......@@ -3789,9 +3789,9 @@ pub enum WellKnownFunctionKind {
Require,
RequireResolve,
RequireContext,
RequireContextRequire(Vc<RequireContextValue>),
RequireContextRequireKeys(Vc<RequireContextValue>),
RequireContextRequireResolve(Vc<RequireContextValue>),
RequireContextRequire(ResolvedVc<RequireContextValue>),
RequireContextRequireKeys(ResolvedVc<RequireContextValue>),
RequireContextRequireResolve(ResolvedVc<RequireContextValue>),
Define,
FsReadMethod(JsWord),
PathToFileUrl,
......@@ -3838,7 +3838,7 @@ fn is_unresolved_id(i: &Id, unresolved_mark: Mark) -> bool {
#[doc(hidden)]
pub mod test_utils {
use anyhow::Result;
use turbo_tasks::{FxIndexMap, Vc};
use turbo_tasks::{FxIndexMap, ResolvedVc, Vc};
use turbopack_core::{compile_time_info::CompileTimeInfo, error::PrettyPrintError};
use super::{
......@@ -3900,7 +3900,7 @@ pub mod test_utils {
map.insert("./c".into(), format!("[context: {}]/c", options.dir).into());
JsValue::WellKnownFunction(WellKnownFunctionKind::RequireContextRequire(
Vc::cell(map),
ResolvedVc::cell(map),
))
}
Err(err) => v.into_unknown(true, PrettyPrintError(&err).to_string()),
......
use std::mem::take;
use anyhow::Result;
use turbo_tasks::Vc;
use turbo_tasks::{ResolvedVc, Vc};
use turbopack_core::compile_time_info::CompileTimeInfo;
use url::Url;
......@@ -354,8 +354,8 @@ pub fn require(args: Vec<JsValue>) -> JsValue {
}
/// (try to) statically evaluate `require.context(...)()`
pub async fn require_context_require(
val: Vc<RequireContextValue>,
async fn require_context_require(
val: ResolvedVc<RequireContextValue>,
args: Vec<JsValue>,
) -> Result<JsValue> {
if args.is_empty() {
......@@ -406,8 +406,8 @@ pub async fn require_context_require(
}
/// (try to) statically evaluate `require.context(...).keys()`
pub async fn require_context_require_keys(
val: Vc<RequireContextValue>,
async fn require_context_require_keys(
val: ResolvedVc<RequireContextValue>,
args: Vec<JsValue>,
) -> Result<JsValue> {
Ok(if args.is_empty() {
......@@ -428,8 +428,8 @@ pub async fn require_context_require_keys(
}
/// (try to) statically evaluate `require.context(...).resolve()`
pub async fn require_context_require_resolve(
val: Vc<RequireContextValue>,
async fn require_context_require_resolve(
val: ResolvedVc<RequireContextValue>,
args: Vec<JsValue>,
) -> Result<JsValue> {
if args.len() != 1 {
......
use anyhow::Result;
use indoc::formatdoc;
use turbo_rcstr::RcStr;
use turbo_tasks::{TryJoinIterExt, Value, Vc};
use turbo_tasks::{ResolvedVc, TryJoinIterExt, Value, Vc};
use turbopack_core::{
chunk::{
ChunkData, ChunkItem, ChunkItemExt, ChunkType, ChunkableModule, ChunkingContext,
......@@ -24,8 +24,8 @@ use crate::{
#[turbo_tasks::value(shared)]
pub struct AsyncLoaderChunkItem {
pub module: Vc<AsyncLoaderModule>,
pub chunking_context: Vc<Box<dyn ChunkingContext>>,
pub module: ResolvedVc<AsyncLoaderModule>,
pub chunking_context: ResolvedVc<Box<dyn ChunkingContext>>,
}
#[turbo_tasks::value_impl]
......@@ -38,7 +38,7 @@ impl AsyncLoaderChunkItem {
.get(
module
.inner
.as_chunk_item(Vc::upcast(self.chunking_context))
.as_chunk_item(*ResolvedVc::upcast(self.chunking_context))
.resolve()
.await?,
)
......@@ -49,7 +49,7 @@ impl AsyncLoaderChunkItem {
}
}
Ok(self.chunking_context.chunk_group_assets(
Vc::upcast(module.inner),
*ResolvedVc::upcast(module.inner),
Value::new(module.availability_info),
))
}
......@@ -68,7 +68,7 @@ impl AsyncLoaderChunkItem {
impl EcmascriptChunkItem for AsyncLoaderChunkItem {
#[turbo_tasks::function]
fn chunking_context(&self) -> Vc<Box<dyn ChunkingContext>> {
self.chunking_context
*self.chunking_context
}
#[turbo_tasks::function]
......@@ -77,11 +77,11 @@ impl EcmascriptChunkItem for AsyncLoaderChunkItem {
let module = this.module.await?;
let id = if let Some(placeable) =
Vc::try_resolve_downcast::<Box<dyn EcmascriptChunkPlaceable>>(module.inner).await?
Vc::try_resolve_downcast::<Box<dyn EcmascriptChunkPlaceable>>(*module.inner).await?
{
Some(
placeable
.as_chunk_item(Vc::upcast(this.chunking_context))
.as_chunk_item(*ResolvedVc::upcast(this.chunking_context))
.id()
.await?,
)
......@@ -198,7 +198,7 @@ impl ChunkItem for AsyncLoaderChunkItem {
#[turbo_tasks::function]
fn chunking_context(&self) -> Vc<Box<dyn ChunkingContext>> {
Vc::upcast(self.chunking_context)
*ResolvedVc::upcast(self.chunking_context)
}
#[turbo_tasks::function]
......@@ -210,6 +210,6 @@ impl ChunkItem for AsyncLoaderChunkItem {
#[turbo_tasks::function]
fn module(&self) -> Vc<Box<dyn Module>> {
Vc::upcast(self.module)
*ResolvedVc::upcast(self.module)
}
}
use anyhow::Result;
use turbo_rcstr::RcStr;
use turbo_tasks::{Value, Vc};
use turbo_tasks::{ResolvedVc, Value, Vc};
use turbopack_core::{
asset::{Asset, AssetContent},
chunk::{availability_info::AvailabilityInfo, ChunkableModule, ChunkingContext},
......@@ -20,8 +20,8 @@ fn modifier() -> Vc<RcStr> {
/// putting it into a separate chunk group.
#[turbo_tasks::value]
pub struct AsyncLoaderModule {
pub inner: Vc<Box<dyn ChunkableModule>>,
pub chunking_context: Vc<Box<dyn ChunkingContext>>,
pub inner: ResolvedVc<Box<dyn ChunkableModule>>,
pub chunking_context: ResolvedVc<Box<dyn ChunkingContext>>,
pub availability_info: AvailabilityInfo,
}
......@@ -29,8 +29,8 @@ pub struct AsyncLoaderModule {
impl AsyncLoaderModule {
#[turbo_tasks::function]
pub fn new(
module: Vc<Box<dyn ChunkableModule>>,
chunking_context: Vc<Box<dyn ChunkingContext>>,
module: ResolvedVc<Box<dyn ChunkableModule>>,
chunking_context: ResolvedVc<Box<dyn ChunkingContext>>,
availability_info: Value<AvailabilityInfo>,
) -> Vc<Self> {
Self::cell(AsyncLoaderModule {
......@@ -55,13 +55,13 @@ fn inner_module_reference_description() -> Vc<RcStr> {
impl Module for AsyncLoaderModule {
#[turbo_tasks::function]
fn ident(&self) -> Vc<AssetIdent> {
Self::asset_ident_for(self.inner)
Self::asset_ident_for(*self.inner)
}
#[turbo_tasks::function]
async fn references(self: Vc<Self>) -> Result<Vc<ModuleReferences>> {
Ok(Vc::cell(vec![Vc::upcast(SingleModuleReference::new(
Vc::upcast(self.await?.inner),
*ResolvedVc::upcast(self.await?.inner),
inner_module_reference_description(),
))]))
}
......@@ -78,9 +78,9 @@ impl Asset for AsyncLoaderModule {
#[turbo_tasks::value_impl]
impl ChunkableModule for AsyncLoaderModule {
#[turbo_tasks::function]
fn as_chunk_item(
self: Vc<Self>,
chunking_context: Vc<Box<dyn ChunkingContext>>,
async fn as_chunk_item(
self: ResolvedVc<Self>,
chunking_context: ResolvedVc<Box<dyn ChunkingContext>>,
) -> Vc<Box<dyn turbopack_core::chunk::ChunkItem>> {
Vc::upcast(
AsyncLoaderChunkItem {
......
......@@ -8,7 +8,7 @@ use std::fmt::Write;
use anyhow::{bail, Result};
use turbo_rcstr::RcStr;
use turbo_tasks::{Value, ValueToString, Vc};
use turbo_tasks::{ResolvedVc, Value, ValueToString, Vc};
use turbo_tasks_fs::FileSystem;
use turbopack_core::{
asset::{Asset, AssetContent},
......@@ -36,16 +36,16 @@ pub use self::{
#[turbo_tasks::value]
pub struct EcmascriptChunk {
pub chunking_context: Vc<Box<dyn ChunkingContext>>,
pub content: Vc<EcmascriptChunkContent>,
pub chunking_context: ResolvedVc<Box<dyn ChunkingContext>>,
pub content: ResolvedVc<EcmascriptChunkContent>,
}
#[turbo_tasks::value_impl]
impl EcmascriptChunk {
#[turbo_tasks::function]
pub fn new(
chunking_context: Vc<Box<dyn ChunkingContext>>,
content: Vc<EcmascriptChunkContent>,
chunking_context: ResolvedVc<Box<dyn ChunkingContext>>,
content: ResolvedVc<EcmascriptChunkContent>,
) -> Vc<Self> {
EcmascriptChunk {
chunking_context,
......@@ -127,7 +127,7 @@ impl Chunk for EcmascriptChunk {
#[turbo_tasks::function]
fn chunking_context(&self) -> Vc<Box<dyn ChunkingContext>> {
Vc::upcast(self.chunking_context)
*ResolvedVc::upcast(self.chunking_context)
}
#[turbo_tasks::function]
......@@ -163,7 +163,7 @@ impl ValueToString for EcmascriptChunk {
impl EcmascriptChunk {
#[turbo_tasks::function]
pub fn chunk_content(&self) -> Vc<EcmascriptChunkContent> {
self.content
*self.content
}
#[turbo_tasks::function]
......
......@@ -38,7 +38,7 @@ enum SideEffectsValue {
#[turbo_tasks::function]
async fn side_effects_from_package_json(
package_json: Vc<FileSystemPath>,
package_json: ResolvedVc<FileSystemPath>,
) -> Result<Vc<SideEffectsValue>> {
if let FileJsonContent::Content(content) = &*package_json.read_json().await? {
if let Some(side_effects) = content.get("sideEffects") {
......@@ -66,7 +66,7 @@ async fn side_effects_from_package_json(
)
.into(),
)
.cell(),
.resolved_cell(),
),
}
.cell()
......@@ -88,7 +88,7 @@ async fn side_effects_from_package_json(
)
.into(),
)
.cell(),
.resolved_cell(),
),
}
.cell()
......@@ -113,7 +113,7 @@ async fn side_effects_from_package_json(
)
.into(),
)
.cell(),
.resolved_cell(),
),
}
.cell()
......@@ -126,8 +126,8 @@ async fn side_effects_from_package_json(
#[turbo_tasks::value]
struct SideEffectsInPackageJsonIssue {
path: Vc<FileSystemPath>,
description: Option<Vc<StyledString>>,
path: ResolvedVc<FileSystemPath>,
description: Option<ResolvedVc<StyledString>>,
}
#[turbo_tasks::value_impl]
......@@ -144,7 +144,7 @@ impl Issue for SideEffectsInPackageJsonIssue {
#[turbo_tasks::function]
fn file_path(&self) -> Vc<FileSystemPath> {
self.path
*self.path
}
#[turbo_tasks::function]
......@@ -154,7 +154,7 @@ impl Issue for SideEffectsInPackageJsonIssue {
#[turbo_tasks::function]
fn description(&self) -> Vc<OptionStyledString> {
Vc::cell(self.description)
Vc::cell(self.description.map(|v| *v))
}
}
......
......@@ -37,9 +37,9 @@ fn modifier() -> Vc<RcStr> {
/// ChunkGroup with the provided ChunkingContext.
#[turbo_tasks::value(shared)]
pub struct ChunkGroupFilesAsset {
pub module: Vc<Box<dyn ChunkableModule>>,
pub client_root: Vc<FileSystemPath>,
pub chunking_context: Vc<Box<dyn ChunkingContext>>,
pub module: ResolvedVc<Box<dyn ChunkableModule>>,
pub client_root: ResolvedVc<FileSystemPath>,
pub chunking_context: ResolvedVc<Box<dyn ChunkingContext>>,
pub runtime_entries: Option<ResolvedVc<EvaluatableAssets>>,
}
......@@ -63,7 +63,7 @@ impl Module for ChunkGroupFilesAsset {
#[turbo_tasks::function]
async fn references(&self) -> Result<Vc<ModuleReferences>> {
let mut references: Vec<Vc<Box<dyn ModuleReference>>> = vec![Vc::upcast(
SingleModuleReference::new(Vc::upcast(self.module), module_description()),
SingleModuleReference::new(*ResolvedVc::upcast(self.module), module_description()),
)];
if let Some(runtime_entries) = self.runtime_entries {
......@@ -91,8 +91,8 @@ impl Asset for ChunkGroupFilesAsset {
impl ChunkableModule for ChunkGroupFilesAsset {
#[turbo_tasks::function]
async fn as_chunk_item(
self: Vc<Self>,
chunking_context: Vc<Box<dyn ChunkingContext>>,
self: ResolvedVc<Self>,
chunking_context: ResolvedVc<Box<dyn ChunkingContext>>,
) -> Result<Vc<Box<dyn turbopack_core::chunk::ChunkItem>>> {
let this = self.await?;
Ok(Vc::upcast(
......@@ -116,9 +116,9 @@ impl EcmascriptChunkPlaceable for ChunkGroupFilesAsset {
#[turbo_tasks::value]
struct ChunkGroupFilesChunkItem {
chunking_context: Vc<Box<dyn ChunkingContext>>,
client_root: Vc<FileSystemPath>,
inner: Vc<ChunkGroupFilesAsset>,
chunking_context: ResolvedVc<Box<dyn ChunkingContext>>,
client_root: ResolvedVc<FileSystemPath>,
inner: ResolvedVc<ChunkGroupFilesAsset>,
}
#[turbo_tasks::value_impl]
......@@ -127,7 +127,7 @@ impl ChunkGroupFilesChunkItem {
async fn chunks(&self) -> Result<Vc<OutputAssets>> {
let inner = self.inner.await?;
let chunks = if let Some(ecma) =
Vc::try_resolve_sidecast::<Box<dyn EvaluatableAsset>>(inner.module).await?
ResolvedVc::try_sidecast::<Box<dyn EvaluatableAsset>>(inner.module).await?
{
inner.chunking_context.evaluated_chunk_group_assets(
inner.module.ident(),
......@@ -136,13 +136,13 @@ impl ChunkGroupFilesChunkItem {
.as_deref()
.copied()
.unwrap_or_else(EvaluatableAssets::empty)
.with_entry(ecma),
.with_entry(*ecma),
Value::new(AvailabilityInfo::Root),
)
} else {
inner
.chunking_context
.root_chunk_group_assets(Vc::upcast(inner.module))
.root_chunk_group_assets(*ResolvedVc::upcast(inner.module))
};
Ok(chunks)
}
......@@ -152,7 +152,7 @@ impl ChunkGroupFilesChunkItem {
impl EcmascriptChunkItem for ChunkGroupFilesChunkItem {
#[turbo_tasks::function]
fn chunking_context(&self) -> Vc<Box<dyn ChunkingContext>> {
self.chunking_context
*self.chunking_context
}
#[turbo_tasks::function]
......@@ -217,7 +217,7 @@ impl ChunkItem for ChunkGroupFilesChunkItem {
#[turbo_tasks::function]
fn chunking_context(&self) -> Vc<Box<dyn ChunkingContext>> {
Vc::upcast(self.chunking_context)
*ResolvedVc::upcast(self.chunking_context)
}
#[turbo_tasks::function]
......@@ -229,7 +229,7 @@ impl ChunkItem for ChunkGroupFilesChunkItem {
#[turbo_tasks::function]
fn module(&self) -> Vc<Box<dyn Module>> {
Vc::upcast(self.inner)
*ResolvedVc::upcast(self.inner)
}
}
......@@ -255,7 +255,7 @@ impl Introspectable for ChunkGroupFilesAsset {
let mut children = FxIndexSet::default();
children.insert((
Vc::cell("inner asset".into()),
IntrospectableModule::new(Vc::upcast(self.module)),
IntrospectableModule::new(*ResolvedVc::upcast(self.module)),
));
Vc::cell(children)
}
......
......@@ -24,14 +24,14 @@ pub struct PreprocessedChildrenIdents {
#[derive(Clone, Hash)]
#[turbo_tasks::value(shared)]
pub enum ReferencedModule {
Module(Vc<Box<dyn Module>>),
Module(ResolvedVc<Box<dyn Module>>),
AsyncLoaderModule(ResolvedVc<Box<dyn Module>>),
}
impl ReferencedModule {
fn module(&self) -> Vc<Box<dyn Module>> {
match *self {
ReferencedModule::Module(module) => module,
ReferencedModule::Module(module) => *module,
ReferencedModule::AsyncLoaderModule(module) => *module,
}
}
......@@ -86,7 +86,7 @@ async fn referenced_modules(module: Vc<Box<dyn Module>>) -> Result<Vc<Referenced
for (module_list, async_loader) in modules_and_async_loaders {
for module in module_list {
if set.insert(module) {
modules.push(ReferencedModule::Module(*module).resolved_cell());
modules.push(ReferencedModule::Module(module).resolved_cell());
}
}
if let Some(async_loader_module) = async_loader {
......@@ -106,7 +106,7 @@ pub async fn get_children_modules(
let parent_module = parent.await?.module();
let mut modules = referenced_modules(parent_module).await?.clone_value();
for module in parent_module.additional_layers_modules().await? {
modules.push(ReferencedModule::Module(**module).resolved_cell());
modules.push(ReferencedModule::Module(*module).resolved_cell());
}
Ok(modules.into_iter())
}
......@@ -125,7 +125,7 @@ pub async fn children_modules_idents(
root_modules
.await?
.iter()
.map(|module| ReferencedModule::Module(**module).resolved_cell())
.map(|module| ReferencedModule::Module(*module).resolved_cell())
.collect::<Vec<_>>(),
get_children_modules,
)
......
......@@ -237,12 +237,12 @@ impl EcmascriptModuleAssetBuilder {
#[turbo_tasks::value]
pub struct EcmascriptModuleAsset {
pub source: Vc<Box<dyn Source>>,
pub asset_context: Vc<Box<dyn AssetContext>>,
pub source: ResolvedVc<Box<dyn Source>>,
pub asset_context: ResolvedVc<Box<dyn AssetContext>>,
pub ty: EcmascriptModuleAssetType,
pub transforms: Vc<EcmascriptInputTransforms>,
pub options: Vc<EcmascriptOptions>,
pub compile_time_info: Vc<CompileTimeInfo>,
pub transforms: ResolvedVc<EcmascriptInputTransforms>,
pub options: ResolvedVc<EcmascriptOptions>,
pub compile_time_info: ResolvedVc<CompileTimeInfo>,
pub inner_assets: Option<ResolvedVc<InnerAssets>>,
#[turbo_tasks(debug_ignore)]
last_successful_parse: turbo_tasks::TransientState<ReadRef<ParseResult>>,
......@@ -380,22 +380,22 @@ impl EcmascriptAnalyzable for EcmascriptModuleAsset {
chunking_context: Vc<Box<dyn ChunkingContext>>,
async_module_info: Option<Vc<AsyncModuleInfo>>,
) -> Result<Vc<EcmascriptModuleContent>> {
let parsed = self.parse().resolve().await?;
let parsed = self.parse().to_resolved().await?;
let analyze = self.analyze().await?;
let module_type_result = *self.determine_module_type().await?;
Ok(EcmascriptModuleContent::new(
parsed,
*parsed,
self.ident(),
module_type_result.module_type,
chunking_context,
analyze.references,
analyze.code_generation,
analyze.async_module,
*analyze.references,
*analyze.code_generation,
*analyze.async_module,
analyze.source_map,
analyze.exports,
*analyze.exports,
async_module_info,
))
}
......@@ -405,13 +405,13 @@ impl EcmascriptAnalyzable for EcmascriptModuleAsset {
impl EcmascriptModuleAsset {
#[turbo_tasks::function]
pub fn new(
source: Vc<Box<dyn Source>>,
asset_context: Vc<Box<dyn AssetContext>>,
source: ResolvedVc<Box<dyn Source>>,
asset_context: ResolvedVc<Box<dyn AssetContext>>,
ty: Value<EcmascriptModuleAssetType>,
transforms: Vc<EcmascriptInputTransforms>,
options: Vc<EcmascriptOptions>,
compile_time_info: Vc<CompileTimeInfo>,
transforms: ResolvedVc<EcmascriptInputTransforms>,
options: ResolvedVc<EcmascriptOptions>,
compile_time_info: ResolvedVc<CompileTimeInfo>,
) -> Vc<Self> {
Self::cell(EcmascriptModuleAsset {
source,
......@@ -428,12 +428,12 @@ impl EcmascriptModuleAsset {
#[turbo_tasks::function]
pub fn new_with_inner_assets(
source: Vc<Box<dyn Source>>,
asset_context: Vc<Box<dyn AssetContext>>,
source: ResolvedVc<Box<dyn Source>>,
asset_context: ResolvedVc<Box<dyn AssetContext>>,
ty: Value<EcmascriptModuleAssetType>,
transforms: Vc<EcmascriptInputTransforms>,
options: Vc<EcmascriptOptions>,
compile_time_info: Vc<CompileTimeInfo>,
transforms: ResolvedVc<EcmascriptInputTransforms>,
options: ResolvedVc<EcmascriptOptions>,
compile_time_info: ResolvedVc<CompileTimeInfo>,
inner_assets: ResolvedVc<InnerAssets>,
) -> Vc<Self> {
Self::cell(EcmascriptModuleAsset {
......@@ -450,7 +450,7 @@ impl EcmascriptModuleAsset {
#[turbo_tasks::function]
pub fn source(&self) -> Vc<Box<dyn Source>> {
self.source
*self.source
}
#[turbo_tasks::function]
......@@ -460,12 +460,12 @@ impl EcmascriptModuleAsset {
#[turbo_tasks::function]
pub fn options(&self) -> Vc<EcmascriptOptions> {
self.options
*self.options
}
#[turbo_tasks::function]
pub fn parse(&self) -> Vc<ParseResult> {
parse(self.source, Value::new(self.ty), self.transforms)
parse(*self.source, Value::new(self.ty), *self.transforms)
}
#[turbo_tasks::function]
......@@ -561,8 +561,8 @@ impl Asset for EcmascriptModuleAsset {
impl ChunkableModule for EcmascriptModuleAsset {
#[turbo_tasks::function]
fn as_chunk_item(
self: Vc<Self>,
chunking_context: Vc<Box<dyn ChunkingContext>>,
self: ResolvedVc<Self>,
chunking_context: ResolvedVc<Box<dyn ChunkingContext>>,
) -> Vc<Box<dyn ChunkItem>> {
Vc::upcast(ModuleChunkItem::cell(ModuleChunkItem {
module: self,
......@@ -575,12 +575,12 @@ impl ChunkableModule for EcmascriptModuleAsset {
impl EcmascriptChunkPlaceable for EcmascriptModuleAsset {
#[turbo_tasks::function]
async fn get_exports(self: Vc<Self>) -> Result<Vc<EcmascriptExports>> {
Ok(self.analyze().await?.exports)
Ok(*self.analyze().await?.exports)
}
#[turbo_tasks::function]
async fn get_async_module(self: Vc<Self>) -> Result<Vc<OptionAsyncModule>> {
Ok(self.analyze().await?.async_module)
Ok(*self.analyze().await?.async_module)
}
}
......@@ -596,7 +596,7 @@ impl ResolveOrigin for EcmascriptModuleAsset {
#[turbo_tasks::function]
fn asset_context(&self) -> Vc<Box<dyn AssetContext>> {
self.asset_context
*self.asset_context
}
#[turbo_tasks::function]
......@@ -615,8 +615,8 @@ impl ResolveOrigin for EcmascriptModuleAsset {
#[turbo_tasks::value]
struct ModuleChunkItem {
module: Vc<EcmascriptModuleAsset>,
chunking_context: Vc<Box<dyn ChunkingContext>>,
module: ResolvedVc<EcmascriptModuleAsset>,
chunking_context: ResolvedVc<Box<dyn ChunkingContext>>,
}
#[turbo_tasks::value_impl]
......@@ -633,7 +633,7 @@ impl ChunkItem for ModuleChunkItem {
#[turbo_tasks::function]
fn chunking_context(&self) -> Vc<Box<dyn ChunkingContext>> {
Vc::upcast(self.chunking_context)
*ResolvedVc::upcast(self.chunking_context)
}
#[turbo_tasks::function]
......@@ -645,13 +645,13 @@ impl ChunkItem for ModuleChunkItem {
#[turbo_tasks::function]
fn module(&self) -> Vc<Box<dyn Module>> {
Vc::upcast(self.module)
*ResolvedVc::upcast(self.module)
}
#[turbo_tasks::function]
async fn is_self_async(&self) -> Result<Vc<bool>> {
if let Some(async_module) = *self.module.get_async_module().await? {
Ok(async_module.is_self_async(self.module.analyze().await?.references))
Ok(async_module.is_self_async(*self.module.analyze().await?.references))
} else {
Ok(Vc::cell(false))
}
......@@ -662,7 +662,7 @@ impl ChunkItem for ModuleChunkItem {
impl EcmascriptChunkItem for ModuleChunkItem {
#[turbo_tasks::function]
fn chunking_context(&self) -> Vc<Box<dyn ChunkingContext>> {
self.chunking_context
*self.chunking_context
}
#[turbo_tasks::function]
......@@ -689,11 +689,11 @@ impl EcmascriptChunkItem for ModuleChunkItem {
// TODO check if we need to pass async_module_info at all
let content = this
.module
.module_content(this.chunking_context, async_module_info);
.module_content(*this.chunking_context, async_module_info);
Ok(EcmascriptChunkItemContent::new(
content,
this.chunking_context,
*this.chunking_context,
this.module.options(),
async_module_options,
))
......
use anyhow::Result;
use turbo_rcstr::RcStr;
use turbo_tasks::{Value, Vc};
use turbo_tasks::{ResolvedVc, Value, Vc};
use turbopack_core::{
asset::{Asset, AssetContent},
chunk::{
......@@ -33,17 +33,17 @@ fn modifier() -> Vc<RcStr> {
/// import appears in.
#[turbo_tasks::value(shared)]
pub struct ManifestAsyncModule {
pub inner: Vc<Box<dyn ChunkableModule>>,
pub chunking_context: Vc<Box<dyn ChunkingContext>>,
pub inner: ResolvedVc<Box<dyn ChunkableModule>>,
pub chunking_context: ResolvedVc<Box<dyn ChunkingContext>>,
pub availability_info: AvailabilityInfo,
}
#[turbo_tasks::value_impl]
impl ManifestAsyncModule {
#[turbo_tasks::function]
pub fn new(
module: Vc<Box<dyn ChunkableModule>>,
chunking_context: Vc<Box<dyn ChunkingContext>>,
pub async fn new(
module: ResolvedVc<Box<dyn ChunkableModule>>,
chunking_context: ResolvedVc<Box<dyn ChunkingContext>>,
availability_info: Value<AvailabilityInfo>,
) -> Vc<Self> {
Self::cell(ManifestAsyncModule {
......@@ -55,8 +55,10 @@ impl ManifestAsyncModule {
#[turbo_tasks::function]
pub(super) fn chunks(&self) -> Vc<OutputAssets> {
self.chunking_context
.chunk_group_assets(Vc::upcast(self.inner), Value::new(self.availability_info))
self.chunking_context.chunk_group_assets(
*ResolvedVc::upcast(self.inner),
Value::new(self.availability_info),
)
}
#[turbo_tasks::function]
......@@ -66,7 +68,7 @@ impl ManifestAsyncModule {
if chunk_items
.get(
this.inner
.as_chunk_item(Vc::upcast(this.chunking_context))
.as_chunk_item(*ResolvedVc::upcast(this.chunking_context))
.resolve()
.await?,
)
......@@ -140,9 +142,9 @@ impl Asset for ManifestAsyncModule {
#[turbo_tasks::value_impl]
impl ChunkableModule for ManifestAsyncModule {
#[turbo_tasks::function]
fn as_chunk_item(
self: Vc<Self>,
chunking_context: Vc<Box<dyn ChunkingContext>>,
async fn as_chunk_item(
self: ResolvedVc<Self>,
chunking_context: ResolvedVc<Box<dyn ChunkingContext>>,
) -> Vc<Box<dyn turbopack_core::chunk::ChunkItem>> {
Vc::upcast(
ManifestChunkItem {
......
use anyhow::Result;
use indoc::formatdoc;
use turbo_tasks::{TryJoinIterExt, Vc};
use turbo_tasks::{ResolvedVc, TryJoinIterExt, Vc};
use turbopack_core::{
chunk::{ChunkData, ChunkItem, ChunkType, ChunkingContext, ChunksData},
ident::AssetIdent,
......@@ -22,8 +22,8 @@ use crate::{
/// __turbopack_import__ the actual module that was dynamically imported.
#[turbo_tasks::value(shared)]
pub(super) struct ManifestChunkItem {
pub chunking_context: Vc<Box<dyn ChunkingContext>>,
pub manifest: Vc<ManifestAsyncModule>,
pub chunking_context: ResolvedVc<Box<dyn ChunkingContext>>,
pub manifest: ResolvedVc<ManifestAsyncModule>,
}
#[turbo_tasks::value_impl]
......@@ -38,7 +38,7 @@ impl ManifestChunkItem {
impl EcmascriptChunkItem for ManifestChunkItem {
#[turbo_tasks::function]
fn chunking_context(&self) -> Vc<Box<dyn ChunkingContext>> {
self.chunking_context
*self.chunking_context
}
#[turbo_tasks::function]
......@@ -95,7 +95,7 @@ impl ChunkItem for ManifestChunkItem {
#[turbo_tasks::function]
fn chunking_context(&self) -> Vc<Box<dyn ChunkingContext>> {
Vc::upcast(self.chunking_context)
*ResolvedVc::upcast(self.chunking_context)
}
#[turbo_tasks::function]
......@@ -107,6 +107,6 @@ impl ChunkItem for ManifestChunkItem {
#[turbo_tasks::function]
fn module(&self) -> Vc<Box<dyn Module>> {
Vc::upcast(self.manifest)
*ResolvedVc::upcast(self.manifest)
}
}
......@@ -3,7 +3,7 @@ use std::io::Write as _;
use anyhow::{anyhow, Result};
use indoc::writedoc;
use turbo_rcstr::RcStr;
use turbo_tasks::{TryJoinIterExt, Vc};
use turbo_tasks::{ResolvedVc, TryJoinIterExt, Vc};
use turbopack_core::{
chunk::{
ChunkData, ChunkItem, ChunkItemExt, ChunkType, ChunkableModule, ChunkingContext, ChunksData,
......@@ -43,16 +43,16 @@ fn modifier() -> Vc<RcStr> {
/// import appears in.
#[turbo_tasks::value]
pub struct ManifestLoaderChunkItem {
manifest: Vc<ManifestAsyncModule>,
chunking_context: Vc<Box<dyn ChunkingContext>>,
manifest: ResolvedVc<ManifestAsyncModule>,
chunking_context: ResolvedVc<Box<dyn ChunkingContext>>,
}
#[turbo_tasks::value_impl]
impl ManifestLoaderChunkItem {
#[turbo_tasks::function]
pub fn new(
manifest: Vc<ManifestAsyncModule>,
chunking_context: Vc<Box<dyn ChunkingContext>>,
manifest: ResolvedVc<ManifestAsyncModule>,
chunking_context: ResolvedVc<Box<dyn ChunkingContext>>,
) -> Vc<Self> {
Self::cell(ManifestLoaderChunkItem {
manifest,
......@@ -125,7 +125,7 @@ impl ChunkItem for ManifestLoaderChunkItem {
#[turbo_tasks::function]
fn chunking_context(&self) -> Vc<Box<dyn ChunkingContext>> {
Vc::upcast(self.chunking_context)
*ResolvedVc::upcast(self.chunking_context)
}
#[turbo_tasks::function]
......@@ -137,7 +137,7 @@ impl ChunkItem for ManifestLoaderChunkItem {
#[turbo_tasks::function]
fn module(&self) -> Vc<Box<dyn Module>> {
Vc::upcast(self.manifest)
*ResolvedVc::upcast(self.manifest)
}
}
......@@ -145,7 +145,7 @@ impl ChunkItem for ManifestLoaderChunkItem {
impl EcmascriptChunkItem for ManifestLoaderChunkItem {
#[turbo_tasks::function]
async fn chunking_context(&self) -> Result<Vc<Box<dyn ChunkingContext>>> {
Ok(self.manifest.await?.chunking_context)
Ok(*self.manifest.await?.chunking_context)
}
#[turbo_tasks::function]
......@@ -165,18 +165,18 @@ impl EcmascriptChunkItem for ManifestLoaderChunkItem {
// exports a promise for all of the necessary chunk loads.
let item_id = &*this
.manifest
.as_chunk_item(Vc::upcast(manifest.chunking_context))
.as_chunk_item(*ResolvedVc::upcast(manifest.chunking_context))
.id()
.await?;
// Finally, we need the id of the module that we're actually trying to
// dynamically import.
let placeable =
Vc::try_resolve_downcast::<Box<dyn EcmascriptChunkPlaceable>>(manifest.inner)
ResolvedVc::try_downcast::<Box<dyn EcmascriptChunkPlaceable>>(manifest.inner)
.await?
.ok_or_else(|| anyhow!("asset is not placeable in ecmascript chunk"))?;
let dynamic_id = &*placeable
.as_chunk_item(Vc::upcast(manifest.chunking_context))
.as_chunk_item(*ResolvedVc::upcast(manifest.chunking_context))
.id()
.await?;
......
......@@ -22,7 +22,7 @@ use swc_core::{
};
use tracing::Instrument;
use turbo_rcstr::RcStr;
use turbo_tasks::{util::WrapFuture, Value, ValueToString, Vc};
use turbo_tasks::{util::WrapFuture, ResolvedVc, Value, ValueToString, Vc};
use turbo_tasks_fs::{FileContent, FileSystemPath};
use turbo_tasks_hash::hash_xxh3_hash64;
use turbopack_core::{
......@@ -155,7 +155,7 @@ impl SourceMapGenConfig for InlineSourcesContentConfig {
#[turbo_tasks::function]
pub async fn parse(
source: Vc<Box<dyn Source>>,
source: ResolvedVc<Box<dyn Source>>,
ty: Value<EcmascriptModuleAssetType>,
transforms: Vc<EcmascriptInputTransforms>,
) -> Result<Vc<ParseResult>> {
......@@ -174,7 +174,7 @@ pub async fn parse(
}
async fn parse_internal(
source: Vc<Box<dyn Source>>,
source: ResolvedVc<Box<dyn Source>>,
ty: Value<EcmascriptModuleAssetType>,
transforms: Vc<EcmascriptInputTransforms>,
) -> Result<Vc<ParseResult>> {
......@@ -253,7 +253,7 @@ async fn parse_file_content(
fs_path: &FileSystemPath,
ident: &str,
file_path_hash: u128,
source: Vc<Box<dyn Source>>,
source: ResolvedVc<Box<dyn Source>>,
ty: EcmascriptModuleAssetType,
transforms: &[EcmascriptInputTransform],
) -> Result<Vc<ParseResult>> {
......@@ -262,14 +262,14 @@ async fn parse_file_content(
true,
false,
Box::new(IssueEmitter::new(
source,
*source,
source_map.clone(),
Some("Ecmascript file had an error".into()),
)),
);
let emitter = Box::new(IssueEmitter::new(
source,
*source,
source_map.clone(),
Some("Parsing ecmascript source code failed".into()),
));
......@@ -396,7 +396,7 @@ async fn parse_file_content(
file_path_str: &fs_path.path,
file_name_str: fs_path.file_name(),
file_name_hash: file_path_hash,
file_path: fs_path_vc,
file_path: fs_path_vc.to_resolved().await?,
};
let span = tracing::trace_span!("transforms");
async {
......@@ -435,7 +435,7 @@ async fn parse_file_content(
unresolved_mark,
top_level_mark,
Some(&comments),
Some(source),
Some(*source),
);
Ok::<ParseResult, anyhow::Error>(ParseResult::Ok {
......@@ -467,7 +467,7 @@ async fn parse_file_content(
#[turbo_tasks::value]
struct ReadSourceIssue {
source: Vc<Box<dyn Source>>,
source: ResolvedVc<Box<dyn Source>>,
error: RcStr,
}
......
......@@ -12,7 +12,8 @@ use swc_core::{
};
use turbo_rcstr::RcStr;
use turbo_tasks::{
debug::ValueDebugFormat, trace::TraceRawVcs, ReadRef, TryJoinIterExt, Value, ValueToString, Vc,
debug::ValueDebugFormat, trace::TraceRawVcs, ReadRef, ResolvedVc, TryJoinIterExt, Value,
ValueToString, Vc,
};
use turbopack_core::{
chunk::{ChunkableModuleReference, ChunkingContext},
......@@ -32,9 +33,9 @@ use crate::{
#[turbo_tasks::value]
#[derive(Hash, Debug)]
pub struct AmdDefineAssetReference {
origin: Vc<Box<dyn ResolveOrigin>>,
request: Vc<Request>,
issue_source: Vc<IssueSource>,
origin: ResolvedVc<Box<dyn ResolveOrigin>>,
request: ResolvedVc<Request>,
issue_source: ResolvedVc<IssueSource>,
in_try: bool,
}
......@@ -42,9 +43,9 @@ pub struct AmdDefineAssetReference {
impl AmdDefineAssetReference {
#[turbo_tasks::function]
pub fn new(
origin: Vc<Box<dyn ResolveOrigin>>,
request: Vc<Request>,
issue_source: Vc<IssueSource>,
origin: ResolvedVc<Box<dyn ResolveOrigin>>,
request: ResolvedVc<Request>,
issue_source: ResolvedVc<IssueSource>,
in_try: bool,
) -> Vc<Self> {
Self::cell(AmdDefineAssetReference {
......@@ -61,9 +62,9 @@ impl ModuleReference for AmdDefineAssetReference {
#[turbo_tasks::function]
fn resolve_reference(&self) -> Vc<ModuleResolveResult> {
cjs_resolve(
self.origin,
self.request,
Some(self.issue_source),
*self.origin,
*self.request,
Some(*self.issue_source),
self.in_try,
)
}
......@@ -107,7 +108,7 @@ pub enum AmdDefineFactoryType {
pub struct AmdDefineWithDependenciesCodeGen {
dependencies_requests: Vec<AmdDefineDependencyElement>,
origin: Vc<Box<dyn ResolveOrigin>>,
path: Vc<AstPath>,
path: ResolvedVc<AstPath>,
factory_type: AmdDefineFactoryType,
issue_source: Vc<IssueSource>,
in_try: bool,
......@@ -117,7 +118,7 @@ impl AmdDefineWithDependenciesCodeGen {
pub fn new(
dependencies_requests: Vec<AmdDefineDependencyElement>,
origin: Vc<Box<dyn ResolveOrigin>>,
path: Vc<AstPath>,
path: ResolvedVc<AstPath>,
factory_type: AmdDefineFactoryType,
issue_source: Vc<IssueSource>,
in_try: bool,
......
......@@ -5,7 +5,7 @@ use swc_core::{
quote,
};
use turbo_rcstr::RcStr;
use turbo_tasks::{Value, ValueToString, Vc};
use turbo_tasks::{ResolvedVc, Value, ValueToString, Vc};
use turbopack_core::{
chunk::{ChunkableModuleReference, ChunkingContext},
issue::IssueSource,
......@@ -24,27 +24,27 @@ use crate::{
#[turbo_tasks::value]
#[derive(Hash, Debug)]
pub struct CjsAssetReference {
pub origin: Vc<Box<dyn ResolveOrigin>>,
pub request: Vc<Request>,
pub issue_source: Vc<IssueSource>,
pub origin: ResolvedVc<Box<dyn ResolveOrigin>>,
pub request: ResolvedVc<Request>,
pub issue_source: ResolvedVc<IssueSource>,
pub in_try: bool,
}
#[turbo_tasks::value_impl]
impl CjsAssetReference {
#[turbo_tasks::function]
pub fn new(
origin: Vc<Box<dyn ResolveOrigin>>,
request: Vc<Request>,
issue_source: Vc<IssueSource>,
pub async fn new(
origin: ResolvedVc<Box<dyn ResolveOrigin>>,
request: ResolvedVc<Request>,
issue_source: ResolvedVc<IssueSource>,
in_try: bool,
) -> Vc<Self> {
Self::cell(CjsAssetReference {
) -> Result<Vc<Self>> {
Ok(Self::cell(CjsAssetReference {
origin,
request,
issue_source,
in_try,
})
}))
}
}
......@@ -53,9 +53,9 @@ impl ModuleReference for CjsAssetReference {
#[turbo_tasks::function]
fn resolve_reference(&self) -> Vc<ModuleResolveResult> {
cjs_resolve(
self.origin,
self.request,
Some(self.issue_source),
*self.origin,
*self.request,
Some(*self.issue_source),
self.in_try,
)
}
......@@ -77,10 +77,10 @@ impl ChunkableModuleReference for CjsAssetReference {}
#[turbo_tasks::value]
#[derive(Hash, Debug)]
pub struct CjsRequireAssetReference {
pub origin: Vc<Box<dyn ResolveOrigin>>,
pub request: Vc<Request>,
pub path: Vc<AstPath>,
pub issue_source: Vc<IssueSource>,
pub origin: ResolvedVc<Box<dyn ResolveOrigin>>,
pub request: ResolvedVc<Request>,
pub path: ResolvedVc<AstPath>,
pub issue_source: ResolvedVc<IssueSource>,
pub in_try: bool,
}
......@@ -88,10 +88,10 @@ pub struct CjsRequireAssetReference {
impl CjsRequireAssetReference {
#[turbo_tasks::function]
pub fn new(
origin: Vc<Box<dyn ResolveOrigin>>,
request: Vc<Request>,
path: Vc<AstPath>,
issue_source: Vc<IssueSource>,
origin: ResolvedVc<Box<dyn ResolveOrigin>>,
request: ResolvedVc<Request>,
path: ResolvedVc<AstPath>,
issue_source: ResolvedVc<IssueSource>,
in_try: bool,
) -> Vc<Self> {
Self::cell(CjsRequireAssetReference {
......@@ -109,9 +109,9 @@ impl ModuleReference for CjsRequireAssetReference {
#[turbo_tasks::function]
fn resolve_reference(&self) -> Vc<ModuleResolveResult> {
cjs_resolve(
self.origin,
self.request,
Some(self.issue_source),
*self.origin,
*self.request,
Some(*self.issue_source),
self.in_try,
)
}
......@@ -138,13 +138,13 @@ impl CodeGenerateable for CjsRequireAssetReference {
chunking_context: Vc<Box<dyn ChunkingContext>>,
) -> Result<Vc<CodeGeneration>> {
let pm = PatternMapping::resolve_request(
self.request,
self.origin,
*self.request,
*self.origin,
Vc::upcast(chunking_context),
cjs_resolve(
self.origin,
self.request,
Some(self.issue_source),
*self.origin,
*self.request,
Some(*self.issue_source),
self.in_try,
),
Value::new(ChunkItem),
......@@ -184,10 +184,10 @@ impl CodeGenerateable for CjsRequireAssetReference {
#[turbo_tasks::value]
#[derive(Hash, Debug)]
pub struct CjsRequireResolveAssetReference {
pub origin: Vc<Box<dyn ResolveOrigin>>,
pub request: Vc<Request>,
pub path: Vc<AstPath>,
pub issue_source: Vc<IssueSource>,
pub origin: ResolvedVc<Box<dyn ResolveOrigin>>,
pub request: ResolvedVc<Request>,
pub path: ResolvedVc<AstPath>,
pub issue_source: ResolvedVc<IssueSource>,
pub in_try: bool,
}
......@@ -195,10 +195,10 @@ pub struct CjsRequireResolveAssetReference {
impl CjsRequireResolveAssetReference {
#[turbo_tasks::function]
pub fn new(
origin: Vc<Box<dyn ResolveOrigin>>,
request: Vc<Request>,
path: Vc<AstPath>,
issue_source: Vc<IssueSource>,
origin: ResolvedVc<Box<dyn ResolveOrigin>>,
request: ResolvedVc<Request>,
path: ResolvedVc<AstPath>,
issue_source: ResolvedVc<IssueSource>,
in_try: bool,
) -> Vc<Self> {
Self::cell(CjsRequireResolveAssetReference {
......@@ -216,9 +216,9 @@ impl ModuleReference for CjsRequireResolveAssetReference {
#[turbo_tasks::function]
fn resolve_reference(&self) -> Vc<ModuleResolveResult> {
cjs_resolve(
self.origin,
self.request,
Some(self.issue_source),
*self.origin,
*self.request,
Some(*self.issue_source),
self.in_try,
)
}
......@@ -245,13 +245,13 @@ impl CodeGenerateable for CjsRequireResolveAssetReference {
chunking_context: Vc<Box<dyn ChunkingContext>>,
) -> Result<Vc<CodeGeneration>> {
let pm = PatternMapping::resolve_request(
self.request,
self.origin,
*self.request,
*self.origin,
Vc::upcast(chunking_context),
cjs_resolve(
self.origin,
self.request,
Some(self.issue_source),
*self.origin,
*self.request,
Some(*self.issue_source),
self.in_try,
),
Value::new(ChunkItem),
......@@ -295,7 +295,7 @@ impl CodeGenerateable for CjsRequireResolveAssetReference {
#[turbo_tasks::value(shared)]
#[derive(Hash, Debug)]
pub struct CjsRequireCacheAccess {
pub path: Vc<AstPath>,
pub path: ResolvedVc<AstPath>,
}
#[turbo_tasks::value_impl]
......
use anyhow::Result;
use swc_core::quote;
use turbo_tasks::{Value, Vc};
use turbo_tasks::{ResolvedVc, Value, Vc};
use turbopack_core::chunk::ChunkingContext;
use super::AstPath;
......@@ -20,13 +20,13 @@ pub enum ConstantConditionValue {
#[turbo_tasks::value]
pub struct ConstantCondition {
value: ConstantConditionValue,
path: Vc<AstPath>,
path: ResolvedVc<AstPath>,
}
#[turbo_tasks::value_impl]
impl ConstantCondition {
#[turbo_tasks::function]
pub fn new(value: Value<ConstantConditionValue>, path: Vc<AstPath>) -> Vc<Self> {
pub fn new(value: Value<ConstantConditionValue>, path: ResolvedVc<AstPath>) -> Vc<Self> {
Self::cell(ConstantCondition {
value: value.into_value(),
path,
......
use anyhow::Result;
use swc_core::quote;
use turbo_tasks::{Value, Vc};
use turbo_tasks::{ResolvedVc, Value, Vc};
use turbopack_core::{chunk::ChunkingContext, compile_time_info::CompileTimeDefineValue};
use super::AstPath;
......@@ -12,13 +12,13 @@ use crate::{
#[turbo_tasks::value]
pub struct ConstantValue {
value: CompileTimeDefineValue,
path: Vc<AstPath>,
path: ResolvedVc<AstPath>,
}
#[turbo_tasks::value_impl]
impl ConstantValue {
#[turbo_tasks::function]
pub fn new(value: Value<CompileTimeDefineValue>, path: Vc<AstPath>) -> Vc<Self> {
pub fn new(value: Value<CompileTimeDefineValue>, path: ResolvedVc<AstPath>) -> Vc<Self> {
Self::cell(ConstantValue {
value: value.into_value(),
path,
......
use anyhow::Result;
use serde::{Deserialize, Serialize};
use swc_core::quote;
use turbo_tasks::{debug::ValueDebugFormat, trace::TraceRawVcs, Vc};
use turbo_tasks::{debug::ValueDebugFormat, trace::TraceRawVcs, ResolvedVc, Vc};
use turbopack_core::chunk::ChunkingContext;
use super::AstPath;
......@@ -18,14 +18,14 @@ enum DynamicExpressionType {
#[turbo_tasks::value]
pub struct DynamicExpression {
path: Vc<AstPath>,
path: ResolvedVc<AstPath>,
ty: DynamicExpressionType,
}
#[turbo_tasks::value_impl]
impl DynamicExpression {
#[turbo_tasks::function]
pub fn new(path: Vc<AstPath>) -> Vc<Self> {
pub fn new(path: ResolvedVc<AstPath>) -> Vc<Self> {
Self::cell(DynamicExpression {
path,
ty: DynamicExpressionType::Normal,
......@@ -33,7 +33,7 @@ impl DynamicExpression {
}
#[turbo_tasks::function]
pub fn new_promise(path: Vc<AstPath>) -> Vc<Self> {
pub fn new_promise(path: ResolvedVc<AstPath>) -> Vc<Self> {
Self::cell(DynamicExpression {
path,
ty: DynamicExpressionType::Promise,
......
......@@ -102,17 +102,17 @@ impl ReferencedAsset {
#[turbo_tasks::value]
#[derive(Hash, Debug)]
pub struct EsmAssetReference {
pub origin: Vc<Box<dyn ResolveOrigin>>,
pub request: Vc<Request>,
pub origin: ResolvedVc<Box<dyn ResolveOrigin>>,
pub request: ResolvedVc<Request>,
pub annotations: ImportAnnotations,
pub issue_source: Vc<IssueSource>,
pub issue_source: ResolvedVc<IssueSource>,
pub export_name: Option<ResolvedVc<ModulePart>>,
pub import_externals: bool,
}
impl EsmAssetReference {
fn get_origin(&self) -> Vc<Box<dyn ResolveOrigin>> {
let mut origin = self.origin;
let mut origin = *self.origin;
if let Some(transition) = self.annotations.transition() {
origin = origin.with_transition(transition.into());
}
......@@ -124,9 +124,9 @@ impl EsmAssetReference {
impl EsmAssetReference {
#[turbo_tasks::function]
pub fn new(
origin: Vc<Box<dyn ResolveOrigin>>,
request: Vc<Request>,
issue_source: Vc<IssueSource>,
origin: ResolvedVc<Box<dyn ResolveOrigin>>,
request: ResolvedVc<Request>,
issue_source: ResolvedVc<IssueSource>,
annotations: Value<ImportAnnotations>,
export_name: Option<ResolvedVc<ModulePart>>,
import_externals: bool,
......@@ -162,13 +162,13 @@ impl ModuleReference for EsmAssetReference {
if let Request::Module { module, .. } = &*self.request.await? {
if module == TURBOPACK_PART_IMPORT_SOURCE {
if let Some(part) = self.export_name {
let module: Vc<crate::EcmascriptModuleAsset> =
Vc::try_resolve_downcast_type(self.origin)
let module: ResolvedVc<crate::EcmascriptModuleAsset> =
ResolvedVc::try_downcast_type(self.origin)
.await?
.expect("EsmAssetReference origin should be a EcmascriptModuleAsset");
return Ok(ModuleResolveResult::module(
EcmascriptModulePartAsset::select_part(module, *part)
EcmascriptModulePartAsset::select_part(*module, *part)
.to_resolved()
.await?,
)
......@@ -181,10 +181,10 @@ impl ModuleReference for EsmAssetReference {
let result = esm_resolve(
self.get_origin().resolve().await?,
self.request,
*self.request,
Value::new(ty),
false,
Some(self.issue_source),
Some(*self.issue_source),
);
if let Some(part) = self.export_name {
......@@ -195,8 +195,8 @@ impl ModuleReference for EsmAssetReference {
let export = export_name.await?;
if *is_export_missing(*module, export.clone_value()).await? {
InvalidExport {
export: *export_name,
module: *module,
export: export_name,
module,
source: self.issue_source,
}
.cell()
......@@ -260,7 +260,7 @@ impl CodeGenerateable for EsmAssetReference {
if let ReferencedAsset::Unresolvable = &*referenced_asset {
// Insert code that throws immediately at time of import if a request is
// unresolvable
let request = request_to_string(this.request).await?.to_string();
let request = request_to_string(*this.request).await?.to_string();
let stmt = Stmt::Expr(ExprStmt {
expr: Box::new(throw_module_not_found_expr(&request)),
span: DUMMY_SP,
......@@ -392,9 +392,9 @@ fn var_decl_with_span(mut decl: Stmt, span: Span) -> Stmt {
#[turbo_tasks::value(shared)]
pub struct InvalidExport {
export: Vc<RcStr>,
module: Vc<Box<dyn EcmascriptChunkPlaceable>>,
source: Vc<IssueSource>,
export: ResolvedVc<RcStr>,
module: ResolvedVc<Box<dyn EcmascriptChunkPlaceable>>,
source: ResolvedVc<IssueSource>,
}
#[turbo_tasks::value_impl]
......@@ -427,7 +427,7 @@ impl Issue for InvalidExport {
#[turbo_tasks::function]
async fn description(&self) -> Result<Vc<OptionStyledString>> {
let export = self.export.await?;
let export_names = all_known_export_names(self.module).await?;
let export_names = all_known_export_names(*self.module).await?;
let did_you_mean = export_names
.iter()
.map(|s| (s, jaro(export.as_str(), s.as_str())))
......@@ -463,7 +463,7 @@ impl Issue for InvalidExport {
#[turbo_tasks::function]
async fn detail(&self) -> Result<Vc<OptionStyledString>> {
let export_names = all_known_export_names(self.module).await?;
let export_names = all_known_export_names(*self.module).await?;
Ok(Vc::cell(Some(
StyledString::Line(vec![
StyledString::Text("These are the exports of the module:\n".into()),
......@@ -482,6 +482,6 @@ impl Issue for InvalidExport {
#[turbo_tasks::function]
fn source(&self) -> Vc<OptionIssueSource> {
Vc::cell(Some(self.source))
Vc::cell(Some(*self.source))
}
}
......@@ -14,7 +14,7 @@ use swc_core::{
},
};
use turbo_rcstr::RcStr;
use turbo_tasks::{trace::TraceRawVcs, TaskInput, Vc};
use turbo_tasks::{trace::TraceRawVcs, ResolvedVc, TaskInput, Vc};
use turbopack_core::chunk::ChunkingContext;
use super::EsmAssetReference;
......@@ -42,14 +42,14 @@ impl EsmBindings {
pub struct EsmBinding {
pub reference: Vc<EsmAssetReference>,
pub export: Option<RcStr>,
pub ast_path: Vc<AstPath>,
pub ast_path: ResolvedVc<AstPath>,
}
impl EsmBinding {
pub fn new(
reference: Vc<EsmAssetReference>,
export: Option<RcStr>,
ast_path: Vc<AstPath>,
ast_path: ResolvedVc<AstPath>,
) -> Self {
EsmBinding {
reference,
......
......@@ -5,7 +5,7 @@ use swc_core::{
quote_expr,
};
use turbo_rcstr::RcStr;
use turbo_tasks::{Value, ValueToString, Vc};
use turbo_tasks::{ResolvedVc, Value, ValueToString, Vc};
use turbopack_core::{
chunk::{ChunkableModuleReference, ChunkingContext, ChunkingType, ChunkingTypeOption},
environment::ChunkLoading,
......@@ -26,10 +26,10 @@ use crate::{
#[turbo_tasks::value]
#[derive(Hash, Debug)]
pub struct EsmAsyncAssetReference {
pub origin: Vc<Box<dyn ResolveOrigin>>,
pub request: Vc<Request>,
pub path: Vc<AstPath>,
pub issue_source: Vc<IssueSource>,
pub origin: ResolvedVc<Box<dyn ResolveOrigin>>,
pub request: ResolvedVc<Request>,
pub path: ResolvedVc<AstPath>,
pub issue_source: ResolvedVc<IssueSource>,
pub in_try: bool,
pub import_externals: bool,
}
......@@ -38,10 +38,10 @@ pub struct EsmAsyncAssetReference {
impl EsmAsyncAssetReference {
#[turbo_tasks::function]
pub fn new(
origin: Vc<Box<dyn ResolveOrigin>>,
request: Vc<Request>,
path: Vc<AstPath>,
issue_source: Vc<IssueSource>,
origin: ResolvedVc<Box<dyn ResolveOrigin>>,
request: ResolvedVc<Request>,
path: ResolvedVc<AstPath>,
issue_source: ResolvedVc<IssueSource>,
in_try: bool,
import_externals: bool,
) -> Vc<Self> {
......@@ -61,11 +61,11 @@ impl ModuleReference for EsmAsyncAssetReference {
#[turbo_tasks::function]
fn resolve_reference(&self) -> Vc<ModuleResolveResult> {
esm_resolve(
self.origin,
self.request,
*self.origin,
*self.request,
Value::new(EcmaScriptModulesReferenceSubType::DynamicImport),
self.in_try,
Some(self.issue_source),
Some(*self.issue_source),
)
}
}
......@@ -96,15 +96,15 @@ impl CodeGenerateable for EsmAsyncAssetReference {
chunking_context: Vc<Box<dyn ChunkingContext>>,
) -> Result<Vc<CodeGeneration>> {
let pm = PatternMapping::resolve_request(
self.request,
self.origin,
*self.request,
*self.origin,
Vc::upcast(chunking_context),
esm_resolve(
self.origin,
self.request,
*self.origin,
*self.request,
Value::new(EcmaScriptModulesReferenceSubType::DynamicImport),
self.in_try,
Some(self.issue_source),
Some(*self.issue_source),
),
if matches!(
*chunking_context.environment().chunk_loading().await?,
......
......@@ -52,7 +52,7 @@ pub enum EsmExport {
#[turbo_tasks::function]
pub async fn is_export_missing(
module: Vc<Box<dyn EcmascriptChunkPlaceable>>,
module: ResolvedVc<Box<dyn EcmascriptChunkPlaceable>>,
export_name: RcStr,
) -> Result<Vc<bool>> {
let exports = module.get_exports().await?;
......@@ -77,7 +77,7 @@ pub async fn is_export_missing(
return Ok(Vc::cell(true));
}
let all_export_names = get_all_export_names(module).await?;
let all_export_names = get_all_export_names(*module).await?;
if all_export_names.esm_exports.contains_key(&export_name) {
return Ok(Vc::cell(false));
}
......@@ -438,7 +438,7 @@ impl EsmExports {
let mut exports: BTreeMap<RcStr, EsmExport> = self.exports.clone();
let mut dynamic_exports = vec![];
for esm_ref in self.star_exports.iter() {
for &esm_ref in self.star_exports.iter() {
// TODO(PACK-2176): we probably need to handle re-exporting from external
// modules.
let ReferencedAsset::Some(asset) =
......@@ -453,7 +453,7 @@ impl EsmExports {
if !exports.contains_key(export) {
exports.insert(
export.clone(),
EsmExport::ImportedBinding(Vc::upcast(*esm_ref), export.clone(), false),
EsmExport::ImportedBinding(Vc::upcast(esm_ref), export.clone(), false),
);
}
}
......
......@@ -6,7 +6,7 @@ use swc_core::{
ecma::ast::{Expr, Ident},
quote,
};
use turbo_tasks::Vc;
use turbo_tasks::{ResolvedVc, Vc};
use turbo_tasks_fs::FileSystemPath;
use turbopack_core::chunk::ChunkingContext;
......@@ -24,13 +24,13 @@ use crate::{
#[turbo_tasks::value(shared)]
#[derive(Hash, Debug)]
pub struct ImportMetaBinding {
path: Vc<FileSystemPath>,
path: ResolvedVc<FileSystemPath>,
}
#[turbo_tasks::value_impl]
impl ImportMetaBinding {
#[turbo_tasks::function]
pub fn new(path: Vc<FileSystemPath>) -> Vc<Self> {
pub fn new(path: ResolvedVc<FileSystemPath>) -> Vc<Self> {
ImportMetaBinding { path }.cell()
}
}
......@@ -42,7 +42,7 @@ impl CodeGenerateable for ImportMetaBinding {
&self,
_context: Vc<Box<dyn ChunkingContext>>,
) -> Result<Vc<CodeGeneration>> {
let path = as_abs_path(self.path).await?.as_str().map_or_else(
let path = as_abs_path(*self.path).await?.as_str().map_or_else(
|| {
quote!(
"(() => { throw new Error('could not convert import.meta.url to filepath') })()"
......@@ -79,13 +79,13 @@ impl CodeGenerateable for ImportMetaBinding {
#[turbo_tasks::value(shared)]
#[derive(Hash, Debug)]
pub struct ImportMetaRef {
ast_path: Vc<AstPath>,
ast_path: ResolvedVc<AstPath>,
}
#[turbo_tasks::value_impl]
impl ImportMetaRef {
#[turbo_tasks::function]
pub fn new(ast_path: Vc<AstPath>) -> Vc<Self> {
pub fn new(ast_path: ResolvedVc<AstPath>) -> Vc<Self> {
ImportMetaRef { ast_path }.cell()
}
}
......
use anyhow::Result;
use swc_core::quote;
use turbo_rcstr::RcStr;
use turbo_tasks::{ValueToString, Vc};
use turbo_tasks::{ResolvedVc, ValueToString, Vc};
use turbopack_core::{
chunk::{
ChunkItemExt, ChunkableModule, ChunkableModuleReference, ChunkingContext,
......@@ -22,14 +22,14 @@ use crate::{
#[turbo_tasks::value]
#[derive(Hash, Debug)]
pub struct EsmModuleIdAssetReference {
inner: Vc<EsmAssetReference>,
ast_path: Vc<AstPath>,
inner: ResolvedVc<EsmAssetReference>,
ast_path: ResolvedVc<AstPath>,
}
#[turbo_tasks::value_impl]
impl EsmModuleIdAssetReference {
#[turbo_tasks::function]
pub fn new(inner: Vc<EsmAssetReference>, ast_path: Vc<AstPath>) -> Vc<Self> {
pub fn new(inner: ResolvedVc<EsmAssetReference>, ast_path: ResolvedVc<AstPath>) -> Vc<Self> {
Self::cell(EsmModuleIdAssetReference { inner, ast_path })
}
}
......
......@@ -9,7 +9,7 @@ use swc_core::{
},
quote,
};
use turbo_tasks::Vc;
use turbo_tasks::{ResolvedVc, Vc};
use turbopack_core::chunk::ChunkingContext;
use crate::{
......@@ -24,13 +24,13 @@ use crate::{
#[turbo_tasks::value]
#[derive(Hash, Debug)]
pub struct EsmModuleItem {
pub path: Vc<AstPath>,
pub path: ResolvedVc<AstPath>,
}
#[turbo_tasks::value_impl]
impl EsmModuleItem {
#[turbo_tasks::function]
pub fn new(path: Vc<AstPath>) -> Vc<Self> {
pub fn new(path: ResolvedVc<AstPath>) -> Vc<Self> {
Self::cell(EsmModuleItem { path })
}
}
......
......@@ -4,7 +4,7 @@ use swc_core::{
quote,
};
use turbo_rcstr::RcStr;
use turbo_tasks::{Value, ValueToString, Vc};
use turbo_tasks::{ResolvedVc, Value, ValueToString, Vc};
use turbopack_core::{
chunk::{
ChunkItemExt, ChunkableModule, ChunkableModuleReference, ChunkingContext, ChunkingType,
......@@ -48,26 +48,26 @@ pub enum UrlRewriteBehavior {
/// referenced file to be imported/fetched/etc.
#[turbo_tasks::value]
pub struct UrlAssetReference {
origin: Vc<Box<dyn ResolveOrigin>>,
request: Vc<Request>,
rendering: Vc<Rendering>,
ast_path: Vc<AstPath>,
issue_source: Vc<IssueSource>,
origin: ResolvedVc<Box<dyn ResolveOrigin>>,
request: ResolvedVc<Request>,
rendering: ResolvedVc<Rendering>,
ast_path: ResolvedVc<AstPath>,
issue_source: ResolvedVc<IssueSource>,
in_try: bool,
url_rewrite_behavior: Vc<UrlRewriteBehavior>,
url_rewrite_behavior: ResolvedVc<UrlRewriteBehavior>,
}
#[turbo_tasks::value_impl]
impl UrlAssetReference {
#[turbo_tasks::function]
pub fn new(
origin: Vc<Box<dyn ResolveOrigin>>,
request: Vc<Request>,
rendering: Vc<Rendering>,
ast_path: Vc<AstPath>,
issue_source: Vc<IssueSource>,
origin: ResolvedVc<Box<dyn ResolveOrigin>>,
request: ResolvedVc<Request>,
rendering: ResolvedVc<Rendering>,
ast_path: ResolvedVc<AstPath>,
issue_source: ResolvedVc<IssueSource>,
in_try: bool,
url_rewrite_behavior: Vc<UrlRewriteBehavior>,
url_rewrite_behavior: ResolvedVc<UrlRewriteBehavior>,
) -> Vc<Self> {
UrlAssetReference {
origin,
......@@ -92,10 +92,10 @@ impl ModuleReference for UrlAssetReference {
#[turbo_tasks::function]
fn resolve_reference(&self) -> Vc<ModuleResolveResult> {
url_resolve(
self.origin,
self.request,
*self.origin,
*self.request,
Value::new(ReferenceType::Url(UrlReferenceSubType::EcmaScriptNewUrl)),
Some(self.issue_source),
Some(*self.issue_source),
self.in_try,
)
}
......
......@@ -3,7 +3,7 @@ use std::{fmt::Display, io::Write};
use anyhow::Result;
use serde::{Deserialize, Serialize};
use turbo_rcstr::RcStr;
use turbo_tasks::{trace::TraceRawVcs, TaskInput, Vc};
use turbo_tasks::{trace::TraceRawVcs, ResolvedVc, TaskInput, Vc};
use turbo_tasks_fs::{glob::Glob, rope::RopeBuilder, FileContent, FileSystem, VirtualFileSystem};
use turbopack_core::{
asset::{Asset, AssetContent},
......@@ -124,8 +124,8 @@ impl Asset for CachedExternalModule {
impl ChunkableModule for CachedExternalModule {
#[turbo_tasks::function]
fn as_chunk_item(
self: Vc<Self>,
chunking_context: Vc<Box<dyn ChunkingContext>>,
self: ResolvedVc<Self>,
chunking_context: ResolvedVc<Box<dyn ChunkingContext>>,
) -> Vc<Box<dyn ChunkItem>> {
Vc::upcast(
CachedExternalModuleChunkItem {
......@@ -176,8 +176,8 @@ impl EcmascriptChunkPlaceable for CachedExternalModule {
#[turbo_tasks::value]
pub struct CachedExternalModuleChunkItem {
module: Vc<CachedExternalModule>,
chunking_context: Vc<Box<dyn ChunkingContext>>,
module: ResolvedVc<CachedExternalModule>,
chunking_context: ResolvedVc<Box<dyn ChunkingContext>>,
}
#[turbo_tasks::value_impl]
......@@ -199,12 +199,12 @@ impl ChunkItem for CachedExternalModuleChunkItem {
#[turbo_tasks::function]
fn module(&self) -> Vc<Box<dyn Module>> {
Vc::upcast(self.module)
Vc::upcast(*self.module)
}
#[turbo_tasks::function]
fn chunking_context(&self) -> Vc<Box<dyn ChunkingContext>> {
self.chunking_context
*self.chunking_context
}
#[turbo_tasks::function]
......@@ -219,7 +219,7 @@ impl ChunkItem for CachedExternalModuleChunkItem {
impl EcmascriptChunkItem for CachedExternalModuleChunkItem {
#[turbo_tasks::function]
fn chunking_context(&self) -> Vc<Box<dyn ChunkingContext>> {
self.chunking_context
*self.chunking_context
}
#[turbo_tasks::function]
......@@ -239,7 +239,7 @@ impl EcmascriptChunkItem for CachedExternalModuleChunkItem {
EcmascriptChunkItemContent::new(
self.module.content(),
self.chunking_context,
*self.chunking_context,
EcmascriptOptions::default().cell(),
async_module_options,
)
......@@ -253,13 +253,13 @@ impl EcmascriptChunkItem for CachedExternalModuleChunkItem {
/// "client modules" and "client modules ssr".
#[turbo_tasks::value]
pub struct IncludeIdentModule {
ident: Vc<AssetIdent>,
ident: ResolvedVc<AssetIdent>,
}
#[turbo_tasks::value_impl]
impl IncludeIdentModule {
#[turbo_tasks::function]
pub fn new(ident: Vc<AssetIdent>) -> Vc<Self> {
pub fn new(ident: ResolvedVc<AssetIdent>) -> Vc<Self> {
Self { ident }.cell()
}
}
......@@ -274,6 +274,6 @@ impl Asset for IncludeIdentModule {
impl Module for IncludeIdentModule {
#[turbo_tasks::function]
fn ident(&self) -> Vc<AssetIdent> {
self.ident
*self.ident
}
}
......@@ -17,13 +17,13 @@ use turbopack_core::{
#[turbo_tasks::value]
#[derive(Hash, Clone, Debug)]
pub struct PackageJsonReference {
pub package_json: Vc<FileSystemPath>,
pub package_json: ResolvedVc<FileSystemPath>,
}
#[turbo_tasks::value_impl]
impl PackageJsonReference {
#[turbo_tasks::function]
pub fn new(package_json: Vc<FileSystemPath>) -> Vc<Self> {
pub fn new(package_json: ResolvedVc<FileSystemPath>) -> Vc<Self> {
Self::cell(PackageJsonReference { package_json })
}
}
......@@ -33,7 +33,7 @@ impl ModuleReference for PackageJsonReference {
#[turbo_tasks::function]
async fn resolve_reference(&self) -> Result<Vc<ModuleResolveResult>> {
Ok(ModuleResolveResult::module(ResolvedVc::upcast(
RawModule::new(Vc::upcast(FileSource::new(self.package_json)))
RawModule::new(Vc::upcast(FileSource::new(*self.package_json)))
.to_resolved()
.await?,
))
......@@ -54,14 +54,14 @@ impl ValueToString for PackageJsonReference {
#[turbo_tasks::value]
#[derive(Hash, Debug)]
pub struct DirAssetReference {
pub source: Vc<Box<dyn Source>>,
pub path: Vc<Pattern>,
pub source: ResolvedVc<Box<dyn Source>>,
pub path: ResolvedVc<Pattern>,
}
#[turbo_tasks::value_impl]
impl DirAssetReference {
#[turbo_tasks::function]
pub fn new(source: Vc<Box<dyn Source>>, path: Vc<Pattern>) -> Vc<Self> {
pub fn new(source: ResolvedVc<Box<dyn Source>>, path: ResolvedVc<Pattern>) -> Vc<Self> {
Self::cell(DirAssetReference { source, path })
}
}
......@@ -151,7 +151,7 @@ impl ModuleReference for DirAssetReference {
let parent_path = self.source.ident().path().parent();
Ok(resolve_reference_from_dir(
parent_path.resolve().await?,
self.path,
*self.path,
))
}
}
......
use anyhow::Result;
use turbo_rcstr::RcStr;
use turbo_tasks::{ValueToString, Vc};
use turbo_tasks::{ResolvedVc, ValueToString, Vc};
use turbopack_core::{
reference::ModuleReference,
resolve::{pattern::Pattern, resolve_raw, ModuleResolveResult},
......@@ -10,14 +10,14 @@ use turbopack_core::{
#[turbo_tasks::value]
#[derive(Hash, Debug)]
pub struct FileSourceReference {
pub source: Vc<Box<dyn Source>>,
pub path: Vc<Pattern>,
pub source: ResolvedVc<Box<dyn Source>>,
pub path: ResolvedVc<Pattern>,
}
#[turbo_tasks::value_impl]
impl FileSourceReference {
#[turbo_tasks::function]
pub fn new(source: Vc<Box<dyn Source>>, path: Vc<Pattern>) -> Vc<Self> {
pub fn new(source: ResolvedVc<Box<dyn Source>>, path: ResolvedVc<Pattern>) -> Vc<Self> {
Self::cell(FileSourceReference { source, path })
}
}
......@@ -28,7 +28,7 @@ impl ModuleReference for FileSourceReference {
fn resolve_reference(&self) -> Vc<ModuleResolveResult> {
let context_dir = self.source.ident().path().parent();
resolve_raw(context_dir, self.path, false).as_raw_module_result()
resolve_raw(context_dir, *self.path, false).as_raw_module_result()
}
}
......
......@@ -122,7 +122,7 @@ impl DirList {
for (k, entry) in &*dir {
match entry {
DirListEntry::File(path) => {
list.insert(k.clone(), **path);
list.insert(k.clone(), *path);
}
DirListEntry::Dir(d) => {
queue.push_back(d.await?);
......@@ -136,7 +136,7 @@ impl DirList {
}
#[turbo_tasks::value(transparent)]
pub(crate) struct FlatDirList(FxIndexMap<RcStr, Vc<FileSystemPath>>);
pub(crate) struct FlatDirList(FxIndexMap<RcStr, ResolvedVc<FileSystemPath>>);
#[turbo_tasks::value_impl]
impl FlatDirList {
......@@ -150,8 +150,8 @@ impl FlatDirList {
#[derive(Debug)]
pub struct RequireContextMapEntry {
pub origin_relative: RcStr,
pub request: Vc<Request>,
pub result: Vc<ModuleResolveResult>,
pub request: ResolvedVc<Request>,
pub result: ResolvedVc<ModuleResolveResult>,
}
/// The resolved context map for a `require.context(..)` call.
......@@ -166,7 +166,7 @@ impl RequireContextMap {
dir: Vc<FileSystemPath>,
recursive: bool,
filter: Vc<Regex>,
issue_source: Option<Vc<IssueSource>>,
issue_source: Option<ResolvedVc<IssueSource>>,
is_optional: bool,
) -> Result<Vc<Self>> {
let origin_path = &*origin.origin_path().parent().await?;
......@@ -177,8 +177,12 @@ impl RequireContextMap {
for (context_relative, path) in list {
if let Some(origin_relative) = origin_path.get_relative_path_to(&*path.await?) {
let request = Request::parse(Value::new(origin_relative.clone().into()));
let result = cjs_resolve(origin, request, issue_source, is_optional);
let request = Request::parse(Value::new(origin_relative.clone().into()))
.to_resolved()
.await?;
let result = cjs_resolve(origin, *request, issue_source.map(|v| *v), is_optional)
.to_resolved()
.await?;
map.insert(
context_relative.clone(),
......@@ -206,32 +210,34 @@ pub struct RequireContextAssetReference {
pub dir: RcStr,
pub include_subdirs: bool,
pub path: Vc<AstPath>,
pub issue_source: Option<Vc<IssueSource>>,
pub path: ResolvedVc<AstPath>,
pub issue_source: Option<ResolvedVc<IssueSource>>,
pub in_try: bool,
}
#[turbo_tasks::value_impl]
impl RequireContextAssetReference {
#[turbo_tasks::function]
pub fn new(
source: Vc<Box<dyn Source>>,
origin: Vc<Box<dyn ResolveOrigin>>,
pub async fn new(
source: ResolvedVc<Box<dyn Source>>,
origin: ResolvedVc<Box<dyn ResolveOrigin>>,
dir: RcStr,
include_subdirs: bool,
filter: Vc<Regex>,
path: Vc<AstPath>,
issue_source: Option<Vc<IssueSource>>,
path: ResolvedVc<AstPath>,
issue_source: Option<ResolvedVc<IssueSource>>,
in_try: bool,
) -> Vc<Self> {
) -> Result<Vc<Self>> {
let map = RequireContextMap::generate(
origin,
*origin,
origin.origin_path().parent().join(dir.clone()),
include_subdirs,
filter,
issue_source,
issue_source.map(|v| *v),
in_try,
);
)
.to_resolved()
.await?;
let inner = RequireContextAsset {
source,
origin,
......@@ -242,14 +248,14 @@ impl RequireContextAssetReference {
}
.resolved_cell();
Self::cell(RequireContextAssetReference {
Ok(Self::cell(RequireContextAssetReference {
inner,
dir,
include_subdirs,
path,
issue_source,
in_try,
})
}))
}
}
......@@ -306,13 +312,13 @@ impl CodeGenerateable for RequireContextAssetReference {
}
#[turbo_tasks::value(transparent)]
pub struct ResolvedModuleReference(Vc<ModuleResolveResult>);
pub struct ResolvedModuleReference(ResolvedVc<ModuleResolveResult>);
#[turbo_tasks::value_impl]
impl ModuleReference for ResolvedModuleReference {
#[turbo_tasks::function]
fn resolve_reference(&self) -> Vc<ModuleResolveResult> {
self.0
*self.0
}
}
......@@ -329,10 +335,10 @@ impl ChunkableModuleReference for ResolvedModuleReference {}
#[turbo_tasks::value]
pub struct RequireContextAsset {
source: Vc<Box<dyn Source>>,
source: ResolvedVc<Box<dyn Source>>,
origin: Vc<Box<dyn ResolveOrigin>>,
map: Vc<RequireContextMap>,
origin: ResolvedVc<Box<dyn ResolveOrigin>>,
map: ResolvedVc<RequireContextMap>,
dir: RcStr,
include_subdirs: bool,
......@@ -383,8 +389,8 @@ impl Asset for RequireContextAsset {
impl ChunkableModule for RequireContextAsset {
#[turbo_tasks::function]
async fn as_chunk_item(
self: Vc<Self>,
chunking_context: Vc<Box<dyn ChunkingContext>>,
self: ResolvedVc<Self>,
chunking_context: ResolvedVc<Box<dyn ChunkingContext>>,
) -> Result<Vc<Box<dyn turbopack_core::chunk::ChunkItem>>> {
let this = self.await?;
Ok(Vc::upcast(
......@@ -410,18 +416,18 @@ impl EcmascriptChunkPlaceable for RequireContextAsset {
#[turbo_tasks::value]
pub struct RequireContextChunkItem {
chunking_context: Vc<Box<dyn ChunkingContext>>,
inner: Vc<RequireContextAsset>,
chunking_context: ResolvedVc<Box<dyn ChunkingContext>>,
inner: ResolvedVc<RequireContextAsset>,
origin: Vc<Box<dyn ResolveOrigin>>,
map: Vc<RequireContextMap>,
origin: ResolvedVc<Box<dyn ResolveOrigin>>,
map: ResolvedVc<RequireContextMap>,
}
#[turbo_tasks::value_impl]
impl EcmascriptChunkItem for RequireContextChunkItem {
#[turbo_tasks::function]
fn chunking_context(&self) -> Vc<Box<dyn ChunkingContext>> {
self.chunking_context
*self.chunking_context
}
#[turbo_tasks::function]
......@@ -435,10 +441,10 @@ impl EcmascriptChunkItem for RequireContextChunkItem {
for (key, entry) in map {
let pm = PatternMapping::resolve_request(
entry.request,
self.origin,
Vc::upcast(self.chunking_context),
entry.result,
*entry.request,
*self.origin,
*ResolvedVc::upcast(self.chunking_context),
*entry.result,
Value::new(ResolveType::ChunkItem),
)
.await?;
......@@ -512,7 +518,7 @@ impl ChunkItem for RequireContextChunkItem {
#[turbo_tasks::function]
fn chunking_context(&self) -> Vc<Box<dyn ChunkingContext>> {
Vc::upcast(self.chunking_context)
*ResolvedVc::upcast(self.chunking_context)
}
#[turbo_tasks::function]
......@@ -524,6 +530,6 @@ impl ChunkItem for RequireContextChunkItem {
#[turbo_tasks::function]
fn module(&self) -> Vc<Box<dyn Module>> {
Vc::upcast(self.inner)
*ResolvedVc::upcast(self.inner)
}
}
use turbo_tasks::Vc;
use turbo_tasks::{ResolvedVc, Vc};
use turbo_tasks_fs::FileSystemPath;
use turbopack_core::issue::{Issue, IssueSeverity, IssueStage, OptionStyledString, StyledString};
......@@ -6,7 +6,7 @@ use crate::SpecifiedModuleType;
#[turbo_tasks::value(shared)]
pub struct SpecifiedModuleTypeIssue {
pub path: Vc<FileSystemPath>,
pub path: ResolvedVc<FileSystemPath>,
pub specified_type: SpecifiedModuleType,
}
......@@ -14,7 +14,7 @@ pub struct SpecifiedModuleTypeIssue {
impl Issue for SpecifiedModuleTypeIssue {
#[turbo_tasks::function]
fn file_path(&self) -> Vc<FileSystemPath> {
self.path
*self.path
}
#[turbo_tasks::function]
......
......@@ -16,14 +16,17 @@ use crate::typescript::TsConfigModuleAsset;
#[turbo_tasks::value]
#[derive(Hash, Clone, Debug)]
pub struct TsConfigReference {
pub tsconfig: Vc<FileSystemPath>,
pub origin: Vc<Box<dyn ResolveOrigin>>,
pub tsconfig: ResolvedVc<FileSystemPath>,
pub origin: ResolvedVc<Box<dyn ResolveOrigin>>,
}
#[turbo_tasks::value_impl]
impl TsConfigReference {
#[turbo_tasks::function]
pub fn new(origin: Vc<Box<dyn ResolveOrigin>>, tsconfig: Vc<FileSystemPath>) -> Vc<Self> {
pub fn new(
origin: ResolvedVc<Box<dyn ResolveOrigin>>,
tsconfig: ResolvedVc<FileSystemPath>,
) -> Vc<Self> {
Self::cell(TsConfigReference { tsconfig, origin })
}
}
......@@ -33,7 +36,7 @@ impl ModuleReference for TsConfigReference {
#[turbo_tasks::function]
async fn resolve_reference(&self) -> Result<Vc<ModuleResolveResult>> {
Ok(ModuleResolveResult::module(ResolvedVc::upcast(
TsConfigModuleAsset::new(self.origin, Vc::upcast(FileSource::new(self.tsconfig)))
TsConfigModuleAsset::new(*self.origin, Vc::upcast(FileSource::new(*self.tsconfig)))
.to_resolved()
.await?,
))
......@@ -54,14 +57,14 @@ impl ValueToString for TsConfigReference {
#[turbo_tasks::value]
#[derive(Hash, Debug)]
pub struct TsReferencePathAssetReference {
pub origin: Vc<Box<dyn ResolveOrigin>>,
pub origin: ResolvedVc<Box<dyn ResolveOrigin>>,
pub path: RcStr,
}
#[turbo_tasks::value_impl]
impl TsReferencePathAssetReference {
#[turbo_tasks::function]
pub fn new(origin: Vc<Box<dyn ResolveOrigin>>, path: RcStr) -> Vc<Self> {
pub fn new(origin: ResolvedVc<Box<dyn ResolveOrigin>>, path: RcStr) -> Vc<Self> {
Self::cell(TsReferencePathAssetReference { origin, path })
}
}
......@@ -109,14 +112,14 @@ impl ValueToString for TsReferencePathAssetReference {
#[turbo_tasks::value]
#[derive(Hash, Debug)]
pub struct TsReferenceTypeAssetReference {
pub origin: Vc<Box<dyn ResolveOrigin>>,
pub origin: ResolvedVc<Box<dyn ResolveOrigin>>,
pub module: RcStr,
}
#[turbo_tasks::value_impl]
impl TsReferenceTypeAssetReference {
#[turbo_tasks::function]
pub fn new(origin: Vc<Box<dyn ResolveOrigin>>, module: RcStr) -> Vc<Self> {
pub fn new(origin: ResolvedVc<Box<dyn ResolveOrigin>>, module: RcStr) -> Vc<Self> {
Self::cell(TsReferenceTypeAssetReference { origin, module })
}
}
......@@ -126,7 +129,7 @@ impl ModuleReference for TsReferenceTypeAssetReference {
#[turbo_tasks::function]
fn resolve_reference(&self) -> Vc<ModuleResolveResult> {
type_resolve(
self.origin,
*self.origin,
Request::module(
self.module.clone(),
Value::new(RcStr::default().into()),
......
......@@ -16,7 +16,7 @@ use swc_core::{
},
quote,
};
use turbo_tasks::Vc;
use turbo_tasks::{ResolvedVc, Vc};
use turbopack_core::chunk::ChunkingContext;
use crate::{
......@@ -27,13 +27,13 @@ use crate::{
#[turbo_tasks::value]
pub struct Unreachable {
range: Vc<AstPathRange>,
range: ResolvedVc<AstPathRange>,
}
#[turbo_tasks::value_impl]
impl Unreachable {
#[turbo_tasks::function]
pub fn new(range: Vc<AstPathRange>) -> Vc<Self> {
pub fn new(range: ResolvedVc<AstPathRange>) -> Vc<Self> {
Self::cell(Unreachable { range })
}
}
......
......@@ -24,10 +24,10 @@ use crate::{
#[turbo_tasks::value]
#[derive(Hash, Debug)]
pub struct WorkerAssetReference {
pub origin: Vc<Box<dyn ResolveOrigin>>,
pub request: Vc<Request>,
pub path: Vc<AstPath>,
pub issue_source: Vc<IssueSource>,
pub origin: ResolvedVc<Box<dyn ResolveOrigin>>,
pub request: ResolvedVc<Request>,
pub path: ResolvedVc<AstPath>,
pub issue_source: ResolvedVc<IssueSource>,
pub in_try: bool,
}
......@@ -35,10 +35,10 @@ pub struct WorkerAssetReference {
impl WorkerAssetReference {
#[turbo_tasks::function]
pub fn new(
origin: Vc<Box<dyn ResolveOrigin>>,
request: Vc<Request>,
path: Vc<AstPath>,
issue_source: Vc<IssueSource>,
origin: ResolvedVc<Box<dyn ResolveOrigin>>,
request: ResolvedVc<Request>,
path: ResolvedVc<AstPath>,
issue_source: ResolvedVc<IssueSource>,
in_try: bool,
) -> Vc<Self> {
Self::cell(WorkerAssetReference {
......@@ -56,11 +56,11 @@ impl WorkerAssetReference {
self: &WorkerAssetReference,
) -> Result<Option<Vc<WorkerLoaderModule>>> {
let module = url_resolve(
self.origin,
self.request,
*self.origin,
*self.request,
// TODO support more worker types
Value::new(ReferenceType::Worker(WorkerReferenceSubType::WebWorker)),
Some(self.issue_source),
Some(*self.issue_source),
self.in_try,
);
......
......@@ -8,7 +8,7 @@ use swc_core::{
codegen::{text_writer::JsWriter, Emitter},
},
};
use turbo_tasks::{TryJoinIterExt, Vc};
use turbo_tasks::{ResolvedVc, TryJoinIterExt, Vc};
use turbo_tasks_fs::rope::RopeBuilder;
use turbopack_core::{
chunk::{AsyncModuleInfo, ChunkItem, ChunkType, ChunkingContext},
......@@ -30,8 +30,8 @@ use crate::{
/// The chunk item for [EcmascriptModuleFacadeModule].
#[turbo_tasks::value(shared)]
pub struct EcmascriptModuleFacadeChunkItem {
pub(crate) module: Vc<EcmascriptModuleFacadeModule>,
pub(crate) chunking_context: Vc<Box<dyn ChunkingContext>>,
pub(crate) module: ResolvedVc<EcmascriptModuleFacadeModule>,
pub(crate) chunking_context: ResolvedVc<Box<dyn ChunkingContext>>,
}
#[turbo_tasks::value_impl]
......@@ -74,19 +74,19 @@ impl EcmascriptChunkItem for EcmascriptModuleFacadeChunkItem {
if let Some(code_gen) =
Vc::try_resolve_sidecast::<Box<dyn CodeGenerateableWithAsyncModuleInfo>>(r).await?
{
code_gens.push(code_gen.code_generation(chunking_context, async_module_info));
code_gens.push(code_gen.code_generation(*chunking_context, async_module_info));
} else if let Some(code_gen) =
Vc::try_resolve_sidecast::<Box<dyn CodeGenerateable>>(r).await?
{
code_gens.push(code_gen.code_generation(chunking_context));
code_gens.push(code_gen.code_generation(*chunking_context));
}
}
code_gens.push(self.module.async_module().code_generation(
chunking_context,
*chunking_context,
async_module_info,
references,
));
code_gens.push(exports.code_generation(chunking_context));
code_gens.push(exports.code_generation(*chunking_context));
let code_gens = code_gens.into_iter().try_join().await?;
let code_gens = code_gens.iter().map(|cg| &**cg).collect::<Vec<_>>();
......@@ -124,7 +124,7 @@ impl EcmascriptChunkItem for EcmascriptModuleFacadeChunkItem {
#[turbo_tasks::function]
fn chunking_context(&self) -> Vc<Box<dyn ChunkingContext>> {
self.chunking_context
*self.chunking_context
}
}
......@@ -142,7 +142,7 @@ impl ChunkItem for EcmascriptModuleFacadeChunkItem {
#[turbo_tasks::function]
fn chunking_context(&self) -> Vc<Box<dyn ChunkingContext>> {
Vc::upcast(self.chunking_context)
*ResolvedVc::upcast(self.chunking_context)
}
#[turbo_tasks::function]
......@@ -154,7 +154,7 @@ impl ChunkItem for EcmascriptModuleFacadeChunkItem {
#[turbo_tasks::function]
fn module(&self) -> Vc<Box<dyn Module>> {
Vc::upcast(self.module)
*ResolvedVc::upcast(self.module)
}
#[turbo_tasks::function]
......
use std::collections::BTreeMap;
use anyhow::{bail, Result};
use turbo_tasks::Vc;
use turbo_tasks::{ResolvedVc, Vc};
use turbo_tasks_fs::{glob::Glob, File, FileContent};
use turbopack_core::{
asset::{Asset, AssetContent},
......@@ -28,14 +28,17 @@ use crate::{
/// [EcmascriptModuleLocalsModule]. It allows to follow
#[turbo_tasks::value]
pub struct EcmascriptModuleFacadeModule {
pub module: Vc<Box<dyn EcmascriptChunkPlaceable>>,
pub ty: Vc<ModulePart>,
pub module: ResolvedVc<Box<dyn EcmascriptChunkPlaceable>>,
pub ty: ResolvedVc<ModulePart>,
}
#[turbo_tasks::value_impl]
impl EcmascriptModuleFacadeModule {
#[turbo_tasks::function]
pub fn new(module: Vc<Box<dyn EcmascriptChunkPlaceable>>, ty: Vc<ModulePart>) -> Vc<Self> {
pub fn new(
module: ResolvedVc<Box<dyn EcmascriptChunkPlaceable>>,
ty: ResolvedVc<ModulePart>,
) -> Vc<Self> {
EcmascriptModuleFacadeModule { module, ty }.cell()
}
......@@ -64,7 +67,7 @@ impl Module for EcmascriptModuleFacadeModule {
async fn ident(&self) -> Result<Vc<AssetIdent>> {
let inner = self.module.ident();
Ok(inner.with_part(self.ty))
Ok(inner.with_part(*self.ty))
}
#[turbo_tasks::function]
......@@ -72,7 +75,7 @@ impl Module for EcmascriptModuleFacadeModule {
let references = match &*self.ty.await? {
ModulePart::Evaluation => {
let Some(module) =
Vc::try_resolve_sidecast::<Box<dyn EcmascriptAnalyzable>>(self.module).await?
ResolvedVc::try_sidecast::<Box<dyn EcmascriptAnalyzable>>(self.module).await?
else {
bail!(
"Expected EcmascriptModuleAsset for a EcmascriptModuleFacadeModule with \
......@@ -83,14 +86,14 @@ impl Module for EcmascriptModuleFacadeModule {
let references = result.evaluation_references;
let mut references = references.await?.clone_value();
references.push(Vc::upcast(EcmascriptModulePartReference::new_part(
self.module,
*self.module,
ModulePart::locals(),
)));
references
}
ModulePart::Exports => {
let Some(module) =
Vc::try_resolve_sidecast::<Box<dyn EcmascriptAnalyzable>>(self.module).await?
ResolvedVc::try_sidecast::<Box<dyn EcmascriptAnalyzable>>(self.module).await?
else {
bail!(
"Expected EcmascriptModuleAsset for a EcmascriptModuleFacadeModule with \
......@@ -101,7 +104,7 @@ impl Module for EcmascriptModuleFacadeModule {
let references = result.reexport_references;
let mut references = references.await?.clone_value();
references.push(Vc::upcast(EcmascriptModulePartReference::new_part(
self.module,
*self.module,
ModulePart::locals(),
)));
references
......@@ -109,20 +112,20 @@ impl Module for EcmascriptModuleFacadeModule {
ModulePart::Facade => {
vec![
Vc::upcast(EcmascriptModulePartReference::new_part(
self.module,
*self.module,
ModulePart::evaluation(),
)),
Vc::upcast(EcmascriptModulePartReference::new_part(
self.module,
*self.module,
ModulePart::exports(),
)),
]
}
ModulePart::RenamedNamespace { .. } => {
vec![Vc::upcast(EcmascriptModulePartReference::new(self.module))]
vec![Vc::upcast(EcmascriptModulePartReference::new(*self.module))]
}
ModulePart::RenamedExport { .. } => {
vec![Vc::upcast(EcmascriptModulePartReference::new(self.module))]
vec![Vc::upcast(EcmascriptModulePartReference::new(*self.module))]
}
_ => {
bail!("Unexpected ModulePart for EcmascriptModuleFacadeModule");
......@@ -166,7 +169,7 @@ impl EcmascriptChunkPlaceable for EcmascriptModuleFacadeModule {
name.clone(),
EsmExport::ImportedBinding(
Vc::upcast(EcmascriptModulePartReference::new_part(
self.module,
*self.module,
ModulePart::locals(),
)),
name,
......@@ -209,7 +212,7 @@ impl EcmascriptChunkPlaceable for EcmascriptModuleFacadeModule {
"default".into(),
EsmExport::ImportedBinding(
Vc::upcast(EcmascriptModulePartReference::new_part(
self.module,
*self.module,
ModulePart::exports(),
)),
"default".into(),
......@@ -218,7 +221,7 @@ impl EcmascriptChunkPlaceable for EcmascriptModuleFacadeModule {
);
}
star_exports.push(Vc::upcast(EcmascriptModulePartReference::new_part(
self.module,
*self.module,
ModulePart::exports(),
)));
}
......@@ -230,7 +233,7 @@ impl EcmascriptChunkPlaceable for EcmascriptModuleFacadeModule {
exports.insert(
export.await?.clone_value(),
EsmExport::ImportedBinding(
Vc::upcast(EcmascriptModulePartReference::new(self.module)),
Vc::upcast(EcmascriptModulePartReference::new(*self.module)),
original_export.clone_value(),
false,
),
......@@ -240,7 +243,7 @@ impl EcmascriptChunkPlaceable for EcmascriptModuleFacadeModule {
exports.insert(
export.await?.clone_value(),
EsmExport::ImportedNamespace(Vc::upcast(EcmascriptModulePartReference::new(
self.module,
*self.module,
))),
);
}
......@@ -284,8 +287,8 @@ impl EcmascriptChunkPlaceable for EcmascriptModuleFacadeModule {
impl ChunkableModule for EcmascriptModuleFacadeModule {
#[turbo_tasks::function]
fn as_chunk_item(
self: Vc<Self>,
chunking_context: Vc<Box<dyn ChunkingContext>>,
self: ResolvedVc<Self>,
chunking_context: ResolvedVc<Box<dyn ChunkingContext>>,
) -> Vc<Box<dyn turbopack_core::chunk::ChunkItem>> {
Vc::upcast(
EcmascriptModuleFacadeChunkItem {
......
use anyhow::Result;
use turbo_tasks::Vc;
use turbo_tasks::{ResolvedVc, Vc};
use turbopack_core::{
chunk::{AsyncModuleInfo, ChunkItem, ChunkType, ChunkingContext},
ident::AssetIdent,
......@@ -19,8 +19,8 @@ use crate::{
/// The chunk item for [EcmascriptModuleLocalsModule].
#[turbo_tasks::value(shared)]
pub struct EcmascriptModuleLocalsChunkItem {
pub(super) module: Vc<EcmascriptModuleLocalsModule>,
pub(super) chunking_context: Vc<Box<dyn ChunkingContext>>,
pub(super) module: ResolvedVc<EcmascriptModuleLocalsModule>,
pub(super) chunking_context: ResolvedVc<Box<dyn ChunkingContext>>,
}
#[turbo_tasks::value_impl]
......@@ -52,10 +52,10 @@ impl EcmascriptChunkItem for EcmascriptModuleLocalsChunkItem {
parsed,
self.module.ident(),
module_type_result.module_type,
chunking_context,
analyze_result.local_references,
analyze_result.code_generation,
analyze_result.async_module,
*chunking_context,
*analyze_result.local_references,
*analyze_result.code_generation,
*analyze_result.async_module,
analyze_result.source_map,
exports,
async_module_info,
......@@ -63,15 +63,15 @@ impl EcmascriptChunkItem for EcmascriptModuleLocalsChunkItem {
Ok(EcmascriptChunkItemContent::new(
content,
self.chunking_context,
original_module.await?.options,
*chunking_context,
*original_module.await?.options,
async_module_options,
))
}
#[turbo_tasks::function]
fn chunking_context(&self) -> Vc<Box<dyn ChunkingContext>> {
self.chunking_context
*self.chunking_context
}
}
......@@ -89,7 +89,7 @@ impl ChunkItem for EcmascriptModuleLocalsChunkItem {
#[turbo_tasks::function]
fn chunking_context(&self) -> Vc<Box<dyn ChunkingContext>> {
Vc::upcast(self.chunking_context)
*ResolvedVc::upcast(self.chunking_context)
}
#[turbo_tasks::function]
......@@ -101,7 +101,7 @@ impl ChunkItem for EcmascriptModuleLocalsChunkItem {
#[turbo_tasks::function]
fn module(&self) -> Vc<Box<dyn Module>> {
Vc::upcast(self.module)
*ResolvedVc::upcast(self.module)
}
#[turbo_tasks::function]
......@@ -109,7 +109,7 @@ impl ChunkItem for EcmascriptModuleLocalsChunkItem {
let module = self.module.await?;
let analyze = module.module.analyze().await?;
if let Some(async_module) = *analyze.async_module.await? {
let is_self_async = async_module.is_self_async(analyze.local_references);
let is_self_async = async_module.is_self_async(*analyze.local_references);
Ok(is_self_async)
} else {
Ok(Vc::cell(false))
......
use std::collections::BTreeMap;
use anyhow::{bail, Result};
use turbo_tasks::Vc;
use turbo_tasks::{ResolvedVc, Vc};
use turbo_tasks_fs::glob::Glob;
use turbopack_core::{
asset::{Asset, AssetContent},
......@@ -27,13 +27,13 @@ use crate::{
/// from [EcmascriptModuleFacadeModule] instead.
#[turbo_tasks::value]
pub struct EcmascriptModuleLocalsModule {
pub module: Vc<EcmascriptModuleAsset>,
pub module: ResolvedVc<EcmascriptModuleAsset>,
}
#[turbo_tasks::value_impl]
impl EcmascriptModuleLocalsModule {
#[turbo_tasks::function]
pub fn new(module: Vc<EcmascriptModuleAsset>) -> Vc<Self> {
pub fn new(module: ResolvedVc<EcmascriptModuleAsset>) -> Vc<Self> {
EcmascriptModuleLocalsModule { module }.cell()
}
}
......@@ -50,7 +50,7 @@ impl Module for EcmascriptModuleLocalsModule {
#[turbo_tasks::function]
async fn references(&self) -> Result<Vc<ModuleReferences>> {
let result = self.module.analyze().await?;
Ok(result.local_references)
Ok(*result.local_references)
}
}
......@@ -113,8 +113,8 @@ impl EcmascriptChunkPlaceable for EcmascriptModuleLocalsModule {
impl ChunkableModule for EcmascriptModuleLocalsModule {
#[turbo_tasks::function]
fn as_chunk_item(
self: Vc<Self>,
chunking_context: Vc<Box<dyn ChunkingContext>>,
self: ResolvedVc<Self>,
chunking_context: ResolvedVc<Box<dyn ChunkingContext>>,
) -> Vc<Box<dyn turbopack_core::chunk::ChunkItem>> {
Vc::upcast(
EcmascriptModuleLocalsChunkItem {
......
use anyhow::{bail, Result};
use turbo_tasks::{Value, Vc};
use turbo_tasks::{ResolvedVc, Value, Vc};
use turbo_tasks_fs::FileSystemPath;
use turbopack_core::{
code_builder::{Code, CodeBuilder},
......@@ -16,7 +16,7 @@ use crate::EcmascriptAnalyzable;
/// the final runtime code, while keeping source map information.
#[turbo_tasks::value]
pub struct StaticEcmascriptCode {
asset_context: Vc<Box<dyn AssetContext>>,
asset_context: ResolvedVc<Box<dyn AssetContext>>,
asset: Vc<Box<dyn EcmascriptAnalyzable>>,
}
......@@ -25,12 +25,12 @@ impl StaticEcmascriptCode {
/// Creates a new [`Vc<StaticEcmascriptCode>`].
#[turbo_tasks::function]
pub async fn new(
asset_context: Vc<Box<dyn AssetContext>>,
asset_path: Vc<FileSystemPath>,
asset_context: ResolvedVc<Box<dyn AssetContext>>,
asset_path: ResolvedVc<FileSystemPath>,
) -> Result<Vc<Self>> {
let module = asset_context
.process(
Vc::upcast(FileSource::new(asset_path)),
Vc::upcast(FileSource::new(*asset_path)),
Value::new(ReferenceType::Runtime),
)
.module();
......
use anyhow::Result;
use turbo_rcstr::RcStr;
use turbo_tasks::Vc;
use turbo_tasks::{ResolvedVc, Vc};
use turbo_tasks_fs::FileContent;
use turbopack_core::{
asset::{Asset, AssetContent},
......@@ -19,13 +19,13 @@ fn modifier() -> Vc<RcStr> {
/// export of a JS module.
#[turbo_tasks::value]
pub struct TextContentFileSource {
pub source: Vc<Box<dyn Source>>,
pub source: ResolvedVc<Box<dyn Source>>,
}
#[turbo_tasks::value_impl]
impl TextContentFileSource {
#[turbo_tasks::function]
pub fn new(source: Vc<Box<dyn Source>>) -> Vc<Self> {
pub fn new(source: ResolvedVc<Box<dyn Source>>) -> Vc<Self> {
TextContentFileSource { source }.cell()
}
}
......
......@@ -29,7 +29,7 @@ use turbopack_core::{
#[derive(Debug, Clone, Hash)]
pub enum EcmascriptInputTransform {
CommonJs,
Plugin(Vc<TransformPlugin>),
Plugin(ResolvedVc<TransformPlugin>),
PresetEnv(ResolvedVc<Environment>),
React {
#[serde(default)]
......@@ -37,9 +37,9 @@ pub enum EcmascriptInputTransform {
#[serde(default)]
refresh: bool,
// swc.jsc.transform.react.importSource
import_source: Vc<Option<RcStr>>,
import_source: ResolvedVc<Option<RcStr>>,
// swc.jsc.transform.react.runtime,
runtime: Vc<Option<RcStr>>,
runtime: ResolvedVc<Option<RcStr>>,
},
GlobalTypeofs {
window_value: String,
......@@ -115,7 +115,7 @@ pub struct TransformContext<'a> {
pub file_path_str: &'a str,
pub file_name_str: &'a str,
pub file_name_hash: u128,
pub file_path: Vc<FileSystemPath>,
pub file_path: ResolvedVc<FileSystemPath>,
}
impl EcmascriptInputTransform {
......@@ -305,7 +305,7 @@ pub fn remove_shebang(program: &mut Program) {
#[turbo_tasks::value(shared)]
pub struct UnsupportedServerActionIssue {
pub file_path: Vc<FileSystemPath>,
pub file_path: ResolvedVc<FileSystemPath>,
}
#[turbo_tasks::value_impl]
......@@ -325,7 +325,7 @@ impl Issue for UnsupportedServerActionIssue {
#[turbo_tasks::function]
fn file_path(&self) -> Vc<FileSystemPath> {
self.file_path
*self.file_path
}
#[turbo_tasks::function]
......
use anyhow::{Context, Result};
use turbo_tasks::Vc;
use turbo_tasks::{ResolvedVc, Vc};
use turbopack_core::{
asset::{Asset, AssetContent},
chunk::{AsyncModuleInfo, ChunkableModule, ChunkingContext, EvaluatableAsset},
......@@ -26,8 +26,8 @@ use crate::{
/// This type is used for an advanced tree shkaing.
#[turbo_tasks::value]
pub struct EcmascriptModulePartAsset {
pub full_module: Vc<EcmascriptModuleAsset>,
pub part: Vc<ModulePart>,
pub full_module: ResolvedVc<EcmascriptModuleAsset>,
pub part: ResolvedVc<ModulePart>,
}
#[turbo_tasks::value_impl]
......@@ -36,7 +36,7 @@ impl EcmascriptParsable for EcmascriptModulePartAsset {
async fn failsafe_parse(&self) -> Result<Vc<ParseResult>> {
let parsed = self.full_module.failsafe_parse();
let split_data = split(self.full_module.ident(), self.full_module.source(), parsed);
Ok(part_of_module(split_data, self.part))
Ok(part_of_module(split_data, *self.part))
}
#[turbo_tasks::function]
fn parse_original(&self) -> Vc<ParseResult> {
......@@ -54,7 +54,7 @@ impl EcmascriptAnalyzable for EcmascriptModulePartAsset {
#[turbo_tasks::function]
fn analyze(&self) -> Vc<AnalyzeEcmascriptModuleResult> {
let part = self.part;
analyse_ecmascript_module(self.full_module, Some(part))
analyse_ecmascript_module(*self.full_module, Some(*part))
}
#[turbo_tasks::function]
......@@ -79,7 +79,10 @@ impl EcmascriptModulePartAsset {
/// of a pointer to the full module and the [ModulePart] pointing the part
/// of the module.
#[turbo_tasks::function]
pub fn new(module: Vc<EcmascriptModuleAsset>, part: Vc<ModulePart>) -> Vc<Self> {
pub fn new(
module: ResolvedVc<EcmascriptModuleAsset>,
part: ResolvedVc<ModulePart>,
) -> Vc<Self> {
EcmascriptModulePartAsset {
full_module: module,
part,
......@@ -104,7 +107,7 @@ impl EcmascriptModulePartAsset {
#[turbo_tasks::function]
pub async fn is_async_module(self: Vc<Self>) -> Result<Vc<bool>> {
let this = self.await?;
let result = analyze(this.full_module, this.part);
let result = analyze(*this.full_module, *this.part);
if let Some(async_module) = *result.await?.async_module.await? {
Ok(async_module.is_self_async(self.references()))
......@@ -118,23 +121,23 @@ impl EcmascriptModulePartAsset {
impl Module for EcmascriptModulePartAsset {
#[turbo_tasks::function]
fn ident(&self) -> Vc<AssetIdent> {
self.full_module.ident().with_part(self.part)
self.full_module.ident().with_part(*self.part)
}
#[turbo_tasks::function]
async fn references(&self) -> Result<Vc<ModuleReferences>> {
let split_data = split_module(self.full_module).await?;
let split_data = split_module(*self.full_module).await?;
let analyze = analyze(self.full_module, self.part).await?;
let analyze = analyze(*self.full_module, *self.part).await?;
let deps = match &*split_data {
SplitResult::Ok { deps, .. } => deps,
SplitResult::Failed { .. } => return Ok(analyze.references),
SplitResult::Failed { .. } => return Ok(*analyze.references),
};
let part_dep = |part: Vc<ModulePart>| -> Vc<Box<dyn ModuleReference>> {
Vc::upcast(SingleModuleReference::new(
Vc::upcast(EcmascriptModulePartAsset::new(self.full_module, part)),
Vc::upcast(EcmascriptModulePartAsset::new(*self.full_module, part)),
Vc::cell("ecmascript module part".into()),
))
};
......@@ -149,7 +152,7 @@ impl Module for EcmascriptModulePartAsset {
}
let deps = {
let part_id = get_part_id(&split_data, self.part)
let part_id = get_part_id(&split_data, *self.part)
.await
.with_context(|| format!("part {:?} is not found in the module", self.part))?;
......@@ -194,7 +197,7 @@ impl Asset for EcmascriptModulePartAsset {
impl EcmascriptChunkPlaceable for EcmascriptModulePartAsset {
#[turbo_tasks::function]
async fn get_exports(self: Vc<Self>) -> Result<Vc<EcmascriptExports>> {
Ok(self.analyze().await?.exports)
Ok(*self.analyze().await?.exports)
}
}
......@@ -202,8 +205,8 @@ impl EcmascriptChunkPlaceable for EcmascriptModulePartAsset {
impl ChunkableModule for EcmascriptModulePartAsset {
#[turbo_tasks::function]
fn as_chunk_item(
self: Vc<Self>,
chunking_context: Vc<Box<dyn ChunkingContext>>,
self: ResolvedVc<Self>,
chunking_context: ResolvedVc<Box<dyn ChunkingContext>>,
) -> Vc<Box<dyn turbopack_core::chunk::ChunkItem>> {
Vc::upcast(
EcmascriptModulePartChunkItem {
......@@ -219,7 +222,7 @@ impl ChunkableModule for EcmascriptModulePartAsset {
impl EcmascriptModulePartAsset {
#[turbo_tasks::function]
pub(super) fn analyze(&self) -> Vc<AnalyzeEcmascriptModuleResult> {
analyze(self.full_module, self.part)
analyze(*self.full_module, *self.part)
}
}
......
use anyhow::Result;
use turbo_tasks::Vc;
use turbo_tasks::{ResolvedVc, Vc};
use turbopack_core::{
chunk::{AsyncModuleInfo, ChunkItem, ChunkType, ChunkingContext},
ident::AssetIdent,
......@@ -19,8 +19,8 @@ use crate::{
/// This is a pointer to a part of an ES module.
#[turbo_tasks::value(shared)]
pub struct EcmascriptModulePartChunkItem {
pub(super) module: Vc<EcmascriptModulePartAsset>,
pub(super) chunking_context: Vc<Box<dyn ChunkingContext>>,
pub(super) module: ResolvedVc<EcmascriptModulePartAsset>,
pub(super) chunking_context: ResolvedVc<Box<dyn ChunkingContext>>,
}
#[turbo_tasks::value_impl]
......@@ -37,8 +37,8 @@ impl EcmascriptChunkItem for EcmascriptModulePartChunkItem {
) -> Result<Vc<EcmascriptChunkItemContent>> {
let module = self.module.await?;
let split_data = split_module(module.full_module);
let parsed = part_of_module(split_data, module.part);
let split_data = split_module(*module.full_module);
let parsed = part_of_module(split_data, *module.part);
let analyze = self.module.analyze().await?;
let async_module_options = analyze.async_module.module_options(async_module_info);
......@@ -49,26 +49,26 @@ impl EcmascriptChunkItem for EcmascriptModulePartChunkItem {
parsed,
module.full_module.ident(),
module_type_result.module_type,
self.chunking_context,
analyze.references,
analyze.code_generation,
analyze.async_module,
*self.chunking_context,
*analyze.references,
*analyze.code_generation,
*analyze.async_module,
analyze.source_map,
analyze.exports,
*analyze.exports,
async_module_info,
);
Ok(EcmascriptChunkItemContent::new(
content,
self.chunking_context,
module.full_module.await?.options,
*self.chunking_context,
*module.full_module.await?.options,
async_module_options,
))
}
#[turbo_tasks::function]
fn chunking_context(&self) -> Vc<Box<dyn ChunkingContext>> {
self.chunking_context
*self.chunking_context
}
}
......@@ -86,7 +86,7 @@ impl ChunkItem for EcmascriptModulePartChunkItem {
#[turbo_tasks::function]
fn chunking_context(&self) -> Vc<Box<dyn ChunkingContext>> {
Vc::upcast(self.chunking_context)
*ResolvedVc::upcast(self.chunking_context)
}
#[turbo_tasks::function]
......@@ -98,7 +98,7 @@ impl ChunkItem for EcmascriptModulePartChunkItem {
#[turbo_tasks::function]
fn module(&self) -> Vc<Box<dyn Module>> {
Vc::upcast(self.module)
*ResolvedVc::upcast(self.module)
}
#[turbo_tasks::function]
......
......@@ -13,7 +13,7 @@ use swc_core::{
},
};
use turbo_rcstr::RcStr;
use turbo_tasks::{FxIndexSet, ValueToString, Vc};
use turbo_tasks::{FxIndexSet, ResolvedVc, ValueToString, Vc};
use turbopack_core::{ident::AssetIdent, resolve::ModulePart, source::Source};
pub(crate) use self::graph::{
......@@ -442,14 +442,14 @@ async fn get_part_id(result: &SplitResult, part: Vc<ModulePart>) -> Result<u32>
#[turbo_tasks::value(shared, serialization = "none", eq = "manual")]
pub(crate) enum SplitResult {
Ok {
asset_ident: Vc<AssetIdent>,
asset_ident: ResolvedVc<AssetIdent>,
/// `u32` is a index to `modules`.
#[turbo_tasks(trace_ignore)]
entrypoints: FxHashMap<Key, u32>,
#[turbo_tasks(debug_ignore, trace_ignore)]
modules: Vec<Vc<ParseResult>>,
modules: Vec<ResolvedVc<ParseResult>>,
#[turbo_tasks(trace_ignore)]
deps: FxHashMap<u32, Vec<PartId>>,
......@@ -458,7 +458,7 @@ pub(crate) enum SplitResult {
star_reexports: Vec<ExportAll>,
},
Failed {
parse_result: Vc<ParseResult>,
parse_result: ResolvedVc<ParseResult>,
},
}
......@@ -478,9 +478,9 @@ pub(super) async fn split_module(asset: Vc<EcmascriptModuleAsset>) -> Result<Vc<
#[turbo_tasks::function]
pub(super) async fn split(
ident: Vc<AssetIdent>,
ident: ResolvedVc<AssetIdent>,
source: Vc<Box<dyn Source>>,
parsed: Vc<ParseResult>,
parsed: ResolvedVc<ParseResult>,
) -> Result<Vc<SplitResult>> {
// Do not split already split module
if !ident.await?.parts.is_empty() {
......@@ -580,7 +580,7 @@ pub(super) async fn split(
Some(source),
);
ParseResult::cell(ParseResult::Ok {
ParseResult::resolved_cell(ParseResult::Ok {
program,
globals: globals.clone(),
comments: comments.clone(),
......@@ -728,8 +728,8 @@ pub(crate) async fn part_of_module(
);
}
Ok(modules[part_id as usize])
Ok(*modules[part_id as usize])
}
SplitResult::Failed { parse_result } => Ok(*parse_result),
SplitResult::Failed { parse_result } => Ok(**parse_result),
}
}
......@@ -169,14 +169,17 @@ impl Asset for TsConfigModuleAsset {
#[turbo_tasks::value]
#[derive(Hash, Debug)]
pub struct CompilerReference {
pub origin: Vc<Box<dyn ResolveOrigin>>,
pub request: Vc<Request>,
pub origin: ResolvedVc<Box<dyn ResolveOrigin>>,
pub request: ResolvedVc<Request>,
}
#[turbo_tasks::value_impl]
impl CompilerReference {
#[turbo_tasks::function]
pub fn new(origin: Vc<Box<dyn ResolveOrigin>>, request: Vc<Request>) -> Vc<Self> {
pub fn new(
origin: ResolvedVc<Box<dyn ResolveOrigin>>,
request: ResolvedVc<Request>,
) -> Vc<Self> {
Self::cell(CompilerReference { origin, request })
}
}
......@@ -185,7 +188,7 @@ impl CompilerReference {
impl ModuleReference for CompilerReference {
#[turbo_tasks::function]
fn resolve_reference(&self) -> Vc<ModuleResolveResult> {
cjs_resolve(self.origin, self.request, None, false)
cjs_resolve(*self.origin, *self.request, None, false)
}
}
......@@ -202,13 +205,13 @@ impl ValueToString for CompilerReference {
#[turbo_tasks::value]
#[derive(Hash, Debug)]
pub struct TsExtendsReference {
pub config: Vc<Box<dyn Source>>,
pub config: ResolvedVc<Box<dyn Source>>,
}
#[turbo_tasks::value_impl]
impl TsExtendsReference {
#[turbo_tasks::function]
pub fn new(config: Vc<Box<dyn Source>>) -> Vc<Self> {
pub fn new(config: ResolvedVc<Box<dyn Source>>) -> Vc<Self> {
Self::cell(TsExtendsReference { config })
}
}
......@@ -218,7 +221,7 @@ impl ModuleReference for TsExtendsReference {
#[turbo_tasks::function]
async fn resolve_reference(&self) -> Result<Vc<ModuleResolveResult>> {
Ok(ModuleResolveResult::module(ResolvedVc::upcast(
RawModule::new(Vc::upcast(self.config))
RawModule::new(*ResolvedVc::upcast(self.config))
.to_resolved()
.await?,
))
......@@ -243,14 +246,17 @@ impl ValueToString for TsExtendsReference {
#[turbo_tasks::value]
#[derive(Hash, Debug)]
pub struct TsNodeRequireReference {
pub origin: Vc<Box<dyn ResolveOrigin>>,
pub request: Vc<Request>,
pub origin: ResolvedVc<Box<dyn ResolveOrigin>>,
pub request: ResolvedVc<Request>,
}
#[turbo_tasks::value_impl]
impl TsNodeRequireReference {
#[turbo_tasks::function]
pub fn new(origin: Vc<Box<dyn ResolveOrigin>>, request: Vc<Request>) -> Vc<Self> {
pub fn new(
origin: ResolvedVc<Box<dyn ResolveOrigin>>,
request: ResolvedVc<Request>,
) -> Vc<Self> {
Self::cell(TsNodeRequireReference { origin, request })
}
}
......@@ -259,7 +265,7 @@ impl TsNodeRequireReference {
impl ModuleReference for TsNodeRequireReference {
#[turbo_tasks::function]
fn resolve_reference(&self) -> Vc<ModuleResolveResult> {
cjs_resolve(self.origin, self.request, None, false)
cjs_resolve(*self.origin, *self.request, None, false)
}
}
......@@ -280,14 +286,17 @@ impl ValueToString for TsNodeRequireReference {
#[turbo_tasks::value]
#[derive(Hash, Debug)]
pub struct TsConfigTypesReference {
pub origin: Vc<Box<dyn ResolveOrigin>>,
pub request: Vc<Request>,
pub origin: ResolvedVc<Box<dyn ResolveOrigin>>,
pub request: ResolvedVc<Request>,
}
#[turbo_tasks::value_impl]
impl TsConfigTypesReference {
#[turbo_tasks::function]
pub fn new(origin: Vc<Box<dyn ResolveOrigin>>, request: Vc<Request>) -> Vc<Self> {
pub fn new(
origin: ResolvedVc<Box<dyn ResolveOrigin>>,
request: ResolvedVc<Request>,
) -> Vc<Self> {
Self::cell(TsConfigTypesReference { origin, request })
}
}
......@@ -296,7 +305,7 @@ impl TsConfigTypesReference {
impl ModuleReference for TsConfigTypesReference {
#[turbo_tasks::function]
fn resolve_reference(&self) -> Vc<ModuleResolveResult> {
type_resolve(self.origin, self.request)
type_resolve(*self.origin, *self.request)
}
}
......
......@@ -31,18 +31,18 @@ fn modifier() -> Vc<RcStr> {
#[turbo_tasks::value]
pub struct WebpackModuleAsset {
pub source: Vc<Box<dyn Source>>,
pub runtime: Vc<WebpackRuntime>,
pub transforms: Vc<EcmascriptInputTransforms>,
pub source: ResolvedVc<Box<dyn Source>>,
pub runtime: ResolvedVc<WebpackRuntime>,
pub transforms: ResolvedVc<EcmascriptInputTransforms>,
}
#[turbo_tasks::value_impl]
impl WebpackModuleAsset {
#[turbo_tasks::function]
pub fn new(
source: Vc<Box<dyn Source>>,
runtime: Vc<WebpackRuntime>,
transforms: Vc<EcmascriptInputTransforms>,
source: ResolvedVc<Box<dyn Source>>,
runtime: ResolvedVc<WebpackRuntime>,
transforms: ResolvedVc<EcmascriptInputTransforms>,
) -> Vc<Self> {
Self::cell(WebpackModuleAsset {
source,
......@@ -61,7 +61,7 @@ impl Module for WebpackModuleAsset {
#[turbo_tasks::function]
fn references(&self) -> Vc<ModuleReferences> {
module_references(self.source, self.runtime, self.transforms)
module_references(*self.source, *self.runtime, *self.transforms)
}
}
......@@ -78,7 +78,7 @@ pub struct WebpackChunkAssetReference {
#[turbo_tasks(trace_ignore)]
pub chunk_id: Lit,
pub runtime: Vc<WebpackRuntime>,
pub transforms: Vc<EcmascriptInputTransforms>,
pub transforms: ResolvedVc<EcmascriptInputTransforms>,
}
#[turbo_tasks::value_impl]
......@@ -101,7 +101,7 @@ impl ModuleReference for WebpackChunkAssetReference {
let source = Vc::upcast(FileSource::new(context_path.join(filename)));
ModuleResolveResult::module(ResolvedVc::upcast(
WebpackModuleAsset::new(source, self.runtime, self.transforms)
WebpackModuleAsset::new(source, self.runtime, *self.transforms)
.to_resolved()
.await?,
))
......@@ -127,9 +127,9 @@ impl ValueToString for WebpackChunkAssetReference {
#[turbo_tasks::value(shared)]
pub struct WebpackEntryAssetReference {
pub source: Vc<Box<dyn Source>>,
pub source: ResolvedVc<Box<dyn Source>>,
pub runtime: Vc<WebpackRuntime>,
pub transforms: Vc<EcmascriptInputTransforms>,
pub transforms: ResolvedVc<EcmascriptInputTransforms>,
}
#[turbo_tasks::value_impl]
......@@ -137,7 +137,7 @@ impl ModuleReference for WebpackEntryAssetReference {
#[turbo_tasks::function]
async fn resolve_reference(&self) -> Result<Vc<ModuleResolveResult>> {
Ok(ModuleResolveResult::module(ResolvedVc::upcast(
WebpackModuleAsset::new(self.source, self.runtime, self.transforms)
WebpackModuleAsset::new(*self.source, self.runtime, *self.transforms)
.to_resolved()
.await?,
))
......@@ -155,10 +155,10 @@ impl ValueToString for WebpackEntryAssetReference {
#[turbo_tasks::value(shared)]
pub struct WebpackRuntimeAssetReference {
pub origin: Vc<Box<dyn ResolveOrigin>>,
pub origin: ResolvedVc<Box<dyn ResolveOrigin>>,
pub request: Vc<Request>,
pub runtime: Vc<WebpackRuntime>,
pub transforms: Vc<EcmascriptInputTransforms>,
pub transforms: ResolvedVc<EcmascriptInputTransforms>,
}
#[turbo_tasks::value_impl]
......@@ -181,7 +181,7 @@ impl ModuleReference for WebpackRuntimeAssetReference {
.await?
.map_module(|source| async move {
Ok(ModuleResolveResultItem::Module(ResolvedVc::upcast(
WebpackModuleAsset::new(*source, self.runtime, self.transforms)
WebpackModuleAsset::new(*source, self.runtime, *self.transforms)
.to_resolved()
.await?,
)))
......
......@@ -12,7 +12,7 @@ use swc_core::{
visit::{Visit, VisitWith},
},
};
use turbo_tasks::{Value, Vc};
use turbo_tasks::{ResolvedVc, Value, Vc};
use turbo_tasks_fs::FileSystemPath;
use turbopack_core::source::Source;
......@@ -31,7 +31,7 @@ pub enum WebpackRuntime {
/// before converting to string
#[turbo_tasks(trace_ignore)]
chunk_request_expr: JsValue,
context_path: Vc<FileSystemPath>,
context_path: ResolvedVc<FileSystemPath>,
},
None,
}
......@@ -232,7 +232,7 @@ pub async fn webpack_runtime(
return Ok(WebpackRuntime::Webpack5 {
chunk_request_expr: value,
context_path: source.ident().path().parent().resolve().await?,
context_path: source.ident().path().parent().to_resolved().await?,
}
.into());
}
......
......@@ -6,7 +6,7 @@ use swc_core::{
visit::{Visit, VisitWith},
},
};
use turbo_tasks::{Value, Vc};
use turbo_tasks::{ResolvedVc, Value, Vc};
use turbopack_core::{
reference::{ModuleReference, ModuleReferences},
source::Source,
......@@ -23,12 +23,12 @@ use crate::{
pub async fn module_references(
source: Vc<Box<dyn Source>>,
runtime: Vc<WebpackRuntime>,
transforms: Vc<EcmascriptInputTransforms>,
transforms: ResolvedVc<EcmascriptInputTransforms>,
) -> Result<Vc<ModuleReferences>> {
let parsed = parse(
source,
Value::new(EcmascriptModuleAssetType::Ecmascript),
transforms,
*transforms,
)
.await?;
match &*parsed {
......@@ -64,7 +64,7 @@ pub async fn module_references(
struct ModuleReferencesVisitor<'a> {
runtime: Vc<WebpackRuntime>,
references: &'a mut Vec<Vc<Box<dyn ModuleReference>>>,
transforms: Vc<EcmascriptInputTransforms>,
transforms: ResolvedVc<EcmascriptInputTransforms>,
}
impl Visit for ModuleReferencesVisitor<'_> {
......
use anyhow::{bail, Result};
use indoc::formatdoc;
use turbo_rcstr::RcStr;
use turbo_tasks::{TryJoinIterExt, Value, ValueToString, Vc};
use turbo_tasks::{ResolvedVc, TryJoinIterExt, Value, ValueToString, Vc};
use turbopack_core::{
chunk::{
availability_info::AvailabilityInfo, ChunkData, ChunkItem, ChunkType, ChunkingContext,
......@@ -24,8 +24,8 @@ use crate::{
#[turbo_tasks::value(shared)]
pub struct WorkerLoaderChunkItem {
pub module: Vc<WorkerLoaderModule>,
pub chunking_context: Vc<Box<dyn ChunkingContext>>,
pub module: ResolvedVc<WorkerLoaderModule>,
pub chunking_context: ResolvedVc<Box<dyn ChunkingContext>>,
}
#[turbo_tasks::function]
......@@ -40,7 +40,7 @@ impl WorkerLoaderChunkItem {
let module = self.module.await?;
let Some(evaluatable) =
Vc::try_resolve_downcast::<Box<dyn EvaluatableAsset>>(module.inner).await?
ResolvedVc::try_downcast::<Box<dyn EvaluatableAsset>>(module.inner).await?
else {
bail!(
"{} is not evaluatable for Worker loader module",
......@@ -54,7 +54,7 @@ impl WorkerLoaderChunkItem {
.chunk_path(module.inner.ident(), ".js".into()),
)
.with_modifier(worker_modifier()),
EvaluatableAssets::empty().with_entry(evaluatable),
EvaluatableAssets::empty().with_entry(*evaluatable),
Value::new(AvailabilityInfo::Root),
))
}
......@@ -73,7 +73,7 @@ impl WorkerLoaderChunkItem {
impl EcmascriptChunkItem for WorkerLoaderChunkItem {
#[turbo_tasks::function]
fn chunking_context(&self) -> Vc<Box<dyn ChunkingContext>> {
self.chunking_context
*self.chunking_context
}
#[turbo_tasks::function]
......@@ -138,7 +138,7 @@ impl ChunkItem for WorkerLoaderChunkItem {
#[turbo_tasks::function]
fn chunking_context(&self) -> Vc<Box<dyn ChunkingContext>> {
Vc::upcast(self.chunking_context)
*ResolvedVc::upcast(self.chunking_context)
}
#[turbo_tasks::function]
......@@ -150,6 +150,6 @@ impl ChunkItem for WorkerLoaderChunkItem {
#[turbo_tasks::function]
fn module(&self) -> Vc<Box<dyn Module>> {
Vc::upcast(self.module)
*ResolvedVc::upcast(self.module)
}
}
use anyhow::Result;
use turbo_rcstr::RcStr;
use turbo_tasks::Vc;
use turbo_tasks::{ResolvedVc, Vc};
use turbopack_core::{
asset::{Asset, AssetContent},
chunk::{ChunkableModule, ChunkingContext},
......@@ -20,13 +20,13 @@ fn modifier() -> Vc<RcStr> {
/// and exports a URL to pass to the worker constructor.
#[turbo_tasks::value]
pub struct WorkerLoaderModule {
pub inner: Vc<Box<dyn ChunkableModule>>,
pub inner: ResolvedVc<Box<dyn ChunkableModule>>,
}
#[turbo_tasks::value_impl]
impl WorkerLoaderModule {
#[turbo_tasks::function]
pub fn new(module: Vc<Box<dyn ChunkableModule>>) -> Vc<Self> {
pub fn new(module: ResolvedVc<Box<dyn ChunkableModule>>) -> Vc<Self> {
Self::cell(WorkerLoaderModule { inner: module })
}
......@@ -45,13 +45,13 @@ fn inner_module_reference_description() -> Vc<RcStr> {
impl Module for WorkerLoaderModule {
#[turbo_tasks::function]
fn ident(&self) -> Vc<AssetIdent> {
Self::asset_ident_for(self.inner)
Self::asset_ident_for(*self.inner)
}
#[turbo_tasks::function]
async fn references(self: Vc<Self>) -> Result<Vc<ModuleReferences>> {
Ok(Vc::cell(vec![Vc::upcast(SingleModuleReference::new(
Vc::upcast(self.await?.inner),
*ResolvedVc::upcast(self.await?.inner),
inner_module_reference_description(),
))]))
}
......@@ -69,8 +69,8 @@ impl Asset for WorkerLoaderModule {
impl ChunkableModule for WorkerLoaderModule {
#[turbo_tasks::function]
fn as_chunk_item(
self: Vc<Self>,
chunking_context: Vc<Box<dyn ChunkingContext>>,
self: ResolvedVc<Self>,
chunking_context: ResolvedVc<Box<dyn ChunkingContext>>,
) -> Vc<Box<dyn turbopack_core::chunk::ChunkItem>> {
Vc::upcast(
WorkerLoaderChunkItem {
......
......@@ -249,11 +249,11 @@ async fn run_test(resource: RcStr) -> Result<Vc<FileSystemPath>> {
conditions,
vec![ModuleRuleEffect::ExtendEcmascriptTransforms {
prepend: ResolvedVc::cell(vec![
EcmascriptInputTransform::Plugin(Vc::cell(Box::new(
EcmascriptInputTransform::Plugin(ResolvedVc::cell(Box::new(
EmotionTransformer::new(&EmotionTransformConfig::default())
.expect("Should be able to create emotion transformer"),
) as _)),
EcmascriptInputTransform::Plugin(Vc::cell(Box::new(
EcmascriptInputTransform::Plugin(ResolvedVc::cell(Box::new(
StyledComponentsTransformer::new(&StyledComponentsTransformConfig::default()),
) as _)),
]),
......
......@@ -120,8 +120,8 @@ impl ModuleOptions {
transforms.push(EcmascriptInputTransform::React {
development: jsx.development,
refresh: jsx.react_refresh,
import_source: Vc::cell(jsx.import_source.clone()),
runtime: Vc::cell(jsx.runtime.clone()),
import_source: ResolvedVc::cell(jsx.import_source.clone()),
runtime: ResolvedVc::cell(jsx.runtime.clone()),
});
}
......
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