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