Unverified Commit e1ea01de authored by Benjamin Woodruff's avatar Benjamin Woodruff Committed by GitHub

codemod(turbopack): Remove unused `Result<...>` return types from…

codemod(turbopack): Remove unused `Result<...>` return types from `#[turbo_task::function]`s (#70492)

The `#[turbo_tasks::function]` macro always exposes a `impl
Future<Output = Result<ReadRef<T>>>`, regardless of the function's
actual return type.

We only need to use a `Result<...>` return type when the function can
fail. If it's infallible, this just adds noise.

I left a bunch of these behind in #70412, plus I think we had a lot of
these independent of that PR. This cleans them up.

```yaml
language: rust
id: remove_unused_result_return_type

utils:
  last-expression-inside-block:
    any:
      - inside: # single-line blocks just have the expression as the only child
          kind: block
        nthChild:
          position: 1
          reverse: true
      - inside: # multi-line blocks wrap their final expression in an expression_statement
          kind: expression_statement
          inside:
            kind: block
          nthChild:
            position: 1
            reverse: true
  ok-expression:
    kind: call_expression
    any:
      - pattern: Ok($_ARG)
      - pattern: $$$::Ok($_ARG)
  ok-expression-capturing:
    kind: call_expression
    any:
      - pattern: Ok($ARG)
      - pattern: $$$::Ok($ARG)
  # ast-grep does not appear to allow utils to be recursive, split out "simple blocks", and limit supported nesting
  simple-block-with-implicit-ok-return:
    kind: block
    has:
      nthChild:
        position: 1
        reverse: true
      matches: ok-expression
  simple-expression-ok-value:
    any:
      - matches: simple-block-with-implicit-ok-return
      - kind: if_expression
        all:
          - has:
              field: consequence
              matches: simple-block-with-implicit-ok-return
          - has:
              field: alternative
              has:
                matches: simple-block-with-implicit-ok-return
      - kind: match_expression
        has:
          field: body
          not:
            has:
              kind: match_arm
              has:
                field: value
                not:
                  any:
                    - matches: ok-expression
                    - matches: simple-block-with-implicit-ok-return
  block-with-implicit-ok-return:
    any:
      - matches: simple-block-with-implicit-ok-return
      - kind: block
        has:
          nthChild:
            position: 1
            reverse: true
          any:
            - kind: expression_statement 
              has:
                matches: simple-expression-ok-value
            - matches: simple-expression-ok-value # single-line blocks don't
  result-return-type:
    pattern:
      context: fn func() -> Result<$INNER_RET_TY> {}
      selector: generic_type
  infallible-fn:  # this function only appears to return `Ok(...)`, it does not use try_expression (`?`) or `anyhow::bail!(...)`
    kind: function_item
    not:
      has:
        field: body
        any:
          - not:
              matches: block-with-implicit-ok-return
          - has:
              stopBy:
                kind: function_item
              any:
                - kind: try_expression
                - pattern: "?"
                  inside:
                    kind: macro_invocation
                    stopBy: end
                - pattern: bail!($$$)
                - pattern: $$$::bail!($$$)
                - kind: return_expression
                  not:
                    has:
                      matches: ok-expression

rule:
  all:
    - pattern: $FUNC
    - kind: function_item
      has:
        field: return_type
        matches: result-return-type
      follows:
        pattern:
          context: |
            #[turbo_tasks::function]
          selector: attribute_item
        stopBy:
          not:
            kind: attribute_item
    - matches: infallible-fn

rewriters:  # this rewriter is far from perfect, and might rewrite too much
  - id: rewrite-return-type
    rule:
      matches: result-return-type
      inside:
        kind: function_item
        field: return_type
    fix: $INNER_RET_TY
  - id: unwrap-ok-values
    rule:
      all:
        - matches: ok-expression-capturing
        - any:
          - matches: last-expression-inside-block
          - inside:
              kind: return_expression
          - inside:
              kind: match_arm
    fix: $ARG

transform:
  NEW_FUNC:
    rewrite:
      rewriters:
        - rewrite-return-type
        - unwrap-ok-values
      source: $FUNC

fix: $NEW_FUNC

ignores:
  - "**/turbo-tasks-testing/**"
  - "**/turbo-tasks-memory/tests/**"
```

```
sg scan -U -r ../codemod_remove_unused_result_return_type.yml && cargo fix --lib --allow-dirty && cargo fmt
```

I used `cargo fix` in this case to auto-remove the now-unused
`anyhow::Result` imports.

I manually fixed clippy lints that now violated the `let_and_return`
lint rule (using a separate commit inside this PR), as `cargo clippy
--fix` seemed to hang when processing our `build.rs` files?
parent 3ead2d1f
...@@ -152,26 +152,26 @@ impl AppProject { ...@@ -152,26 +152,26 @@ impl AppProject {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn client_module_options_context(self: Vc<Self>) -> Result<Vc<ModuleOptionsContext>> { fn client_module_options_context(self: Vc<Self>) -> Vc<ModuleOptionsContext> {
Ok(get_client_module_options_context( get_client_module_options_context(
self.project().project_path(), self.project().project_path(),
self.project().execution_context(), self.project().execution_context(),
self.project().client_compile_time_info().environment(), self.project().client_compile_time_info().environment(),
Value::new(self.client_ty()), Value::new(self.client_ty()),
self.project().next_mode(), self.project().next_mode(),
self.project().next_config(), self.project().next_config(),
)) )
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn client_resolve_options_context(self: Vc<Self>) -> Result<Vc<ResolveOptionsContext>> { fn client_resolve_options_context(self: Vc<Self>) -> Vc<ResolveOptionsContext> {
Ok(get_client_resolve_options_context( get_client_resolve_options_context(
self.project().project_path(), self.project().project_path(),
Value::new(self.client_ty()), Value::new(self.client_ty()),
self.project().next_mode(), self.project().next_mode(),
self.project().next_config(), self.project().next_config(),
self.project().execution_context(), self.project().execution_context(),
)) )
} }
#[turbo_tasks::function] #[turbo_tasks::function]
...@@ -180,101 +180,101 @@ impl AppProject { ...@@ -180,101 +180,101 @@ impl AppProject {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn client_transition(self: Vc<Self>) -> Result<Vc<FullContextTransition>> { fn client_transition(self: Vc<Self>) -> Vc<FullContextTransition> {
let module_context = self.client_module_context(); let module_context = self.client_module_context();
Ok(FullContextTransition::new(module_context)) FullContextTransition::new(module_context)
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn rsc_module_options_context(self: Vc<Self>) -> Result<Vc<ModuleOptionsContext>> { fn rsc_module_options_context(self: Vc<Self>) -> Vc<ModuleOptionsContext> {
Ok(get_server_module_options_context( get_server_module_options_context(
self.project().project_path(), self.project().project_path(),
self.project().execution_context(), self.project().execution_context(),
Value::new(self.rsc_ty()), Value::new(self.rsc_ty()),
self.project().next_mode(), self.project().next_mode(),
self.project().next_config(), self.project().next_config(),
NextRuntime::NodeJs, NextRuntime::NodeJs,
)) )
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn edge_rsc_module_options_context(self: Vc<Self>) -> Result<Vc<ModuleOptionsContext>> { fn edge_rsc_module_options_context(self: Vc<Self>) -> Vc<ModuleOptionsContext> {
Ok(get_server_module_options_context( get_server_module_options_context(
self.project().project_path(), self.project().project_path(),
self.project().execution_context(), self.project().execution_context(),
Value::new(self.rsc_ty()), Value::new(self.rsc_ty()),
self.project().next_mode(), self.project().next_mode(),
self.project().next_config(), self.project().next_config(),
NextRuntime::Edge, NextRuntime::Edge,
)) )
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn route_module_options_context(self: Vc<Self>) -> Result<Vc<ModuleOptionsContext>> { fn route_module_options_context(self: Vc<Self>) -> Vc<ModuleOptionsContext> {
Ok(get_server_module_options_context( get_server_module_options_context(
self.project().project_path(), self.project().project_path(),
self.project().execution_context(), self.project().execution_context(),
Value::new(self.route_ty()), Value::new(self.route_ty()),
self.project().next_mode(), self.project().next_mode(),
self.project().next_config(), self.project().next_config(),
NextRuntime::NodeJs, NextRuntime::NodeJs,
)) )
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn edge_route_module_options_context(self: Vc<Self>) -> Result<Vc<ModuleOptionsContext>> { fn edge_route_module_options_context(self: Vc<Self>) -> Vc<ModuleOptionsContext> {
Ok(get_server_module_options_context( get_server_module_options_context(
self.project().project_path(), self.project().project_path(),
self.project().execution_context(), self.project().execution_context(),
Value::new(self.route_ty()), Value::new(self.route_ty()),
self.project().next_mode(), self.project().next_mode(),
self.project().next_config(), self.project().next_config(),
NextRuntime::Edge, NextRuntime::Edge,
)) )
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn rsc_resolve_options_context(self: Vc<Self>) -> Result<Vc<ResolveOptionsContext>> { fn rsc_resolve_options_context(self: Vc<Self>) -> Vc<ResolveOptionsContext> {
Ok(get_server_resolve_options_context( get_server_resolve_options_context(
self.project().project_path(), self.project().project_path(),
Value::new(self.rsc_ty()), Value::new(self.rsc_ty()),
self.project().next_mode(), self.project().next_mode(),
self.project().next_config(), self.project().next_config(),
self.project().execution_context(), self.project().execution_context(),
)) )
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn edge_rsc_resolve_options_context(self: Vc<Self>) -> Result<Vc<ResolveOptionsContext>> { fn edge_rsc_resolve_options_context(self: Vc<Self>) -> Vc<ResolveOptionsContext> {
Ok(get_edge_resolve_options_context( get_edge_resolve_options_context(
self.project().project_path(), self.project().project_path(),
Value::new(self.rsc_ty()), Value::new(self.rsc_ty()),
self.project().next_mode(), self.project().next_mode(),
self.project().next_config(), self.project().next_config(),
self.project().execution_context(), self.project().execution_context(),
)) )
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn route_resolve_options_context(self: Vc<Self>) -> Result<Vc<ResolveOptionsContext>> { fn route_resolve_options_context(self: Vc<Self>) -> Vc<ResolveOptionsContext> {
Ok(get_server_resolve_options_context( get_server_resolve_options_context(
self.project().project_path(), self.project().project_path(),
Value::new(self.route_ty()), Value::new(self.route_ty()),
self.project().next_mode(), self.project().next_mode(),
self.project().next_config(), self.project().next_config(),
self.project().execution_context(), self.project().execution_context(),
)) )
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn edge_route_resolve_options_context(self: Vc<Self>) -> Result<Vc<ResolveOptionsContext>> { fn edge_route_resolve_options_context(self: Vc<Self>) -> Vc<ResolveOptionsContext> {
Ok(get_edge_resolve_options_context( get_edge_resolve_options_context(
self.project().project_path(), self.project().project_path(),
Value::new(self.route_ty()), Value::new(self.route_ty()),
self.project().next_mode(), self.project().next_mode(),
self.project().next_config(), self.project().next_config(),
self.project().execution_context(), self.project().execution_context(),
)) )
} }
#[turbo_tasks::function] #[turbo_tasks::function]
...@@ -444,49 +444,49 @@ impl AppProject { ...@@ -444,49 +444,49 @@ impl AppProject {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn ssr_module_options_context(self: Vc<Self>) -> Result<Vc<ModuleOptionsContext>> { fn ssr_module_options_context(self: Vc<Self>) -> Vc<ModuleOptionsContext> {
Ok(get_server_module_options_context( get_server_module_options_context(
self.project().project_path(), self.project().project_path(),
self.project().execution_context(), self.project().execution_context(),
Value::new(self.ssr_ty()), Value::new(self.ssr_ty()),
self.project().next_mode(), self.project().next_mode(),
self.project().next_config(), self.project().next_config(),
NextRuntime::NodeJs, NextRuntime::NodeJs,
)) )
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn edge_ssr_module_options_context(self: Vc<Self>) -> Result<Vc<ModuleOptionsContext>> { fn edge_ssr_module_options_context(self: Vc<Self>) -> Vc<ModuleOptionsContext> {
Ok(get_server_module_options_context( get_server_module_options_context(
self.project().project_path(), self.project().project_path(),
self.project().execution_context(), self.project().execution_context(),
Value::new(self.ssr_ty()), Value::new(self.ssr_ty()),
self.project().next_mode(), self.project().next_mode(),
self.project().next_config(), self.project().next_config(),
NextRuntime::Edge, NextRuntime::Edge,
)) )
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn ssr_resolve_options_context(self: Vc<Self>) -> Result<Vc<ResolveOptionsContext>> { fn ssr_resolve_options_context(self: Vc<Self>) -> Vc<ResolveOptionsContext> {
Ok(get_server_resolve_options_context( get_server_resolve_options_context(
self.project().project_path(), self.project().project_path(),
Value::new(self.ssr_ty()), Value::new(self.ssr_ty()),
self.project().next_mode(), self.project().next_mode(),
self.project().next_config(), self.project().next_config(),
self.project().execution_context(), self.project().execution_context(),
)) )
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn edge_ssr_resolve_options_context(self: Vc<Self>) -> Result<Vc<ResolveOptionsContext>> { fn edge_ssr_resolve_options_context(self: Vc<Self>) -> Vc<ResolveOptionsContext> {
Ok(get_edge_resolve_options_context( get_edge_resolve_options_context(
self.project().project_path(), self.project().project_path(),
Value::new(self.ssr_ty()), Value::new(self.ssr_ty()),
self.project().next_mode(), self.project().next_mode(),
self.project().next_config(), self.project().next_config(),
self.project().execution_context(), self.project().execution_context(),
)) )
} }
#[turbo_tasks::function] #[turbo_tasks::function]
...@@ -530,11 +530,8 @@ impl AppProject { ...@@ -530,11 +530,8 @@ impl AppProject {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn runtime_entries(self: Vc<Self>) -> Result<Vc<RuntimeEntries>> { fn runtime_entries(self: Vc<Self>) -> Vc<RuntimeEntries> {
Ok(get_server_runtime_entries( get_server_runtime_entries(Value::new(self.rsc_ty()), self.project().next_mode())
Value::new(self.rsc_ty()),
self.project().next_mode(),
))
} }
#[turbo_tasks::function] #[turbo_tasks::function]
...@@ -558,15 +555,15 @@ impl AppProject { ...@@ -558,15 +555,15 @@ impl AppProject {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn client_runtime_entries(self: Vc<Self>) -> Result<Vc<EvaluatableAssets>> { fn client_runtime_entries(self: Vc<Self>) -> Vc<EvaluatableAssets> {
Ok(get_client_runtime_entries( get_client_runtime_entries(
self.project().project_path(), self.project().project_path(),
Value::new(self.client_ty()), Value::new(self.client_ty()),
self.project().next_mode(), self.project().next_mode(),
self.project().next_config(), self.project().next_config(),
self.project().execution_context(), self.project().execution_context(),
) )
.resolve_entries(Vc::upcast(self.client_module_context()))) .resolve_entries(Vc::upcast(self.client_module_context()))
} }
#[turbo_tasks::function] #[turbo_tasks::function]
......
...@@ -84,9 +84,7 @@ impl GlobalModuleIdStrategyBuilder { ...@@ -84,9 +84,7 @@ impl GlobalModuleIdStrategyBuilder {
// NOTE(LichuAcu) We can't move this function to `turbopack-core` because we need access to // NOTE(LichuAcu) We can't move this function to `turbopack-core` because we need access to
// `Endpoint`, which is not available there. // `Endpoint`, which is not available there.
#[turbo_tasks::function] #[turbo_tasks::function]
fn preprocess_module_ids( fn preprocess_module_ids(endpoint: Vc<Box<dyn Endpoint>>) -> Vc<PreprocessedChildrenIdents> {
endpoint: Vc<Box<dyn Endpoint>>,
) -> Result<Vc<PreprocessedChildrenIdents>> {
let root_modules = endpoint.root_modules(); let root_modules = endpoint.root_modules();
Ok(children_modules_idents(root_modules)) children_modules_idents(root_modules)
} }
...@@ -65,7 +65,7 @@ impl InstrumentationEndpoint { ...@@ -65,7 +65,7 @@ impl InstrumentationEndpoint {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn core_modules(&self) -> Result<Vc<InstrumentationCoreModules>> { fn core_modules(&self) -> Vc<InstrumentationCoreModules> {
let userland_module = self let userland_module = self
.asset_context .asset_context
.process( .process(
...@@ -81,11 +81,11 @@ impl InstrumentationEndpoint { ...@@ -81,11 +81,11 @@ impl InstrumentationEndpoint {
"instrumentation".into(), "instrumentation".into(),
); );
Ok(InstrumentationCoreModules { InstrumentationCoreModules {
userland_module, userland_module,
edge_entry_module, edge_entry_module,
} }
.cell()) .cell()
} }
#[turbo_tasks::function] #[turbo_tasks::function]
......
...@@ -255,14 +255,13 @@ impl MiddlewareEndpoint { ...@@ -255,14 +255,13 @@ impl MiddlewareEndpoint {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn userland_module(&self) -> Result<Vc<Box<dyn Module>>> { fn userland_module(&self) -> Vc<Box<dyn Module>> {
Ok(self self.asset_context
.asset_context
.process( .process(
self.source, self.source,
Value::new(ReferenceType::Entry(EntryReferenceSubType::Middleware)), Value::new(ReferenceType::Entry(EntryReferenceSubType::Middleware)),
) )
.module()) .module()
} }
} }
...@@ -311,7 +310,7 @@ impl Endpoint for MiddlewareEndpoint { ...@@ -311,7 +310,7 @@ impl Endpoint for MiddlewareEndpoint {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn root_modules(self: Vc<Self>) -> Result<Vc<Modules>> { fn root_modules(self: Vc<Self>) -> Vc<Modules> {
Ok(Vc::cell(vec![self.userland_module()])) Vc::cell(vec![self.userland_module()])
} }
} }
...@@ -81,8 +81,8 @@ pub struct PagesProject { ...@@ -81,8 +81,8 @@ pub struct PagesProject {
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl PagesProject { impl PagesProject {
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn new(project: Vc<Project>) -> Result<Vc<Self>> { pub fn new(project: Vc<Project>) -> Vc<Self> {
Ok(PagesProject { project }.cell()) PagesProject { project }.cell()
} }
#[turbo_tasks::function] #[turbo_tasks::function]
...@@ -279,8 +279,8 @@ impl PagesProject { ...@@ -279,8 +279,8 @@ impl PagesProject {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn client_module_options_context(self: Vc<Self>) -> Result<Vc<ModuleOptionsContext>> { fn client_module_options_context(self: Vc<Self>) -> Vc<ModuleOptionsContext> {
Ok(get_client_module_options_context( get_client_module_options_context(
self.project().project_path(), self.project().project_path(),
self.project().execution_context(), self.project().execution_context(),
self.project().client_compile_time_info().environment(), self.project().client_compile_time_info().environment(),
...@@ -289,12 +289,12 @@ impl PagesProject { ...@@ -289,12 +289,12 @@ impl PagesProject {
}), }),
self.project().next_mode(), self.project().next_mode(),
self.project().next_config(), self.project().next_config(),
)) )
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn client_resolve_options_context(self: Vc<Self>) -> Result<Vc<ResolveOptionsContext>> { fn client_resolve_options_context(self: Vc<Self>) -> Vc<ResolveOptionsContext> {
Ok(get_client_resolve_options_context( get_client_resolve_options_context(
self.project().project_path(), self.project().project_path(),
Value::new(ClientContextType::Pages { Value::new(ClientContextType::Pages {
pages_dir: self.pages_dir(), pages_dir: self.pages_dir(),
...@@ -302,7 +302,7 @@ impl PagesProject { ...@@ -302,7 +302,7 @@ impl PagesProject {
self.project().next_mode(), self.project().next_mode(),
self.project().next_config(), self.project().next_config(),
self.project().execution_context(), self.project().execution_context(),
)) )
} }
#[turbo_tasks::function] #[turbo_tasks::function]
...@@ -385,8 +385,8 @@ impl PagesProject { ...@@ -385,8 +385,8 @@ impl PagesProject {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn ssr_module_options_context(self: Vc<Self>) -> Result<Vc<ModuleOptionsContext>> { fn ssr_module_options_context(self: Vc<Self>) -> Vc<ModuleOptionsContext> {
Ok(get_server_module_options_context( get_server_module_options_context(
self.project().project_path(), self.project().project_path(),
self.project().execution_context(), self.project().execution_context(),
Value::new(ServerContextType::Pages { Value::new(ServerContextType::Pages {
...@@ -395,12 +395,12 @@ impl PagesProject { ...@@ -395,12 +395,12 @@ impl PagesProject {
self.project().next_mode(), self.project().next_mode(),
self.project().next_config(), self.project().next_config(),
NextRuntime::NodeJs, NextRuntime::NodeJs,
)) )
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn edge_ssr_module_options_context(self: Vc<Self>) -> Result<Vc<ModuleOptionsContext>> { fn edge_ssr_module_options_context(self: Vc<Self>) -> Vc<ModuleOptionsContext> {
Ok(get_server_module_options_context( get_server_module_options_context(
self.project().project_path(), self.project().project_path(),
self.project().execution_context(), self.project().execution_context(),
Value::new(ServerContextType::Pages { Value::new(ServerContextType::Pages {
...@@ -409,12 +409,12 @@ impl PagesProject { ...@@ -409,12 +409,12 @@ impl PagesProject {
self.project().next_mode(), self.project().next_mode(),
self.project().next_config(), self.project().next_config(),
NextRuntime::Edge, NextRuntime::Edge,
)) )
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn api_module_options_context(self: Vc<Self>) -> Result<Vc<ModuleOptionsContext>> { fn api_module_options_context(self: Vc<Self>) -> Vc<ModuleOptionsContext> {
Ok(get_server_module_options_context( get_server_module_options_context(
self.project().project_path(), self.project().project_path(),
self.project().execution_context(), self.project().execution_context(),
Value::new(ServerContextType::PagesApi { Value::new(ServerContextType::PagesApi {
...@@ -423,12 +423,12 @@ impl PagesProject { ...@@ -423,12 +423,12 @@ impl PagesProject {
self.project().next_mode(), self.project().next_mode(),
self.project().next_config(), self.project().next_config(),
NextRuntime::NodeJs, NextRuntime::NodeJs,
)) )
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn edge_api_module_options_context(self: Vc<Self>) -> Result<Vc<ModuleOptionsContext>> { fn edge_api_module_options_context(self: Vc<Self>) -> Vc<ModuleOptionsContext> {
Ok(get_server_module_options_context( get_server_module_options_context(
self.project().project_path(), self.project().project_path(),
self.project().execution_context(), self.project().execution_context(),
Value::new(ServerContextType::PagesApi { Value::new(ServerContextType::PagesApi {
...@@ -437,12 +437,12 @@ impl PagesProject { ...@@ -437,12 +437,12 @@ impl PagesProject {
self.project().next_mode(), self.project().next_mode(),
self.project().next_config(), self.project().next_config(),
NextRuntime::Edge, NextRuntime::Edge,
)) )
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn ssr_data_module_options_context(self: Vc<Self>) -> Result<Vc<ModuleOptionsContext>> { fn ssr_data_module_options_context(self: Vc<Self>) -> Vc<ModuleOptionsContext> {
Ok(get_server_module_options_context( get_server_module_options_context(
self.project().project_path(), self.project().project_path(),
self.project().execution_context(), self.project().execution_context(),
Value::new(ServerContextType::PagesData { Value::new(ServerContextType::PagesData {
...@@ -451,12 +451,12 @@ impl PagesProject { ...@@ -451,12 +451,12 @@ impl PagesProject {
self.project().next_mode(), self.project().next_mode(),
self.project().next_config(), self.project().next_config(),
NextRuntime::NodeJs, NextRuntime::NodeJs,
)) )
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn edge_ssr_data_module_options_context(self: Vc<Self>) -> Result<Vc<ModuleOptionsContext>> { fn edge_ssr_data_module_options_context(self: Vc<Self>) -> Vc<ModuleOptionsContext> {
Ok(get_server_module_options_context( get_server_module_options_context(
self.project().project_path(), self.project().project_path(),
self.project().execution_context(), self.project().execution_context(),
Value::new(ServerContextType::PagesData { Value::new(ServerContextType::PagesData {
...@@ -465,12 +465,12 @@ impl PagesProject { ...@@ -465,12 +465,12 @@ impl PagesProject {
self.project().next_mode(), self.project().next_mode(),
self.project().next_config(), self.project().next_config(),
NextRuntime::Edge, NextRuntime::Edge,
)) )
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn ssr_resolve_options_context(self: Vc<Self>) -> Result<Vc<ResolveOptionsContext>> { fn ssr_resolve_options_context(self: Vc<Self>) -> Vc<ResolveOptionsContext> {
Ok(get_server_resolve_options_context( get_server_resolve_options_context(
self.project().project_path(), self.project().project_path(),
// NOTE(alexkirsz) This could be `PagesData` for the data endpoint, but it doesn't // NOTE(alexkirsz) This could be `PagesData` for the data endpoint, but it doesn't
// matter (for now at least) because `get_server_resolve_options_context` doesn't // matter (for now at least) because `get_server_resolve_options_context` doesn't
...@@ -481,12 +481,12 @@ impl PagesProject { ...@@ -481,12 +481,12 @@ impl PagesProject {
self.project().next_mode(), self.project().next_mode(),
self.project().next_config(), self.project().next_config(),
self.project().execution_context(), self.project().execution_context(),
)) )
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn edge_ssr_resolve_options_context(self: Vc<Self>) -> Result<Vc<ResolveOptionsContext>> { fn edge_ssr_resolve_options_context(self: Vc<Self>) -> Vc<ResolveOptionsContext> {
Ok(get_edge_resolve_options_context( get_edge_resolve_options_context(
self.project().project_path(), self.project().project_path(),
// NOTE(alexkirsz) This could be `PagesData` for the data endpoint, but it doesn't // NOTE(alexkirsz) This could be `PagesData` for the data endpoint, but it doesn't
// matter (for now at least) because `get_server_resolve_options_context` doesn't // matter (for now at least) because `get_server_resolve_options_context` doesn't
...@@ -497,11 +497,11 @@ impl PagesProject { ...@@ -497,11 +497,11 @@ impl PagesProject {
self.project().next_mode(), self.project().next_mode(),
self.project().next_config(), self.project().next_config(),
self.project().execution_context(), self.project().execution_context(),
)) )
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn client_runtime_entries(self: Vc<Self>) -> Result<Vc<EvaluatableAssets>> { fn client_runtime_entries(self: Vc<Self>) -> Vc<EvaluatableAssets> {
let client_runtime_entries = get_client_runtime_entries( let client_runtime_entries = get_client_runtime_entries(
self.project().project_path(), self.project().project_path(),
Value::new(ClientContextType::Pages { Value::new(ClientContextType::Pages {
...@@ -511,27 +511,27 @@ impl PagesProject { ...@@ -511,27 +511,27 @@ impl PagesProject {
self.project().next_config(), self.project().next_config(),
self.project().execution_context(), self.project().execution_context(),
); );
Ok(client_runtime_entries.resolve_entries(self.client_module_context())) client_runtime_entries.resolve_entries(self.client_module_context())
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn runtime_entries(self: Vc<Self>) -> Result<Vc<RuntimeEntries>> { fn runtime_entries(self: Vc<Self>) -> Vc<RuntimeEntries> {
Ok(get_server_runtime_entries( get_server_runtime_entries(
Value::new(ServerContextType::Pages { Value::new(ServerContextType::Pages {
pages_dir: self.pages_dir(), pages_dir: self.pages_dir(),
}), }),
self.project().next_mode(), self.project().next_mode(),
)) )
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn data_runtime_entries(self: Vc<Self>) -> Result<Vc<RuntimeEntries>> { fn data_runtime_entries(self: Vc<Self>) -> Vc<RuntimeEntries> {
Ok(get_server_runtime_entries( get_server_runtime_entries(
Value::new(ServerContextType::PagesData { Value::new(ServerContextType::PagesData {
pages_dir: self.pages_dir(), pages_dir: self.pages_dir(),
}), }),
self.project().next_mode(), self.project().next_mode(),
)) )
} }
#[turbo_tasks::function] #[turbo_tasks::function]
...@@ -638,8 +638,8 @@ impl PageEndpoint { ...@@ -638,8 +638,8 @@ impl PageEndpoint {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn source(&self) -> Result<Vc<Box<dyn Source>>> { fn source(&self) -> Vc<Box<dyn Source>> {
Ok(Vc::upcast(FileSource::new(self.page.project_path()))) Vc::upcast(FileSource::new(self.page.project_path()))
} }
#[turbo_tasks::function] #[turbo_tasks::function]
......
...@@ -386,12 +386,12 @@ impl ProjectContainer { ...@@ -386,12 +386,12 @@ impl ProjectContainer {
&self, &self,
file_path: Vc<FileSystemPath>, file_path: Vc<FileSystemPath>,
section: Option<RcStr>, section: Option<RcStr>,
) -> Result<Vc<OptionSourceMap>> { ) -> Vc<OptionSourceMap> {
Ok(if let Some(map) = self.versioned_content_map { if let Some(map) = self.versioned_content_map {
map.get_source_map(file_path, section) map.get_source_map(file_path, section)
} else { } else {
OptionSourceMap::none() OptionSourceMap::none()
}) }
} }
} }
...@@ -510,8 +510,8 @@ impl Project { ...@@ -510,8 +510,8 @@ impl Project {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn pages_project(self: Vc<Self>) -> Result<Vc<PagesProject>> { pub fn pages_project(self: Vc<Self>) -> Vc<PagesProject> {
Ok(PagesProject::new(self)) PagesProject::new(self)
} }
#[turbo_tasks::function] #[turbo_tasks::function]
...@@ -528,20 +528,19 @@ impl Project { ...@@ -528,20 +528,19 @@ impl Project {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn client_fs(self: Vc<Self>) -> Result<Vc<Box<dyn FileSystem>>> { fn client_fs(self: Vc<Self>) -> Vc<Box<dyn FileSystem>> {
let virtual_fs = VirtualFileSystem::new(); let virtual_fs = VirtualFileSystem::new();
Ok(Vc::upcast(virtual_fs)) Vc::upcast(virtual_fs)
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn output_fs(&self) -> Result<Vc<DiskFileSystem>> { pub fn output_fs(&self) -> Vc<DiskFileSystem> {
let disk_fs = DiskFileSystem::new("output".into(), self.project_path.clone(), vec![]); DiskFileSystem::new("output".into(), self.project_path.clone(), vec![])
Ok(disk_fs)
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn dist_dir(&self) -> Result<Vc<RcStr>> { pub fn dist_dir(&self) -> Vc<RcStr> {
Ok(Vc::cell(self.dist_dir.clone())) Vc::cell(self.dist_dir.clone())
} }
#[turbo_tasks::function] #[turbo_tasks::function]
...@@ -585,23 +584,23 @@ impl Project { ...@@ -585,23 +584,23 @@ impl Project {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub(super) fn env(&self) -> Result<Vc<Box<dyn ProcessEnv>>> { pub(super) fn env(&self) -> Vc<Box<dyn ProcessEnv>> {
Ok(self.env) self.env
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub(super) fn next_config(&self) -> Result<Vc<NextConfig>> { pub(super) fn next_config(&self) -> Vc<NextConfig> {
Ok(self.next_config) self.next_config
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub(super) fn next_mode(&self) -> Result<Vc<NextMode>> { pub(super) fn next_mode(&self) -> Vc<NextMode> {
Ok(self.mode) self.mode
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub(super) fn js_config(&self) -> Result<Vc<JsConfig>> { pub(super) fn js_config(&self) -> Vc<JsConfig> {
Ok(self.js_config) self.js_config
} }
#[turbo_tasks::function] #[turbo_tasks::function]
...@@ -630,11 +629,8 @@ impl Project { ...@@ -630,11 +629,8 @@ impl Project {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub(super) fn client_compile_time_info(&self) -> Result<Vc<CompileTimeInfo>> { pub(super) fn client_compile_time_info(&self) -> Vc<CompileTimeInfo> {
Ok(get_client_compile_time_info( get_client_compile_time_info(self.browserslist_query.clone(), self.define_env.client())
self.browserslist_query.clone(),
self.define_env.client(),
))
} }
#[turbo_tasks::function] #[turbo_tasks::function]
...@@ -668,15 +664,15 @@ impl Project { ...@@ -668,15 +664,15 @@ impl Project {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub(super) fn client_chunking_context(self: Vc<Self>) -> Result<Vc<Box<dyn ChunkingContext>>> { pub(super) fn client_chunking_context(self: Vc<Self>) -> Vc<Box<dyn ChunkingContext>> {
Ok(get_client_chunking_context( get_client_chunking_context(
self.project_path(), self.project_path(),
self.client_relative_path(), self.client_relative_path(),
self.next_config().computed_asset_prefix(), self.next_config().computed_asset_prefix(),
self.client_compile_time_info().environment(), self.client_compile_time_info().environment(),
self.next_mode(), self.next_mode(),
self.module_id_strategy(), self.module_id_strategy(),
)) )
} }
#[turbo_tasks::function] #[turbo_tasks::function]
...@@ -1322,6 +1318,6 @@ fn all_assets_from_entries_operation( ...@@ -1322,6 +1318,6 @@ fn all_assets_from_entries_operation(
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn stable_endpoint(endpoint: Vc<Box<dyn Endpoint>>) -> Result<Vc<Box<dyn Endpoint>>> { fn stable_endpoint(endpoint: Vc<Box<dyn Endpoint>>) -> Vc<Box<dyn Endpoint>> {
Ok(endpoint) endpoint
} }
...@@ -230,13 +230,13 @@ impl VersionedContentMap { ...@@ -230,13 +230,13 @@ impl VersionedContentMap {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn raw_get(&self, path: Vc<FileSystemPath>) -> Result<Vc<OptionMapEntry>> { fn raw_get(&self, path: Vc<FileSystemPath>) -> Vc<OptionMapEntry> {
let assets = { let assets = {
let map = self.map_path_to_op.get(); let map = self.map_path_to_op.get();
map.get(&path).and_then(|m| m.iter().last().copied()) map.get(&path).and_then(|m| m.iter().last().copied())
}; };
let Some(assets) = assets else { let Some(assets) = assets else {
return Ok(Vc::cell(None)); return Vc::cell(None);
}; };
// Need to reconnect the operation to the map // Need to reconnect the operation to the map
Vc::connect(assets); Vc::connect(assets);
...@@ -246,11 +246,11 @@ impl VersionedContentMap { ...@@ -246,11 +246,11 @@ impl VersionedContentMap {
map.get(&assets).copied() map.get(&assets).copied()
}; };
let Some(compute_entry) = compute_entry else { let Some(compute_entry) = compute_entry else {
return Ok(Vc::cell(None)); return Vc::cell(None);
}; };
// Need to reconnect the operation to the map // Need to reconnect the operation to the map
Vc::connect(compute_entry); Vc::connect(compute_entry);
Ok(compute_entry) compute_entry
} }
} }
...@@ -732,8 +732,8 @@ struct DuplicateParallelRouteIssue { ...@@ -732,8 +732,8 @@ struct DuplicateParallelRouteIssue {
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl Issue for DuplicateParallelRouteIssue { impl Issue for DuplicateParallelRouteIssue {
#[turbo_tasks::function] #[turbo_tasks::function]
fn file_path(&self) -> Result<Vc<FileSystemPath>> { fn file_path(&self) -> Vc<FileSystemPath> {
Ok(self.app_dir.join(self.page.to_string().into())) self.app_dir.join(self.page.to_string().into())
} }
#[turbo_tasks::function] #[turbo_tasks::function]
...@@ -1355,8 +1355,8 @@ impl Issue for DirectoryTreeIssue { ...@@ -1355,8 +1355,8 @@ impl Issue for DirectoryTreeIssue {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn title(&self) -> Result<Vc<StyledString>> { fn title(&self) -> Vc<StyledString> {
Ok(StyledString::Text("An issue occurred while preparing your Next.js app".into()).cell()) StyledString::Text("An issue occurred while preparing your Next.js app".into()).cell()
} }
#[turbo_tasks::function] #[turbo_tasks::function]
......
...@@ -20,15 +20,15 @@ pub fn route_bootstrap( ...@@ -20,15 +20,15 @@ pub fn route_bootstrap(
base_path: Vc<FileSystemPath>, base_path: Vc<FileSystemPath>,
bootstrap_asset: Vc<Box<dyn Source>>, bootstrap_asset: Vc<Box<dyn Source>>,
config: Vc<BootstrapConfig>, config: Vc<BootstrapConfig>,
) -> Result<Vc<Box<dyn EvaluatableAsset>>> { ) -> Vc<Box<dyn EvaluatableAsset>> {
Ok(bootstrap( bootstrap(
asset, asset,
asset_context, asset_context,
base_path, base_path,
bootstrap_asset, bootstrap_asset,
Vc::cell(IndexMap::new()), Vc::cell(IndexMap::new()),
config, config,
)) )
} }
#[turbo_tasks::value(transparent)] #[turbo_tasks::value(transparent)]
......
...@@ -121,8 +121,8 @@ impl ValueToString for HmrEntryModuleReference { ...@@ -121,8 +121,8 @@ impl ValueToString for HmrEntryModuleReference {
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl ModuleReference for HmrEntryModuleReference { impl ModuleReference for HmrEntryModuleReference {
#[turbo_tasks::function] #[turbo_tasks::function]
fn resolve_reference(&self) -> Result<Vc<ModuleResolveResult>> { fn resolve_reference(&self) -> Vc<ModuleResolveResult> {
Ok(ModuleResolveResult::module(self.module).cell()) ModuleResolveResult::module(self.module).cell()
} }
} }
......
...@@ -78,14 +78,14 @@ impl ChunkableModule for IncludeModulesModule { ...@@ -78,14 +78,14 @@ impl ChunkableModule for IncludeModulesModule {
fn as_chunk_item( fn as_chunk_item(
self: Vc<Self>, self: Vc<Self>,
chunking_context: Vc<Box<dyn ChunkingContext>>, chunking_context: Vc<Box<dyn ChunkingContext>>,
) -> Result<Vc<Box<dyn ChunkItem>>> { ) -> Vc<Box<dyn ChunkItem>> {
Ok(Vc::upcast( Vc::upcast(
IncludeModulesChunkItem { IncludeModulesChunkItem {
module: self, module: self,
chunking_context, chunking_context,
} }
.cell(), .cell(),
)) )
} }
} }
...@@ -165,8 +165,8 @@ impl ValueToString for IncludedModuleReference { ...@@ -165,8 +165,8 @@ impl ValueToString for IncludedModuleReference {
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl ModuleReference for IncludedModuleReference { impl ModuleReference for IncludedModuleReference {
#[turbo_tasks::function] #[turbo_tasks::function]
fn resolve_reference(&self) -> Result<Vc<ModuleResolveResult>> { fn resolve_reference(&self) -> Vc<ModuleResolveResult> {
Ok(ModuleResolveResult::module(self.module).cell()) ModuleResolveResult::module(self.module).cell()
} }
} }
......
...@@ -6,16 +6,14 @@ use turbopack_core::resolve::{options::ImportMapping, ExternalType}; ...@@ -6,16 +6,14 @@ use turbopack_core::resolve::{options::ImportMapping, ExternalType};
use crate::next_import_map::get_next_package; use crate::next_import_map::get_next_package;
#[turbo_tasks::function] #[turbo_tasks::function]
pub async fn get_postcss_package_mapping( pub async fn get_postcss_package_mapping(project_path: Vc<FileSystemPath>) -> Vc<ImportMapping> {
project_path: Vc<FileSystemPath>, ImportMapping::Alternatives(vec![
) -> Result<Vc<ImportMapping>> {
Ok(ImportMapping::Alternatives(vec![
// Prefer the local installed version over the next.js version // Prefer the local installed version over the next.js version
ImportMapping::PrimaryAlternative("postcss".into(), Some(project_path)).cell(), ImportMapping::PrimaryAlternative("postcss".into(), Some(project_path)).cell(),
ImportMapping::PrimaryAlternative("postcss".into(), Some(get_next_package(project_path))) ImportMapping::PrimaryAlternative("postcss".into(), Some(get_next_package(project_path)))
.cell(), .cell(),
]) ])
.cell()) .cell()
} }
#[turbo_tasks::function] #[turbo_tasks::function]
......
...@@ -57,10 +57,10 @@ impl Module for EcmascriptClientReferenceModule { ...@@ -57,10 +57,10 @@ impl Module for EcmascriptClientReferenceModule {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn additional_layers_modules(&self) -> Result<Vc<Modules>> { fn additional_layers_modules(&self) -> Vc<Modules> {
let client_module = Vc::upcast(self.client_module); let client_module = Vc::upcast(self.client_module);
let ssr_module = Vc::upcast(self.ssr_module); let ssr_module = Vc::upcast(self.ssr_module);
Ok(Vc::cell(vec![client_module, ssr_module])) Vc::cell(vec![client_module, ssr_module])
} }
} }
......
...@@ -792,17 +792,17 @@ impl NextConfig { ...@@ -792,17 +792,17 @@ impl NextConfig {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn server_external_packages(&self) -> Result<Vc<Vec<RcStr>>> { pub fn server_external_packages(&self) -> Vc<Vec<RcStr>> {
Ok(Vc::cell( Vc::cell(
self.server_external_packages self.server_external_packages
.as_ref() .as_ref()
.cloned() .cloned()
.unwrap_or_default(), .unwrap_or_default(),
)) )
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn env(&self) -> Result<Vc<EnvMap>> { pub fn env(&self) -> Vc<EnvMap> {
// The value expected for env is Record<String, String>, but config itself // The value expected for env is Record<String, String>, but config itself
// allows arbitrary object (https://github.com/vercel/next.js/blob/25ba8a74b7544dfb6b30d1b67c47b9cb5360cb4e/packages/next/src/server/config-schema.ts#L203) // allows arbitrary object (https://github.com/vercel/next.js/blob/25ba8a74b7544dfb6b30d1b67c47b9cb5360cb4e/packages/next/src/server/config-schema.ts#L203)
// then stringifies it. We do the interop here as well. // then stringifies it. We do the interop here as well.
...@@ -822,38 +822,36 @@ impl NextConfig { ...@@ -822,38 +822,36 @@ impl NextConfig {
}) })
.collect(); .collect();
Ok(Vc::cell(env)) Vc::cell(env)
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn image_config(&self) -> Result<Vc<ImageConfig>> { pub fn image_config(&self) -> Vc<ImageConfig> {
Ok(self.images.clone().cell()) self.images.clone().cell()
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn page_extensions(&self) -> Result<Vc<Vec<RcStr>>> { pub fn page_extensions(&self) -> Vc<Vec<RcStr>> {
Ok(Vc::cell(self.page_extensions.clone())) Vc::cell(self.page_extensions.clone())
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn transpile_packages(&self) -> Result<Vc<Vec<RcStr>>> { pub fn transpile_packages(&self) -> Vc<Vec<RcStr>> {
Ok(Vc::cell( Vc::cell(self.transpile_packages.clone().unwrap_or_default())
self.transpile_packages.clone().unwrap_or_default(),
))
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn webpack_rules(&self, active_conditions: Vec<RcStr>) -> Result<Vc<OptionWebpackRules>> { pub fn webpack_rules(&self, active_conditions: Vec<RcStr>) -> Vc<OptionWebpackRules> {
let Some(turbo_rules) = self let Some(turbo_rules) = self
.experimental .experimental
.turbo .turbo
.as_ref() .as_ref()
.and_then(|t| t.rules.as_ref()) .and_then(|t| t.rules.as_ref())
else { else {
return Ok(Vc::cell(None)); return Vc::cell(None);
}; };
if turbo_rules.is_empty() { if turbo_rules.is_empty() {
return Ok(Vc::cell(None)); return Vc::cell(None);
} }
let active_conditions = active_conditions.into_iter().collect::<HashSet<_>>(); let active_conditions = active_conditions.into_iter().collect::<HashSet<_>>();
let mut rules = IndexMap::new(); let mut rules = IndexMap::new();
...@@ -927,7 +925,7 @@ impl NextConfig { ...@@ -927,7 +925,7 @@ impl NextConfig {
} }
} }
} }
Ok(Vc::cell(Some(Vc::cell(rules)))) Vc::cell(Some(Vc::cell(rules)))
} }
#[turbo_tasks::function] #[turbo_tasks::function]
...@@ -945,16 +943,16 @@ impl NextConfig { ...@@ -945,16 +943,16 @@ impl NextConfig {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn resolve_extension(&self) -> Result<Vc<ResolveExtensions>> { pub fn resolve_extension(&self) -> Vc<ResolveExtensions> {
let Some(resolve_extensions) = self let Some(resolve_extensions) = self
.experimental .experimental
.turbo .turbo
.as_ref() .as_ref()
.and_then(|t| t.resolve_extensions.as_ref()) .and_then(|t| t.resolve_extensions.as_ref())
else { else {
return Ok(Vc::cell(None)); return Vc::cell(None);
}; };
Ok(Vc::cell(Some(resolve_extensions.clone()))) Vc::cell(Some(resolve_extensions.clone()))
} }
#[turbo_tasks::function] #[turbo_tasks::function]
...@@ -967,7 +965,7 @@ impl NextConfig { ...@@ -967,7 +965,7 @@ impl NextConfig {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn mdx_rs(&self) -> Result<Vc<OptionalMdxTransformOptions>> { pub fn mdx_rs(&self) -> Vc<OptionalMdxTransformOptions> {
let options = &self.experimental.mdx_rs; let options = &self.experimental.mdx_rs;
let options = match options { let options = match options {
...@@ -993,11 +991,11 @@ impl NextConfig { ...@@ -993,11 +991,11 @@ impl NextConfig {
_ => OptionalMdxTransformOptions(None), _ => OptionalMdxTransformOptions(None),
}; };
Ok(options.cell()) options.cell()
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn react_compiler(&self) -> Result<Vc<OptionalReactCompilerOptions>> { pub fn react_compiler(&self) -> Vc<OptionalReactCompilerOptions> {
let options = &self.experimental.react_compiler; let options = &self.experimental.react_compiler;
let options = match options { let options = match options {
...@@ -1016,24 +1014,22 @@ impl NextConfig { ...@@ -1016,24 +1014,22 @@ impl NextConfig {
_ => OptionalReactCompilerOptions(None), _ => OptionalReactCompilerOptions(None),
}; };
Ok(options.cell()) options.cell()
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn sass_config(&self) -> Result<Vc<JsonValue>> { pub fn sass_config(&self) -> Vc<JsonValue> {
Ok(Vc::cell(self.sass_options.clone().unwrap_or_default())) Vc::cell(self.sass_options.clone().unwrap_or_default())
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn skip_middleware_url_normalize(&self) -> Result<Vc<bool>> { pub fn skip_middleware_url_normalize(&self) -> Vc<bool> {
Ok(Vc::cell( Vc::cell(self.skip_middleware_url_normalize.unwrap_or(false))
self.skip_middleware_url_normalize.unwrap_or(false),
))
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn skip_trailing_slash_redirect(&self) -> Result<Vc<bool>> { pub fn skip_trailing_slash_redirect(&self) -> Vc<bool> {
Ok(Vc::cell(self.skip_trailing_slash_redirect.unwrap_or(false))) Vc::cell(self.skip_trailing_slash_redirect.unwrap_or(false))
} }
/// Returns the final asset prefix. If an assetPrefix is set, it's used. /// Returns the final asset prefix. If an assetPrefix is set, it's used.
...@@ -1057,8 +1053,8 @@ impl NextConfig { ...@@ -1057,8 +1053,8 @@ impl NextConfig {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn enable_ppr(&self) -> Result<Vc<bool>> { pub fn enable_ppr(&self) -> Vc<bool> {
Ok(Vc::cell( Vc::cell(
self.experimental self.experimental
.ppr .ppr
.as_ref() .as_ref()
...@@ -1069,52 +1065,52 @@ impl NextConfig { ...@@ -1069,52 +1065,52 @@ impl NextConfig {
ExperimentalPartialPrerendering::Boolean(b) => *b, ExperimentalPartialPrerendering::Boolean(b) => *b,
}) })
.unwrap_or(false), .unwrap_or(false),
)) )
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn enable_taint(&self) -> Result<Vc<bool>> { pub fn enable_taint(&self) -> Vc<bool> {
Ok(Vc::cell(self.experimental.taint.unwrap_or(false))) Vc::cell(self.experimental.taint.unwrap_or(false))
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn enable_dynamic_io(&self) -> Result<Vc<bool>> { pub fn enable_dynamic_io(&self) -> Vc<bool> {
Ok(Vc::cell(self.experimental.dynamic_io.unwrap_or(false))) Vc::cell(self.experimental.dynamic_io.unwrap_or(false))
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn use_swc_css(&self) -> Result<Vc<bool>> { pub fn use_swc_css(&self) -> Vc<bool> {
Ok(Vc::cell( Vc::cell(
self.experimental self.experimental
.turbo .turbo
.as_ref() .as_ref()
.and_then(|turbo| turbo.use_swc_css) .and_then(|turbo| turbo.use_swc_css)
.unwrap_or(false), .unwrap_or(false),
)) )
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn optimize_package_imports(&self) -> Result<Vc<Vec<RcStr>>> { pub fn optimize_package_imports(&self) -> Vc<Vec<RcStr>> {
Ok(Vc::cell( Vc::cell(
self.experimental self.experimental
.optimize_package_imports .optimize_package_imports
.clone() .clone()
.unwrap_or_default(), .unwrap_or_default(),
)) )
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn tree_shaking_mode_for_foreign_code( pub fn tree_shaking_mode_for_foreign_code(
&self, &self,
is_development: bool, is_development: bool,
) -> Result<Vc<OptionTreeShaking>> { ) -> Vc<OptionTreeShaking> {
let tree_shaking = self let tree_shaking = self
.experimental .experimental
.turbo .turbo
.as_ref() .as_ref()
.and_then(|v| v.tree_shaking); .and_then(|v| v.tree_shaking);
Ok(OptionTreeShaking(match tree_shaking { OptionTreeShaking(match tree_shaking {
Some(false) => Some(TreeShakingMode::ReexportsOnly), Some(false) => Some(TreeShakingMode::ReexportsOnly),
Some(true) => Some(TreeShakingMode::ModuleFragments), Some(true) => Some(TreeShakingMode::ModuleFragments),
None => { None => {
...@@ -1125,32 +1121,32 @@ impl NextConfig { ...@@ -1125,32 +1121,32 @@ impl NextConfig {
} }
} }
}) })
.cell()) .cell()
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn tree_shaking_mode_for_user_code( pub fn tree_shaking_mode_for_user_code(
self: Vc<Self>, self: Vc<Self>,
is_development: bool, is_development: bool,
) -> Result<Vc<OptionTreeShaking>> { ) -> Vc<OptionTreeShaking> {
Ok(Vc::cell(Some(if is_development { Vc::cell(Some(if is_development {
TreeShakingMode::ReexportsOnly TreeShakingMode::ReexportsOnly
} else { } else {
TreeShakingMode::ModuleFragments TreeShakingMode::ModuleFragments
}))) }))
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn module_id_strategy_config(&self) -> Result<Vc<OptionModuleIdStrategy>> { pub fn module_id_strategy_config(&self) -> Vc<OptionModuleIdStrategy> {
let Some(module_id_strategy) = self let Some(module_id_strategy) = self
.experimental .experimental
.turbo .turbo
.as_ref() .as_ref()
.and_then(|t| t.module_id_strategy.as_ref()) .and_then(|t| t.module_id_strategy.as_ref())
else { else {
return Ok(Vc::cell(None)); return Vc::cell(None);
}; };
Ok(Vc::cell(Some(module_id_strategy.clone()))) Vc::cell(Some(module_id_strategy.clone()))
} }
} }
...@@ -1175,8 +1171,8 @@ impl JsConfig { ...@@ -1175,8 +1171,8 @@ impl JsConfig {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn compiler_options(&self) -> Result<Vc<serde_json::Value>> { pub fn compiler_options(&self) -> Vc<serde_json::Value> {
Ok(Vc::cell(self.compiler_options.clone().unwrap_or_default())) Vc::cell(self.compiler_options.clone().unwrap_or_default())
} }
} }
......
use anyhow::Result;
use indexmap::indexmap; use indexmap::indexmap;
use indoc::formatdoc; use indoc::formatdoc;
use turbo_tasks::{RcStr, Value, Vc}; use turbo_tasks::{RcStr, Value, Vc};
...@@ -15,7 +14,7 @@ pub async fn wrap_edge_entry( ...@@ -15,7 +14,7 @@ pub async fn wrap_edge_entry(
project_root: Vc<FileSystemPath>, project_root: Vc<FileSystemPath>,
entry: Vc<Box<dyn Module>>, entry: Vc<Box<dyn Module>>,
pathname: RcStr, pathname: RcStr,
) -> Result<Vc<Box<dyn Module>>> { ) -> Vc<Box<dyn Module>> {
// The wrapped module could be an async module, we handle that with the proxy // The wrapped module could be an async module, we handle that with the proxy
// here. The comma expression makes sure we don't call the function with the // here. The comma expression makes sure we don't call the function with the
// module as the "this" arg. // module as the "this" arg.
...@@ -38,11 +37,10 @@ pub async fn wrap_edge_entry( ...@@ -38,11 +37,10 @@ pub async fn wrap_edge_entry(
"MODULE".into() => entry "MODULE".into() => entry
}; };
let module = asset_context asset_context
.process( .process(
Vc::upcast(virtual_source), Vc::upcast(virtual_source),
Value::new(ReferenceType::Internal(Vc::cell(inner_assets))), Value::new(ReferenceType::Internal(Vc::cell(inner_assets))),
) )
.module(); .module()
Ok(module)
} }
...@@ -35,8 +35,8 @@ impl NextFontGoogleOptions { ...@@ -35,8 +35,8 @@ impl NextFontGoogleOptions {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn font_family(&self) -> Result<Vc<RcStr>> { pub fn font_family(&self) -> Vc<RcStr> {
Ok(Vc::cell((*self.font_family).into())) Vc::cell((*self.font_family).into())
} }
} }
......
...@@ -321,8 +321,8 @@ impl Issue for FontResolvingIssue { ...@@ -321,8 +321,8 @@ impl Issue for FontResolvingIssue {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn file_path(&self) -> Result<Vc<FileSystemPath>> { fn file_path(&self) -> Vc<FileSystemPath> {
Ok(self.origin_path) self.origin_path
} }
#[turbo_tasks::function] #[turbo_tasks::function]
......
...@@ -41,8 +41,8 @@ impl NextFontLocalOptions { ...@@ -41,8 +41,8 @@ impl NextFontLocalOptions {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn font_family(&self) -> Result<Vc<RcStr>> { pub fn font_family(&self) -> Vc<RcStr> {
Ok(Vc::cell(self.variable_name.clone())) Vc::cell(self.variable_name.clone())
} }
} }
......
use anyhow::Result;
use indexmap::indexmap; use indexmap::indexmap;
use turbo_tasks::{TaskInput, Value, Vc}; use turbo_tasks::{TaskInput, Value, Vc};
use turbopack::{module_options::CustomModuleType, ModuleAssetContext}; use turbopack::{module_options::CustomModuleType, ModuleAssetContext};
...@@ -40,9 +39,9 @@ impl StructuredImageModuleType { ...@@ -40,9 +39,9 @@ impl StructuredImageModuleType {
source: Vc<Box<dyn Source>>, source: Vc<Box<dyn Source>>,
blur_placeholder_mode: BlurPlaceholderMode, blur_placeholder_mode: BlurPlaceholderMode,
module_asset_context: Vc<ModuleAssetContext>, module_asset_context: Vc<ModuleAssetContext>,
) -> Result<Vc<Box<dyn Module>>> { ) -> Vc<Box<dyn Module>> {
let static_asset = StaticModuleAsset::new(source, Vc::upcast(module_asset_context)); let static_asset = StaticModuleAsset::new(source, Vc::upcast(module_asset_context));
let module = module_asset_context module_asset_context
.process( .process(
Vc::upcast( Vc::upcast(
StructuredImageFileSource { StructuredImageFileSource {
...@@ -55,8 +54,7 @@ impl StructuredImageModuleType { ...@@ -55,8 +54,7 @@ impl StructuredImageModuleType {
"IMAGE".into() => Vc::upcast(static_asset) "IMAGE".into() => Vc::upcast(static_asset)
)))), )))),
) )
.module(); .module()
Ok(module)
} }
#[turbo_tasks::function] #[turbo_tasks::function]
......
...@@ -170,12 +170,9 @@ fn process_global_item( ...@@ -170,12 +170,9 @@ fn process_global_item(
item: Vc<PagesStructureItem>, item: Vc<PagesStructureItem>,
reference_type: Value<ReferenceType>, reference_type: Value<ReferenceType>,
module_context: Vc<Box<dyn AssetContext>>, module_context: Vc<Box<dyn AssetContext>>,
) -> Result<Vc<Box<dyn Module>>> { ) -> Vc<Box<dyn Module>> {
let source = Vc::upcast(FileSource::new(item.project_path())); let source = Vc::upcast(FileSource::new(item.project_path()));
module_context.process(source, reference_type).module()
let module = module_context.process(source, reference_type).module();
Ok(module)
} }
#[turbo_tasks::function] #[turbo_tasks::function]
......
...@@ -21,8 +21,8 @@ pub(crate) struct NextExactMatcher { ...@@ -21,8 +21,8 @@ pub(crate) struct NextExactMatcher {
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl NextExactMatcher { impl NextExactMatcher {
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn new(path: Vc<RcStr>) -> Result<Vc<Self>> { pub fn new(path: Vc<RcStr>) -> Vc<Self> {
Ok(Self::cell(NextExactMatcher { path })) Self::cell(NextExactMatcher { path })
} }
} }
......
...@@ -476,7 +476,7 @@ impl Issue for UnableToExternalize { ...@@ -476,7 +476,7 @@ impl Issue for UnableToExternalize {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
async fn title(&self) -> Result<Vc<StyledString>> { async fn title(&self) -> Vc<StyledString> {
let request = &self.request; let request = &self.request;
let package = if request.starts_with('@') { let package = if request.starts_with('@') {
request request
...@@ -490,14 +490,14 @@ impl Issue for UnableToExternalize { ...@@ -490,14 +490,14 @@ impl Issue for UnableToExternalize {
} else { } else {
request.clone() request.clone()
}; };
Ok(StyledString::Line(vec![ StyledString::Line(vec![
StyledString::Text("Package ".into()), StyledString::Text("Package ".into()),
StyledString::Code(package), StyledString::Code(package),
StyledString::Text(" (".into()), StyledString::Text(" (".into()),
StyledString::Code("serverExternalPackages".into()), StyledString::Code("serverExternalPackages".into()),
StyledString::Text(" or default list) can't be external".into()), StyledString::Text(" or default list) can't be external".into()),
]) ])
.cell()) .cell()
} }
#[turbo_tasks::function] #[turbo_tasks::function]
......
...@@ -46,8 +46,8 @@ impl NextServerComponentModule { ...@@ -46,8 +46,8 @@ impl NextServerComponentModule {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn server_path(&self) -> Result<Vc<FileSystemPath>> { pub fn server_path(&self) -> Vc<FileSystemPath> {
Ok(self.module.ident().path()) self.module.ident().path()
} }
} }
...@@ -92,14 +92,14 @@ impl ChunkableModule for NextServerComponentModule { ...@@ -92,14 +92,14 @@ impl ChunkableModule for NextServerComponentModule {
fn as_chunk_item( fn as_chunk_item(
self: Vc<Self>, self: Vc<Self>,
chunking_context: Vc<Box<dyn ChunkingContext>>, chunking_context: Vc<Box<dyn ChunkingContext>>,
) -> Result<Vc<Box<dyn turbopack_core::chunk::ChunkItem>>> { ) -> Vc<Box<dyn turbopack_core::chunk::ChunkItem>> {
Ok(Vc::upcast( Vc::upcast(
NextServerComponentChunkItem { NextServerComponentChunkItem {
chunking_context, chunking_context,
inner: self, inner: self,
} }
.cell(), .cell(),
)) )
} }
} }
......
...@@ -130,7 +130,7 @@ impl BeforeResolvePlugin for InvalidImportResolvePlugin { ...@@ -130,7 +130,7 @@ impl BeforeResolvePlugin for InvalidImportResolvePlugin {
lookup_path: Vc<FileSystemPath>, lookup_path: Vc<FileSystemPath>,
_reference_type: Value<ReferenceType>, _reference_type: Value<ReferenceType>,
_request: Vc<Request>, _request: Vc<Request>,
) -> Result<Vc<ResolveResultOption>> { ) -> Vc<ResolveResultOption> {
InvalidImportModuleIssue { InvalidImportModuleIssue {
file_path: lookup_path, file_path: lookup_path,
messages: self.message.clone(), messages: self.message.clone(),
...@@ -140,12 +140,12 @@ impl BeforeResolvePlugin for InvalidImportResolvePlugin { ...@@ -140,12 +140,12 @@ impl BeforeResolvePlugin for InvalidImportResolvePlugin {
.cell() .cell()
.emit(); .emit();
Ok(ResolveResultOption::some( ResolveResultOption::some(
ResolveResult::primary(ResolveResultItem::Error(Vc::cell( ResolveResult::primary(ResolveResultItem::Error(Vc::cell(
self.message.join("\n").into(), self.message.join("\n").into(),
))) )))
.cell(), .cell(),
)) )
} }
} }
......
...@@ -157,8 +157,8 @@ impl Issue for PageStaticInfoIssue { ...@@ -157,8 +157,8 @@ impl Issue for PageStaticInfoIssue {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn description(&self) -> Result<Vc<OptionStyledString>> { fn description(&self) -> Vc<OptionStyledString> {
Ok(Vc::cell(Some( Vc::cell(Some(
StyledString::Line( StyledString::Line(
self.messages self.messages
.iter() .iter()
...@@ -166,6 +166,6 @@ impl Issue for PageStaticInfoIssue { ...@@ -166,6 +166,6 @@ impl Issue for PageStaticInfoIssue {
.collect::<Vec<StyledString>>(), .collect::<Vec<StyledString>>(),
) )
.cell(), .cell(),
))) ))
} }
} }
...@@ -32,15 +32,15 @@ impl PagesStructureItem { ...@@ -32,15 +32,15 @@ impl PagesStructureItem {
fallback_path: Option<Vc<FileSystemPath>>, fallback_path: Option<Vc<FileSystemPath>>,
next_router_path: Vc<FileSystemPath>, next_router_path: Vc<FileSystemPath>,
original_path: Vc<FileSystemPath>, original_path: Vc<FileSystemPath>,
) -> Result<Vc<Self>> { ) -> Vc<Self> {
Ok(PagesStructureItem { PagesStructureItem {
base_path, base_path,
extensions, extensions,
fallback_path, fallback_path,
next_router_path, next_router_path,
original_path, original_path,
} }
.cell()) .cell()
} }
#[turbo_tasks::function] #[turbo_tasks::function]
...@@ -102,8 +102,8 @@ impl PagesDirectoryStructure { ...@@ -102,8 +102,8 @@ impl PagesDirectoryStructure {
/// Returns the path to the directory of this structure in the project file /// Returns the path to the directory of this structure in the project file
/// system. /// system.
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn project_path(&self) -> Result<Vc<FileSystemPath>> { pub fn project_path(&self) -> Vc<FileSystemPath> {
Ok(self.project_path) self.project_path
} }
} }
......
...@@ -632,7 +632,7 @@ async fn create_module_asset( ...@@ -632,7 +632,7 @@ async fn create_module_asset(
process_cwd: Option<RcStr>, process_cwd: Option<RcStr>,
module_options: TransientInstance<ModuleOptionsContext>, module_options: TransientInstance<ModuleOptionsContext>,
resolve_options: TransientInstance<ResolveOptionsContext>, resolve_options: TransientInstance<ResolveOptionsContext>,
) -> Result<Vc<ModuleAssetContext>> { ) -> Vc<ModuleAssetContext> {
let env = Environment::new(Value::new(ExecutionEnvironment::NodeJsLambda( let env = Environment::new(Value::new(ExecutionEnvironment::NodeJsLambda(
NodeJsEnvironment { NodeJsEnvironment {
cwd: Vc::cell(process_cwd), cwd: Vc::cell(process_cwd),
...@@ -666,13 +666,13 @@ async fn create_module_asset( ...@@ -666,13 +666,13 @@ async fn create_module_asset(
); );
} }
Ok(ModuleAssetContext::new( ModuleAssetContext::new(
Default::default(), Default::default(),
compile_time_info, compile_time_info,
ModuleOptionsContext::clone(&*module_options).cell(), ModuleOptionsContext::clone(&*module_options).cell(),
resolve_options.cell(), resolve_options.cell(),
Vc::cell("node_file_trace".into()), Vc::cell("node_file_trace".into()),
)) )
} }
fn register() { fn register() {
......
...@@ -24,10 +24,10 @@ impl DotenvProcessEnv { ...@@ -24,10 +24,10 @@ impl DotenvProcessEnv {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn read_prior(&self) -> Result<Vc<EnvMap>> { pub fn read_prior(&self) -> Vc<EnvMap> {
match self.prior { match self.prior {
None => Ok(EnvMap::empty()), None => EnvMap::empty(),
Some(p) => Ok(p.read_all()), Some(p) => p.read_all(),
} }
} }
...@@ -76,9 +76,9 @@ impl DotenvProcessEnv { ...@@ -76,9 +76,9 @@ impl DotenvProcessEnv {
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl ProcessEnv for DotenvProcessEnv { impl ProcessEnv for DotenvProcessEnv {
#[turbo_tasks::function] #[turbo_tasks::function]
fn read_all(self: Vc<Self>) -> Result<Vc<EnvMap>> { fn read_all(self: Vc<Self>) -> Vc<EnvMap> {
let prior = self.read_prior(); let prior = self.read_prior();
Ok(self.read_all_with_prior(prior)) self.read_all_with_prior(prior)
} }
} }
......
...@@ -30,8 +30,8 @@ impl EnvMap { ...@@ -30,8 +30,8 @@ impl EnvMap {
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl ProcessEnv for EnvMap { impl ProcessEnv for EnvMap {
#[turbo_tasks::function] #[turbo_tasks::function]
fn read_all(self: Vc<Self>) -> Result<Vc<EnvMap>> { fn read_all(self: Vc<Self>) -> Vc<EnvMap> {
Ok(self) self
} }
#[turbo_tasks::function] #[turbo_tasks::function]
......
...@@ -30,8 +30,8 @@ pub async fn content_from_relative_path( ...@@ -30,8 +30,8 @@ pub async fn content_from_relative_path(
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn content_from_str(string: RcStr) -> Result<Vc<FileContent>> { pub fn content_from_str(string: RcStr) -> Vc<FileContent> {
Ok(File::from(string).into()) File::from(string).into()
} }
/// Loads a file's content from disk and invalidates on change (debug builds). /// Loads a file's content from disk and invalidates on change (debug builds).
......
...@@ -1209,13 +1209,13 @@ impl FileSystemPath { ...@@ -1209,13 +1209,13 @@ impl FileSystemPath {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn fs(&self) -> Result<Vc<Box<dyn FileSystem>>> { pub fn fs(&self) -> Vc<Box<dyn FileSystem>> {
Ok(self.fs) self.fs
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn extension(&self) -> Result<Vc<RcStr>> { pub fn extension(&self) -> Vc<RcStr> {
Ok(Vc::cell(self.extension_ref().unwrap_or("").into())) Vc::cell(self.extension_ref().unwrap_or("").into())
} }
#[turbo_tasks::function] #[turbo_tasks::function]
...@@ -1231,9 +1231,9 @@ impl FileSystemPath { ...@@ -1231,9 +1231,9 @@ impl FileSystemPath {
/// Creates a new [`Vc<FileSystemPath>`] like `self` but with the given /// Creates a new [`Vc<FileSystemPath>`] like `self` but with the given
/// extension. /// extension.
#[turbo_tasks::function] #[turbo_tasks::function]
pub async fn with_extension(&self, extension: RcStr) -> Result<Vc<FileSystemPath>> { pub async fn with_extension(&self, extension: RcStr) -> Vc<FileSystemPath> {
let (path_without_extension, _) = self.split_extension(); let (path_without_extension, _) = self.split_extension();
Ok(Self::new_normalized( Self::new_normalized(
self.fs, self.fs,
// Like `Path::with_extension` and `PathBuf::set_extension`, if the extension is empty, // Like `Path::with_extension` and `PathBuf::set_extension`, if the extension is empty,
// we remove the extension altogether. // we remove the extension altogether.
...@@ -1241,7 +1241,7 @@ impl FileSystemPath { ...@@ -1241,7 +1241,7 @@ impl FileSystemPath {
true => path_without_extension.into(), true => path_without_extension.into(),
false => format!("{path_without_extension}.{extension}").into(), false => format!("{path_without_extension}.{extension}").into(),
}, },
)) )
} }
/// Extracts the stem (non-extension) portion of self.file_name. /// Extracts the stem (non-extension) portion of self.file_name.
...@@ -1253,12 +1253,12 @@ impl FileSystemPath { ...@@ -1253,12 +1253,12 @@ impl FileSystemPath {
/// * The entire file name if the file name begins with `.` and has no other `.`s within; /// * The entire file name if the file name begins with `.` and has no other `.`s within;
/// * Otherwise, the portion of the file name before the final `.` /// * Otherwise, the portion of the file name before the final `.`
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn file_stem(&self) -> Result<Vc<Option<RcStr>>> { pub fn file_stem(&self) -> Vc<Option<RcStr>> {
let (_, file_stem, _) = self.split_file_stem_extension(); let (_, file_stem, _) = self.split_file_stem_extension();
if file_stem.is_empty() { if file_stem.is_empty() {
return Ok(Vc::cell(None)); return Vc::cell(None);
} }
Ok(Vc::cell(Some(file_stem.into()))) Vc::cell(Some(file_stem.into()))
} }
/// See [`truncate_file_name_with_hash`]. Preserves the input [`Vc`] if no truncation was /// See [`truncate_file_name_with_hash`]. Preserves the input [`Vc`] if no truncation was
...@@ -1478,8 +1478,8 @@ pub struct RealPathResult { ...@@ -1478,8 +1478,8 @@ pub struct RealPathResult {
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl RealPathResult { impl RealPathResult {
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn path(&self) -> Result<Vc<FileSystemPath>> { pub fn path(&self) -> Vc<FileSystemPath> {
Ok(self.path) self.path
} }
} }
......
...@@ -485,8 +485,8 @@ impl ChunkingContext for BrowserChunkingContext { ...@@ -485,8 +485,8 @@ impl ChunkingContext for BrowserChunkingContext {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn chunk_item_id_from_ident(&self, ident: Vc<AssetIdent>) -> Result<Vc<ModuleId>> { fn chunk_item_id_from_ident(&self, ident: Vc<AssetIdent>) -> Vc<ModuleId> {
Ok(self.module_id_strategy.get_module_id(ident)) self.module_id_strategy.get_module_id(ident)
} }
#[turbo_tasks::function] #[turbo_tasks::function]
......
...@@ -40,8 +40,8 @@ impl EcmascriptDevChunk { ...@@ -40,8 +40,8 @@ impl EcmascriptDevChunk {
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl ValueToString for EcmascriptDevChunk { impl ValueToString for EcmascriptDevChunk {
#[turbo_tasks::function] #[turbo_tasks::function]
fn to_string(&self) -> Result<Vc<RcStr>> { fn to_string(&self) -> Vc<RcStr> {
Ok(Vc::cell("Ecmascript Dev Chunk".into())) Vc::cell("Ecmascript Dev Chunk".into())
} }
} }
......
...@@ -47,20 +47,20 @@ impl EcmascriptDevChunkContent { ...@@ -47,20 +47,20 @@ impl EcmascriptDevChunkContent {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn entries(&self) -> Result<Vc<EcmascriptDevChunkContentEntries>> { pub fn entries(&self) -> Vc<EcmascriptDevChunkContentEntries> {
Ok(self.entries) self.entries
} }
} }
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl EcmascriptDevChunkContent { impl EcmascriptDevChunkContent {
#[turbo_tasks::function] #[turbo_tasks::function]
pub(crate) fn own_version(&self) -> Result<Vc<EcmascriptDevChunkVersion>> { pub(crate) fn own_version(&self) -> Vc<EcmascriptDevChunkVersion> {
Ok(EcmascriptDevChunkVersion::new( EcmascriptDevChunkVersion::new(
self.chunking_context.output_root(), self.chunking_context.output_root(),
self.chunk.ident().path(), self.chunk.ident().path(),
self.entries, self.entries,
)) )
} }
#[turbo_tasks::function] #[turbo_tasks::function]
......
...@@ -57,11 +57,8 @@ impl EcmascriptDevEvaluateChunk { ...@@ -57,11 +57,8 @@ impl EcmascriptDevEvaluateChunk {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn chunks_data(&self) -> Result<Vc<ChunksData>> { fn chunks_data(&self) -> Vc<ChunksData> {
Ok(ChunkData::from_assets( ChunkData::from_assets(self.chunking_context.output_root(), self.other_chunks)
self.chunking_context.output_root(),
self.other_chunks,
))
} }
#[turbo_tasks::function] #[turbo_tasks::function]
...@@ -191,8 +188,8 @@ impl EcmascriptDevEvaluateChunk { ...@@ -191,8 +188,8 @@ impl EcmascriptDevEvaluateChunk {
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl ValueToString for EcmascriptDevEvaluateChunk { impl ValueToString for EcmascriptDevEvaluateChunk {
#[turbo_tasks::function] #[turbo_tasks::function]
fn to_string(&self) -> Result<Vc<RcStr>> { fn to_string(&self) -> Vc<RcStr> {
Ok(Vc::cell("Ecmascript Dev Evaluate Chunk".into())) Vc::cell("Ecmascript Dev Evaluate Chunk".into())
} }
} }
......
...@@ -61,8 +61,8 @@ impl EcmascriptDevChunkList { ...@@ -61,8 +61,8 @@ impl EcmascriptDevChunkList {
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl ValueToString for EcmascriptDevChunkList { impl ValueToString for EcmascriptDevChunkList {
#[turbo_tasks::function] #[turbo_tasks::function]
fn to_string(&self) -> Result<Vc<RcStr>> { fn to_string(&self) -> Vc<RcStr> {
Ok(Vc::cell("Ecmascript Dev Chunk List".into())) Vc::cell("Ecmascript Dev Chunk List".into())
} }
} }
...@@ -111,8 +111,8 @@ impl OutputAsset for EcmascriptDevChunkList { ...@@ -111,8 +111,8 @@ impl OutputAsset for EcmascriptDevChunkList {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn references(&self) -> Result<Vc<OutputAssets>> { fn references(&self) -> Vc<OutputAssets> {
Ok(self.chunks) self.chunks
} }
} }
......
...@@ -46,8 +46,8 @@ impl EcmascriptDevChunkRuntime { ...@@ -46,8 +46,8 @@ impl EcmascriptDevChunkRuntime {
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl ValueToString for EcmascriptDevChunkRuntime { impl ValueToString for EcmascriptDevChunkRuntime {
#[turbo_tasks::function] #[turbo_tasks::function]
fn to_string(&self) -> Result<Vc<RcStr>> { fn to_string(&self) -> Vc<RcStr> {
Ok(Vc::cell("Ecmascript Dev Runtime".to_string())) Vc::cell("Ecmascript Dev Runtime".to_string())
} }
} }
......
...@@ -50,7 +50,7 @@ async fn foreign_code_context_condition() -> Result<ContextCondition> { ...@@ -50,7 +50,7 @@ async fn foreign_code_context_condition() -> Result<ContextCondition> {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn get_client_import_map(project_path: Vc<FileSystemPath>) -> Result<Vc<ImportMap>> { pub fn get_client_import_map(project_path: Vc<FileSystemPath>) -> Vc<ImportMap> {
let mut import_map = ImportMap::empty(); let mut import_map = ImportMap::empty();
import_map.insert_singleton_alias("@swc/helpers", project_path); import_map.insert_singleton_alias("@swc/helpers", project_path);
...@@ -67,7 +67,7 @@ pub fn get_client_import_map(project_path: Vc<FileSystemPath>) -> Result<Vc<Impo ...@@ -67,7 +67,7 @@ pub fn get_client_import_map(project_path: Vc<FileSystemPath>) -> Result<Vc<Impo
.cell(), .cell(),
); );
Ok(import_map.cell()) import_map.cell()
} }
#[turbo_tasks::function] #[turbo_tasks::function]
......
...@@ -232,7 +232,7 @@ async fn source( ...@@ -232,7 +232,7 @@ async fn source(
entry_requests: TransientInstance<Vec<EntryRequest>>, entry_requests: TransientInstance<Vec<EntryRequest>>,
eager_compile: bool, eager_compile: bool,
browserslist_query: RcStr, browserslist_query: RcStr,
) -> Result<Vc<Box<dyn ContentSource>>> { ) -> Vc<Box<dyn ContentSource>> {
let project_relative = project_dir.strip_prefix(&*root_dir).unwrap(); let project_relative = project_dir.strip_prefix(&*root_dir).unwrap();
let project_relative: RcStr = project_relative let project_relative: RcStr = project_relative
.strip_prefix(MAIN_SEPARATOR) .strip_prefix(MAIN_SEPARATOR)
...@@ -303,13 +303,11 @@ async fn source( ...@@ -303,13 +303,11 @@ async fn source(
.cell(), .cell(),
); );
let main_source = Vc::upcast(main_source); let main_source = Vc::upcast(main_source);
let source = Vc::upcast(PrefixedRouterContentSource::new( Vc::upcast(PrefixedRouterContentSource::new(
Default::default(), Default::default(),
vec![("__turbopack__".into(), introspect)], vec![("__turbopack__".into(), introspect)],
main_source, main_source,
)); ))
Ok(source)
} }
pub fn register() { pub fn register() {
......
...@@ -137,7 +137,7 @@ impl ChunkData { ...@@ -137,7 +137,7 @@ impl ChunkData {
/// Returns [`OutputAsset`]s that this chunk data references. /// Returns [`OutputAsset`]s that this chunk data references.
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn references(&self) -> Result<Vc<OutputAssets>> { pub fn references(&self) -> Vc<OutputAssets> {
Ok(self.references) self.references
} }
} }
...@@ -191,9 +191,9 @@ impl GenerateSourceMap for Code { ...@@ -191,9 +191,9 @@ impl GenerateSourceMap for Code {
impl Code { impl Code {
/// Returns the hash of the source code of this Code. /// Returns the hash of the source code of this Code.
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn source_code_hash(&self) -> Result<Vc<u64>> { pub fn source_code_hash(&self) -> Vc<u64> {
let code = self; let code = self;
let hash = hash_xxh3_hash64(code.source_code()); let hash = hash_xxh3_hash64(code.source_code());
Ok(Vc::cell(hash)) Vc::cell(hash)
} }
} }
use anyhow::Result;
use indexmap::IndexMap; use indexmap::IndexMap;
use turbo_tasks::{RcStr, Vc}; use turbo_tasks::{RcStr, Vc};
use turbo_tasks_fs::FileSystemPath; use turbo_tasks_fs::FileSystemPath;
...@@ -263,8 +262,8 @@ impl CompileTimeInfo { ...@@ -263,8 +262,8 @@ impl CompileTimeInfo {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn environment(&self) -> Result<Vc<Environment>> { pub fn environment(&self) -> Vc<Environment> {
Ok(self.environment) self.environment
} }
} }
......
...@@ -93,57 +93,57 @@ impl Environment { ...@@ -93,57 +93,57 @@ impl Environment {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn node_externals(&self) -> Result<Vc<bool>> { pub fn node_externals(&self) -> Vc<bool> {
Ok(match self.execution { match self.execution {
ExecutionEnvironment::NodeJsBuildTime(..) | ExecutionEnvironment::NodeJsLambda(_) => { ExecutionEnvironment::NodeJsBuildTime(..) | ExecutionEnvironment::NodeJsLambda(_) => {
Vc::cell(true) Vc::cell(true)
} }
ExecutionEnvironment::Browser(_) => Vc::cell(false), ExecutionEnvironment::Browser(_) => Vc::cell(false),
ExecutionEnvironment::EdgeWorker(_) => Vc::cell(false), ExecutionEnvironment::EdgeWorker(_) => Vc::cell(false),
ExecutionEnvironment::Custom(_) => todo!(), ExecutionEnvironment::Custom(_) => todo!(),
}) }
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn supports_esm_externals(&self) -> Result<Vc<bool>> { pub fn supports_esm_externals(&self) -> Vc<bool> {
Ok(match self.execution { match self.execution {
ExecutionEnvironment::NodeJsBuildTime(..) | ExecutionEnvironment::NodeJsLambda(_) => { ExecutionEnvironment::NodeJsBuildTime(..) | ExecutionEnvironment::NodeJsLambda(_) => {
Vc::cell(true) Vc::cell(true)
} }
ExecutionEnvironment::Browser(_) => Vc::cell(false), ExecutionEnvironment::Browser(_) => Vc::cell(false),
ExecutionEnvironment::EdgeWorker(_) => Vc::cell(false), ExecutionEnvironment::EdgeWorker(_) => Vc::cell(false),
ExecutionEnvironment::Custom(_) => todo!(), ExecutionEnvironment::Custom(_) => todo!(),
}) }
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn supports_commonjs_externals(&self) -> Result<Vc<bool>> { pub fn supports_commonjs_externals(&self) -> Vc<bool> {
Ok(match self.execution { match self.execution {
ExecutionEnvironment::NodeJsBuildTime(..) | ExecutionEnvironment::NodeJsLambda(_) => { ExecutionEnvironment::NodeJsBuildTime(..) | ExecutionEnvironment::NodeJsLambda(_) => {
Vc::cell(true) Vc::cell(true)
} }
ExecutionEnvironment::Browser(_) => Vc::cell(false), ExecutionEnvironment::Browser(_) => Vc::cell(false),
ExecutionEnvironment::EdgeWorker(_) => Vc::cell(true), ExecutionEnvironment::EdgeWorker(_) => Vc::cell(true),
ExecutionEnvironment::Custom(_) => todo!(), ExecutionEnvironment::Custom(_) => todo!(),
}) }
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn supports_wasm(&self) -> Result<Vc<bool>> { pub fn supports_wasm(&self) -> Vc<bool> {
Ok(match self.execution { match self.execution {
ExecutionEnvironment::NodeJsBuildTime(..) | ExecutionEnvironment::NodeJsLambda(_) => { ExecutionEnvironment::NodeJsBuildTime(..) | ExecutionEnvironment::NodeJsLambda(_) => {
Vc::cell(true) Vc::cell(true)
} }
ExecutionEnvironment::Browser(_) => Vc::cell(false), ExecutionEnvironment::Browser(_) => Vc::cell(false),
ExecutionEnvironment::EdgeWorker(_) => Vc::cell(false), ExecutionEnvironment::EdgeWorker(_) => Vc::cell(false),
ExecutionEnvironment::Custom(_) => todo!(), ExecutionEnvironment::Custom(_) => todo!(),
}) }
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn resolve_extensions(&self) -> Result<Vc<Vec<RcStr>>> { pub fn resolve_extensions(&self) -> Vc<Vec<RcStr>> {
let env = self; let env = self;
Ok(match env.execution { match env.execution {
ExecutionEnvironment::NodeJsBuildTime(..) | ExecutionEnvironment::NodeJsLambda(_) => { ExecutionEnvironment::NodeJsBuildTime(..) | ExecutionEnvironment::NodeJsLambda(_) => {
Vc::cell(vec![".js".into(), ".node".into(), ".json".into()]) Vc::cell(vec![".js".into(), ".node".into(), ".json".into()])
} }
...@@ -151,13 +151,13 @@ impl Environment { ...@@ -151,13 +151,13 @@ impl Environment {
Vc::<Vec<RcStr>>::default() Vc::<Vec<RcStr>>::default()
} }
ExecutionEnvironment::Custom(_) => todo!(), ExecutionEnvironment::Custom(_) => todo!(),
}) }
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn resolve_node_modules(&self) -> Result<Vc<bool>> { pub fn resolve_node_modules(&self) -> Vc<bool> {
let env = self; let env = self;
Ok(match env.execution { match env.execution {
ExecutionEnvironment::NodeJsBuildTime(..) | ExecutionEnvironment::NodeJsLambda(_) => { ExecutionEnvironment::NodeJsBuildTime(..) | ExecutionEnvironment::NodeJsLambda(_) => {
Vc::cell(true) Vc::cell(true)
} }
...@@ -165,13 +165,13 @@ impl Environment { ...@@ -165,13 +165,13 @@ impl Environment {
Vc::cell(false) Vc::cell(false)
} }
ExecutionEnvironment::Custom(_) => todo!(), ExecutionEnvironment::Custom(_) => todo!(),
}) }
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn resolve_conditions(&self) -> Result<Vc<Vec<RcStr>>> { pub fn resolve_conditions(&self) -> Vc<Vec<RcStr>> {
let env = self; let env = self;
Ok(match env.execution { match env.execution {
ExecutionEnvironment::NodeJsBuildTime(..) | ExecutionEnvironment::NodeJsLambda(_) => { ExecutionEnvironment::NodeJsBuildTime(..) | ExecutionEnvironment::NodeJsLambda(_) => {
Vc::cell(vec!["node".into()]) Vc::cell(vec!["node".into()])
} }
...@@ -180,7 +180,7 @@ impl Environment { ...@@ -180,7 +180,7 @@ impl Environment {
Vc::cell(vec!["edge-light".into(), "worker".into()]) Vc::cell(vec!["edge-light".into(), "worker".into()])
} }
ExecutionEnvironment::Custom(_) => todo!(), ExecutionEnvironment::Custom(_) => todo!(),
}) }
} }
#[turbo_tasks::function] #[turbo_tasks::function]
...@@ -194,29 +194,29 @@ impl Environment { ...@@ -194,29 +194,29 @@ impl Environment {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn rendering(&self) -> Result<Vc<Rendering>> { pub fn rendering(&self) -> Vc<Rendering> {
let env = self; let env = self;
Ok(match env.execution { match env.execution {
ExecutionEnvironment::NodeJsBuildTime(_) | ExecutionEnvironment::NodeJsLambda(_) => { ExecutionEnvironment::NodeJsBuildTime(_) | ExecutionEnvironment::NodeJsLambda(_) => {
Rendering::Server.cell() Rendering::Server.cell()
} }
ExecutionEnvironment::EdgeWorker(_) => Rendering::Server.cell(), ExecutionEnvironment::EdgeWorker(_) => Rendering::Server.cell(),
ExecutionEnvironment::Browser(_) => Rendering::Client.cell(), ExecutionEnvironment::Browser(_) => Rendering::Client.cell(),
_ => Rendering::None.cell(), _ => Rendering::None.cell(),
}) }
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn chunk_loading(&self) -> Result<Vc<ChunkLoading>> { pub fn chunk_loading(&self) -> Vc<ChunkLoading> {
let env = self; let env = self;
Ok(match env.execution { match env.execution {
ExecutionEnvironment::NodeJsBuildTime(_) | ExecutionEnvironment::NodeJsLambda(_) => { ExecutionEnvironment::NodeJsBuildTime(_) | ExecutionEnvironment::NodeJsLambda(_) => {
ChunkLoading::NodeJs.cell() ChunkLoading::NodeJs.cell()
} }
ExecutionEnvironment::EdgeWorker(_) => ChunkLoading::Edge.cell(), ExecutionEnvironment::EdgeWorker(_) => ChunkLoading::Edge.cell(),
ExecutionEnvironment::Browser(_) => ChunkLoading::Dom.cell(), ExecutionEnvironment::Browser(_) => ChunkLoading::Dom.cell(),
ExecutionEnvironment::Custom(_) => todo!(), ExecutionEnvironment::Custom(_) => todo!(),
}) }
} }
} }
......
...@@ -368,8 +368,8 @@ pub struct CapturedIssues { ...@@ -368,8 +368,8 @@ pub struct CapturedIssues {
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl CapturedIssues { impl CapturedIssues {
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn is_empty(&self) -> Result<Vc<bool>> { pub fn is_empty(&self) -> Vc<bool> {
Ok(Vc::cell(self.is_empty_ref())) Vc::cell(self.is_empty_ref())
} }
} }
...@@ -761,8 +761,8 @@ impl PlainIssue { ...@@ -761,8 +761,8 @@ impl PlainIssue {
/// same issue to pass from multiple processing paths, making for overly /// same issue to pass from multiple processing paths, making for overly
/// verbose logging. /// verbose logging.
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn internal_hash(&self, full: bool) -> Result<Vc<u64>> { pub fn internal_hash(&self, full: bool) -> Vc<u64> {
Ok(Vc::cell(self.internal_hash_ref(full))) Vc::cell(self.internal_hash_ref(full))
} }
} }
......
...@@ -86,8 +86,8 @@ impl SingleModuleReference { ...@@ -86,8 +86,8 @@ impl SingleModuleReference {
/// The [Vc<Box<dyn Asset>>] that this reference resolves to. /// The [Vc<Box<dyn Asset>>] that this reference resolves to.
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn asset(&self) -> Result<Vc<Box<dyn Module>>> { pub fn asset(&self) -> Vc<Box<dyn Module>> {
Ok(self.asset) self.asset
} }
} }
...@@ -132,8 +132,8 @@ impl SingleOutputAssetReference { ...@@ -132,8 +132,8 @@ impl SingleOutputAssetReference {
/// The [Vc<Box<dyn Asset>>] that this reference resolves to. /// The [Vc<Box<dyn Asset>>] that this reference resolves to.
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn asset(&self) -> Result<Vc<Box<dyn OutputAsset>>> { pub fn asset(&self) -> Vc<Box<dyn OutputAsset>> {
Ok(self.asset) self.asset
} }
} }
......
...@@ -319,18 +319,16 @@ impl ModuleResolveResult { ...@@ -319,18 +319,16 @@ impl ModuleResolveResult {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn is_unresolveable(&self) -> Result<Vc<bool>> { pub fn is_unresolveable(&self) -> Vc<bool> {
Ok(Vc::cell(self.is_unresolveable_ref())) Vc::cell(self.is_unresolveable_ref())
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn first_module(&self) -> Result<Vc<OptionModule>> { pub fn first_module(&self) -> Vc<OptionModule> {
Ok(Vc::cell(self.primary.iter().find_map( Vc::cell(self.primary.iter().find_map(|(_, item)| match item {
|(_, item)| match item {
&ModuleResolveResultItem::Module(a) => Some(a), &ModuleResolveResultItem::Module(a) => Some(a),
_ => None, _ => None,
}, }))
)))
} }
/// Returns a set (no duplicates) of primary modules in the result. All /// Returns a set (no duplicates) of primary modules in the result. All
...@@ -357,8 +355,8 @@ impl ModuleResolveResult { ...@@ -357,8 +355,8 @@ impl ModuleResolveResult {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn primary_output_assets(&self) -> Result<Vc<OutputAssets>> { pub fn primary_output_assets(&self) -> Vc<OutputAssets> {
Ok(Vc::cell( Vc::cell(
self.primary self.primary
.iter() .iter()
.filter_map(|(_, item)| match item { .filter_map(|(_, item)| match item {
...@@ -366,7 +364,7 @@ impl ModuleResolveResult { ...@@ -366,7 +364,7 @@ impl ModuleResolveResult {
_ => None, _ => None,
}) })
.collect(), .collect(),
)) )
} }
} }
...@@ -847,24 +845,24 @@ impl ResolveResult { ...@@ -847,24 +845,24 @@ impl ResolveResult {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn is_unresolveable(&self) -> Result<Vc<bool>> { pub fn is_unresolveable(&self) -> Vc<bool> {
Ok(Vc::cell(self.is_unresolveable_ref())) Vc::cell(self.is_unresolveable_ref())
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn first_source(&self) -> Result<Vc<OptionSource>> { pub fn first_source(&self) -> Vc<OptionSource> {
Ok(Vc::cell(self.primary.iter().find_map(|(_, item)| { Vc::cell(self.primary.iter().find_map(|(_, item)| {
if let &ResolveResultItem::Source(a) = item { if let &ResolveResultItem::Source(a) = item {
Some(a) Some(a)
} else { } else {
None None
} }
}))) }))
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn primary_sources(&self) -> Result<Vc<Sources>> { pub fn primary_sources(&self) -> Vc<Sources> {
Ok(Vc::cell( Vc::cell(
self.primary self.primary
.iter() .iter()
.filter_map(|(_, item)| { .filter_map(|(_, item)| {
...@@ -875,7 +873,7 @@ impl ResolveResult { ...@@ -875,7 +873,7 @@ impl ResolveResult {
} }
}) })
.collect(), .collect(),
)) )
} }
/// Returns a new [ResolveResult] where all [RequestKey]s are updated. The `old_request_key` /// Returns a new [ResolveResult] where all [RequestKey]s are updated. The `old_request_key`
...@@ -953,7 +951,7 @@ impl ResolveResult { ...@@ -953,7 +951,7 @@ impl ResolveResult {
/// Returns a new [ResolveResult] where all [RequestKey]s are set to the /// Returns a new [ResolveResult] where all [RequestKey]s are set to the
/// passed `request`. /// passed `request`.
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn with_request(&self, request: RcStr) -> Result<Vc<Self>> { pub fn with_request(&self, request: RcStr) -> Vc<Self> {
let new_primary = self let new_primary = self
.primary .primary
.iter() .iter()
...@@ -967,11 +965,11 @@ impl ResolveResult { ...@@ -967,11 +965,11 @@ impl ResolveResult {
) )
}) })
.collect(); .collect();
Ok(ResolveResult { ResolveResult {
primary: new_primary, primary: new_primary,
affecting_sources: self.affecting_sources.clone(), affecting_sources: self.affecting_sources.clone(),
} }
.into()) .into()
} }
} }
......
...@@ -28,12 +28,10 @@ impl SourceMapAsset { ...@@ -28,12 +28,10 @@ impl SourceMapAsset {
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl OutputAsset for SourceMapAsset { impl OutputAsset for SourceMapAsset {
#[turbo_tasks::function] #[turbo_tasks::function]
fn ident(&self) -> Result<Vc<AssetIdent>> { fn ident(&self) -> Vc<AssetIdent> {
// NOTE(alexkirsz) We used to include the asset's version id in the path, // NOTE(alexkirsz) We used to include the asset's version id in the path,
// but this caused `all_assets_map` to be recomputed on every change. // but this caused `all_assets_map` to be recomputed on every change.
Ok(AssetIdent::from_path( AssetIdent::from_path(self.asset.ident().path().append(".map".into()))
self.asset.ident().path().append(".map".into()),
))
} }
} }
......
use anyhow::Result;
use turbo_tasks::Vc; use turbo_tasks::Vc;
use crate::source::Source; use crate::source::Source;
...@@ -14,10 +13,9 @@ pub struct SourceTransforms(Vec<Vc<Box<dyn SourceTransform>>>); ...@@ -14,10 +13,9 @@ pub struct SourceTransforms(Vec<Vc<Box<dyn SourceTransform>>>);
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl SourceTransforms { impl SourceTransforms {
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn transform(&self, source: Vc<Box<dyn Source>>) -> Result<Vc<Box<dyn Source>>> { pub fn transform(&self, source: Vc<Box<dyn Source>>) -> Vc<Box<dyn Source>> {
Ok(self self.0
.0
.iter() .iter()
.fold(source, |source, transform| transform.transform(source))) .fold(source, |source, transform| transform.transform(source))
} }
} }
...@@ -236,8 +236,8 @@ impl FileHashVersion { ...@@ -236,8 +236,8 @@ impl FileHashVersion {
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl Version for FileHashVersion { impl Version for FileHashVersion {
#[turbo_tasks::function] #[turbo_tasks::function]
fn id(&self) -> Result<Vc<RcStr>> { fn id(&self) -> Vc<RcStr> {
Ok(Vc::cell(self.hash.clone())) Vc::cell(self.hash.clone())
} }
} }
...@@ -250,9 +250,9 @@ pub struct VersionState { ...@@ -250,9 +250,9 @@ pub struct VersionState {
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl VersionState { impl VersionState {
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn get(&self) -> Result<Vc<Box<dyn Version>>> { pub fn get(&self) -> Vc<Box<dyn Version>> {
let version = TraitRef::cell(self.version.get().clone()); let version = TraitRef::cell(self.version.get().clone());
Ok(version) version
} }
} }
......
...@@ -65,8 +65,8 @@ impl CssModuleAsset { ...@@ -65,8 +65,8 @@ impl CssModuleAsset {
/// Retrns the asset ident of the source without the "css" modifier /// Retrns the asset ident of the source without the "css" modifier
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn source_ident(&self) -> Result<Vc<AssetIdent>> { pub fn source_ident(&self) -> Vc<AssetIdent> {
Ok(self.source.ident()) self.source.ident()
} }
} }
...@@ -90,20 +90,20 @@ impl ParseCss for CssModuleAsset { ...@@ -90,20 +90,20 @@ impl ParseCss for CssModuleAsset {
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl ProcessCss for CssModuleAsset { impl ProcessCss for CssModuleAsset {
#[turbo_tasks::function] #[turbo_tasks::function]
fn get_css_with_placeholder(self: Vc<Self>) -> Result<Vc<CssWithPlaceholderResult>> { fn get_css_with_placeholder(self: Vc<Self>) -> Vc<CssWithPlaceholderResult> {
let parse_result = self.parse_css(); let parse_result = self.parse_css();
Ok(process_css_with_placeholder(parse_result)) process_css_with_placeholder(parse_result)
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn finalize_css( fn finalize_css(
self: Vc<Self>, self: Vc<Self>,
chunking_context: Vc<Box<dyn ChunkingContext>>, chunking_context: Vc<Box<dyn ChunkingContext>>,
) -> Result<Vc<FinalCssResult>> { ) -> Vc<FinalCssResult> {
let process_result = self.get_css_with_placeholder(); let process_result = self.get_css_with_placeholder();
Ok(finalize_css(process_result, chunking_context)) finalize_css(process_result, chunking_context)
} }
} }
......
...@@ -100,15 +100,15 @@ fn single_item_modifier() -> Vc<RcStr> { ...@@ -100,15 +100,15 @@ fn single_item_modifier() -> Vc<RcStr> {
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl OutputAsset for SingleItemCssChunk { impl OutputAsset for SingleItemCssChunk {
#[turbo_tasks::function] #[turbo_tasks::function]
fn ident(&self) -> Result<Vc<AssetIdent>> { fn ident(&self) -> Vc<AssetIdent> {
Ok(AssetIdent::from_path( AssetIdent::from_path(
self.chunking_context.chunk_path( self.chunking_context.chunk_path(
self.item self.item
.asset_ident() .asset_ident()
.with_modifier(single_item_modifier()), .with_modifier(single_item_modifier()),
".css".into(), ".css".into(),
), ),
)) )
} }
#[turbo_tasks::function] #[turbo_tasks::function]
......
...@@ -28,10 +28,8 @@ impl SingleItemCssChunkSourceMapAsset { ...@@ -28,10 +28,8 @@ impl SingleItemCssChunkSourceMapAsset {
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl OutputAsset for SingleItemCssChunkSourceMapAsset { impl OutputAsset for SingleItemCssChunkSourceMapAsset {
#[turbo_tasks::function] #[turbo_tasks::function]
fn ident(&self) -> Result<Vc<AssetIdent>> { fn ident(&self) -> Vc<AssetIdent> {
Ok(AssetIdent::from_path( AssetIdent::from_path(self.chunk.path().append(".map".into()))
self.chunk.path().append(".map".into()),
))
} }
} }
......
...@@ -28,10 +28,8 @@ impl CssChunkSourceMapAsset { ...@@ -28,10 +28,8 @@ impl CssChunkSourceMapAsset {
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl OutputAsset for CssChunkSourceMapAsset { impl OutputAsset for CssChunkSourceMapAsset {
#[turbo_tasks::function] #[turbo_tasks::function]
fn ident(&self) -> Result<Vc<AssetIdent>> { fn ident(&self) -> Vc<AssetIdent> {
Ok(AssetIdent::from_path( AssetIdent::from_path(self.chunk.path().append(".map".into()))
self.chunk.path().append(".map".into()),
))
} }
} }
......
...@@ -49,14 +49,11 @@ pub struct ModuleCssAsset { ...@@ -49,14 +49,11 @@ pub struct ModuleCssAsset {
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl ModuleCssAsset { impl ModuleCssAsset {
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn new( pub fn new(source: Vc<Box<dyn Source>>, asset_context: Vc<Box<dyn AssetContext>>) -> Vc<Self> {
source: Vc<Box<dyn Source>>, Self::cell(ModuleCssAsset {
asset_context: Vc<Box<dyn AssetContext>>,
) -> Result<Vc<Self>> {
Ok(Self::cell(ModuleCssAsset {
source, source,
asset_context, asset_context,
})) })
} }
} }
...@@ -152,11 +149,11 @@ struct ModuleCssClasses(IndexMap<String, Vec<ModuleCssClass>>); ...@@ -152,11 +149,11 @@ struct ModuleCssClasses(IndexMap<String, Vec<ModuleCssClass>>);
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl ModuleCssAsset { impl ModuleCssAsset {
#[turbo_tasks::function] #[turbo_tasks::function]
fn inner(&self) -> Result<Vc<ProcessResult>> { fn inner(&self) -> Vc<ProcessResult> {
Ok(self.asset_context.process( self.asset_context.process(
self.source, self.source,
Value::new(ReferenceType::Css(CssReferenceSubType::Internal)), Value::new(ReferenceType::Css(CssReferenceSubType::Internal)),
)) )
} }
#[turbo_tasks::function] #[turbo_tasks::function]
...@@ -237,14 +234,14 @@ impl ChunkableModule for ModuleCssAsset { ...@@ -237,14 +234,14 @@ impl ChunkableModule for ModuleCssAsset {
fn as_chunk_item( fn as_chunk_item(
self: Vc<Self>, self: Vc<Self>,
chunking_context: Vc<Box<dyn ChunkingContext>>, chunking_context: Vc<Box<dyn ChunkingContext>>,
) -> Result<Vc<Box<dyn turbopack_core::chunk::ChunkItem>>> { ) -> Vc<Box<dyn turbopack_core::chunk::ChunkItem>> {
Ok(Vc::upcast( Vc::upcast(
ModuleChunkItem { ModuleChunkItem {
chunking_context, chunking_context,
module: self, module: self,
} }
.cell(), .cell(),
)) )
} }
} }
...@@ -439,11 +436,9 @@ impl Issue for CssModuleComposesIssue { ...@@ -439,11 +436,9 @@ impl Issue for CssModuleComposesIssue {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn title(&self) -> Result<Vc<StyledString>> { fn title(&self) -> Vc<StyledString> {
Ok(StyledString::Text( StyledString::Text("An issue occurred while resolving a CSS module `composes:` rule".into())
"An issue occurred while resolving a CSS module `composes:` rule".into(), .cell()
)
.cell())
} }
#[turbo_tasks::function] #[turbo_tasks::function]
......
...@@ -241,7 +241,7 @@ struct DevHtmlAssetVersion { ...@@ -241,7 +241,7 @@ struct DevHtmlAssetVersion {
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl Version for DevHtmlAssetVersion { impl Version for DevHtmlAssetVersion {
#[turbo_tasks::function] #[turbo_tasks::function]
fn id(&self) -> Result<Vc<RcStr>> { fn id(&self) -> Vc<RcStr> {
let mut hasher = Xxh3Hash64Hasher::new(); let mut hasher = Xxh3Hash64Hasher::new();
for relative_path in &*self.content.chunk_paths { for relative_path in &*self.content.chunk_paths {
hasher.write_ref(relative_path); hasher.write_ref(relative_path);
...@@ -251,6 +251,6 @@ impl Version for DevHtmlAssetVersion { ...@@ -251,6 +251,6 @@ impl Version for DevHtmlAssetVersion {
} }
let hash = hasher.finish(); let hash = hasher.finish();
let hex_hash = encode_hex(hash); let hex_hash = encode_hex(hash);
Ok(Vc::cell(hex_hash.into())) Vc::cell(hex_hash.into())
} }
} }
...@@ -108,15 +108,15 @@ impl Introspectable for ConditionalContentSource { ...@@ -108,15 +108,15 @@ impl Introspectable for ConditionalContentSource {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn details(&self) -> Result<Vc<RcStr>> { fn details(&self) -> Vc<RcStr> {
Ok(Vc::cell( Vc::cell(
if *self.activated.get() { if *self.activated.get() {
"activated" "activated"
} else { } else {
"not activated" "not activated"
} }
.into(), .into(),
)) )
} }
#[turbo_tasks::function] #[turbo_tasks::function]
......
...@@ -29,13 +29,13 @@ impl PrefixedRouterContentSource { ...@@ -29,13 +29,13 @@ impl PrefixedRouterContentSource {
prefix: Vc<RcStr>, prefix: Vc<RcStr>,
routes: Vec<(RcStr, Vc<Box<dyn ContentSource>>)>, routes: Vec<(RcStr, Vc<Box<dyn ContentSource>>)>,
fallback: Vc<Box<dyn ContentSource>>, fallback: Vc<Box<dyn ContentSource>>,
) -> Result<Vc<Self>> { ) -> Vc<Self> {
Ok(PrefixedRouterContentSource { PrefixedRouterContentSource {
prefix, prefix,
routes, routes,
fallback, fallback,
} }
.cell()) .cell()
} }
} }
......
...@@ -164,7 +164,7 @@ async fn compute_update_stream( ...@@ -164,7 +164,7 @@ async fn compute_update_stream(
from: Vc<VersionState>, from: Vc<VersionState>,
get_content: TransientInstance<GetContentFn>, get_content: TransientInstance<GetContentFn>,
sender: TransientInstance<Sender<Result<ReadRef<UpdateStreamItem>>>>, sender: TransientInstance<Sender<Result<ReadRef<UpdateStreamItem>>>>,
) -> Result<Vc<()>> { ) -> Vc<()> {
let item = get_update_stream_item(resource, from, get_content) let item = get_update_stream_item(resource, from, get_content)
.strongly_consistent() .strongly_consistent()
.await; .await;
...@@ -172,7 +172,7 @@ async fn compute_update_stream( ...@@ -172,7 +172,7 @@ async fn compute_update_stream(
// Send update. Ignore channel closed error. // Send update. Ignore channel closed error.
let _ = sender.send(item).await; let _ = sender.send(item).await;
Ok(Default::default()) Default::default()
} }
pub(super) struct UpdateStream( pub(super) struct UpdateStream(
......
...@@ -64,11 +64,9 @@ impl Issue for UnsupportedSwcEcmaTransformPluginsIssue { ...@@ -64,11 +64,9 @@ impl Issue for UnsupportedSwcEcmaTransformPluginsIssue {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn title(&self) -> Result<Vc<StyledString>> { fn title(&self) -> Vc<StyledString> {
Ok(StyledString::Text( StyledString::Text("Unsupported SWC EcmaScript transform plugins on this platform.".into())
"Unsupported SWC EcmaScript transform plugins on this platform.".into(), .cell()
)
.cell())
} }
#[turbo_tasks::function] #[turbo_tasks::function]
......
...@@ -80,13 +80,13 @@ impl ChunkableModule for AsyncLoaderModule { ...@@ -80,13 +80,13 @@ impl ChunkableModule for AsyncLoaderModule {
fn as_chunk_item( fn as_chunk_item(
self: Vc<Self>, self: Vc<Self>,
chunking_context: Vc<Box<dyn ChunkingContext>>, chunking_context: Vc<Box<dyn ChunkingContext>>,
) -> Result<Vc<Box<dyn turbopack_core::chunk::ChunkItem>>> { ) -> Vc<Box<dyn turbopack_core::chunk::ChunkItem>> {
Ok(Vc::upcast( Vc::upcast(
AsyncLoaderChunkItem { AsyncLoaderChunkItem {
chunking_context, chunking_context,
module: self, module: self,
} }
.cell(), .cell(),
)) )
} }
} }
...@@ -48,18 +48,18 @@ impl EcmascriptChunk { ...@@ -48,18 +48,18 @@ impl EcmascriptChunk {
pub fn new( pub fn new(
chunking_context: Vc<Box<dyn ChunkingContext>>, chunking_context: Vc<Box<dyn ChunkingContext>>,
content: Vc<EcmascriptChunkContent>, content: Vc<EcmascriptChunkContent>,
) -> Result<Vc<Self>> { ) -> Vc<Self> {
Ok(EcmascriptChunk { EcmascriptChunk {
chunking_context, chunking_context,
content, content,
} }
.cell()) .cell()
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn entry_ids(self: Vc<Self>) -> Result<Vc<ModuleIds>> { pub fn entry_ids(self: Vc<Self>) -> Vc<ModuleIds> {
// TODO return something usefull // TODO return something usefull
Ok(Vc::cell(Default::default())) Vc::cell(Default::default())
} }
} }
......
...@@ -249,12 +249,12 @@ impl Introspectable for ChunkGroupFilesAsset { ...@@ -249,12 +249,12 @@ impl Introspectable for ChunkGroupFilesAsset {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn children(&self) -> Result<Vc<IntrospectableChildren>> { fn children(&self) -> Vc<IntrospectableChildren> {
let mut children = IndexSet::new(); let mut children = IndexSet::new();
children.insert(( children.insert((
Vc::cell("inner asset".into()), Vc::cell("inner asset".into()),
IntrospectableModule::new(Vc::upcast(self.module)), IntrospectableModule::new(Vc::upcast(self.module)),
)); ));
Ok(Vc::cell(children)) Vc::cell(children)
} }
} }
...@@ -352,13 +352,13 @@ impl EcmascriptParsable for EcmascriptModuleAsset { ...@@ -352,13 +352,13 @@ impl EcmascriptParsable for EcmascriptModuleAsset {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn parse_original(self: Vc<Self>) -> Result<Vc<ParseResult>> { fn parse_original(self: Vc<Self>) -> Vc<ParseResult> {
Ok(self.failsafe_parse()) self.failsafe_parse()
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn ty(&self) -> Result<Vc<EcmascriptModuleAssetType>> { fn ty(&self) -> Vc<EcmascriptModuleAssetType> {
Ok(self.ty.cell()) self.ty.cell()
} }
} }
...@@ -461,8 +461,8 @@ impl EcmascriptModuleAsset { ...@@ -461,8 +461,8 @@ impl EcmascriptModuleAsset {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn source(&self) -> Result<Vc<Box<dyn Source>>> { pub fn source(&self) -> Vc<Box<dyn Source>> {
Ok(self.source) self.source
} }
#[turbo_tasks::function] #[turbo_tasks::function]
...@@ -471,8 +471,8 @@ impl EcmascriptModuleAsset { ...@@ -471,8 +471,8 @@ impl EcmascriptModuleAsset {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn options(&self) -> Result<Vc<EcmascriptOptions>> { pub fn options(&self) -> Vc<EcmascriptOptions> {
Ok(self.options) self.options
} }
#[turbo_tasks::function] #[turbo_tasks::function]
...@@ -572,11 +572,11 @@ impl ChunkableModule for EcmascriptModuleAsset { ...@@ -572,11 +572,11 @@ impl ChunkableModule for EcmascriptModuleAsset {
fn as_chunk_item( fn as_chunk_item(
self: Vc<Self>, self: Vc<Self>,
chunking_context: Vc<Box<dyn ChunkingContext>>, chunking_context: Vc<Box<dyn ChunkingContext>>,
) -> Result<Vc<Box<dyn ChunkItem>>> { ) -> Vc<Box<dyn ChunkItem>> {
Ok(Vc::upcast(ModuleChunkItem::cell(ModuleChunkItem { Vc::upcast(ModuleChunkItem::cell(ModuleChunkItem {
module: self, module: self,
chunking_context, chunking_context,
}))) }))
} }
} }
......
...@@ -52,10 +52,9 @@ impl ManifestAsyncModule { ...@@ -52,10 +52,9 @@ impl ManifestAsyncModule {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub(super) fn chunks(&self) -> Result<Vc<OutputAssets>> { pub(super) fn chunks(&self) -> Vc<OutputAssets> {
Ok(self self.chunking_context
.chunking_context .chunk_group_assets(Vc::upcast(self.inner), Value::new(self.availability_info))
.chunk_group_assets(Vc::upcast(self.inner), Value::new(self.availability_info)))
} }
#[turbo_tasks::function] #[turbo_tasks::function]
...@@ -142,14 +141,14 @@ impl ChunkableModule for ManifestAsyncModule { ...@@ -142,14 +141,14 @@ impl ChunkableModule for ManifestAsyncModule {
fn as_chunk_item( fn as_chunk_item(
self: Vc<Self>, self: Vc<Self>,
chunking_context: Vc<Box<dyn ChunkingContext>>, chunking_context: Vc<Box<dyn ChunkingContext>>,
) -> Result<Vc<Box<dyn turbopack_core::chunk::ChunkItem>>> { ) -> Vc<Box<dyn turbopack_core::chunk::ChunkItem>> {
Ok(Vc::upcast( Vc::upcast(
ManifestChunkItem { ManifestChunkItem {
chunking_context, chunking_context,
manifest: self, manifest: self,
} }
.cell(), .cell(),
)) )
} }
} }
......
...@@ -29,11 +29,8 @@ pub(super) struct ManifestChunkItem { ...@@ -29,11 +29,8 @@ pub(super) struct ManifestChunkItem {
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl ManifestChunkItem { impl ManifestChunkItem {
#[turbo_tasks::function] #[turbo_tasks::function]
fn chunks_data(&self) -> Result<Vc<ChunksData>> { fn chunks_data(&self) -> Vc<ChunksData> {
Ok(ChunkData::from_assets( ChunkData::from_assets(self.chunking_context.output_root(), self.manifest.chunks())
self.chunking_context.output_root(),
self.manifest.chunks(),
))
} }
} }
......
...@@ -58,12 +58,9 @@ impl ManifestLoaderChunkItem { ...@@ -58,12 +58,9 @@ impl ManifestLoaderChunkItem {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn chunks_data(&self) -> Result<Vc<ChunksData>> { pub fn chunks_data(&self) -> Vc<ChunksData> {
let chunks = self.manifest.manifest_chunks(); let chunks = self.manifest.manifest_chunks();
Ok(ChunkData::from_assets( ChunkData::from_assets(self.chunking_context.output_root(), chunks)
self.chunking_context.output_root(),
chunks,
))
} }
#[turbo_tasks::function] #[turbo_tasks::function]
...@@ -124,8 +121,8 @@ impl ChunkItem for ManifestLoaderChunkItem { ...@@ -124,8 +121,8 @@ impl ChunkItem for ManifestLoaderChunkItem {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn chunking_context(&self) -> Result<Vc<Box<dyn ChunkingContext>>> { fn chunking_context(&self) -> Vc<Box<dyn ChunkingContext>> {
Ok(Vc::upcast(self.chunking_context)) Vc::upcast(self.chunking_context)
} }
#[turbo_tasks::function] #[turbo_tasks::function]
......
...@@ -176,14 +176,14 @@ impl AsyncModule { ...@@ -176,14 +176,14 @@ impl AsyncModule {
pub fn module_options( pub fn module_options(
&self, &self,
async_module_info: Option<Vc<AsyncModuleInfo>>, async_module_info: Option<Vc<AsyncModuleInfo>>,
) -> Result<Vc<OptionAsyncModuleOptions>> { ) -> Vc<OptionAsyncModuleOptions> {
if async_module_info.is_none() { if async_module_info.is_none() {
return Ok(Vc::cell(None)); return Vc::cell(None);
} }
Ok(Vc::cell(Some(AsyncModuleOptions { Vc::cell(Some(AsyncModuleOptions {
has_top_level_await: self.has_top_level_await, has_top_level_await: self.has_top_level_await,
}))) }))
} }
#[turbo_tasks::function] #[turbo_tasks::function]
......
...@@ -125,14 +125,14 @@ impl ChunkableModule for CachedExternalModule { ...@@ -125,14 +125,14 @@ impl ChunkableModule for CachedExternalModule {
fn as_chunk_item( fn as_chunk_item(
self: Vc<Self>, self: Vc<Self>,
chunking_context: Vc<Box<dyn ChunkingContext>>, chunking_context: Vc<Box<dyn ChunkingContext>>,
) -> Result<Vc<Box<dyn ChunkItem>>> { ) -> Vc<Box<dyn ChunkItem>> {
Ok(Vc::upcast( Vc::upcast(
CachedExternalModuleChunkItem { CachedExternalModuleChunkItem {
module: self, module: self,
chunking_context, chunking_context,
} }
.cell(), .cell(),
)) )
} }
} }
...@@ -230,18 +230,18 @@ impl EcmascriptChunkItem for CachedExternalModuleChunkItem { ...@@ -230,18 +230,18 @@ impl EcmascriptChunkItem for CachedExternalModuleChunkItem {
fn content_with_async_module_info( fn content_with_async_module_info(
&self, &self,
async_module_info: Option<Vc<AsyncModuleInfo>>, async_module_info: Option<Vc<AsyncModuleInfo>>,
) -> Result<Vc<EcmascriptChunkItemContent>> { ) -> Vc<EcmascriptChunkItemContent> {
let async_module_options = self let async_module_options = self
.module .module
.get_async_module() .get_async_module()
.module_options(async_module_info); .module_options(async_module_info);
Ok(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,
)) )
} }
} }
......
...@@ -262,15 +262,15 @@ impl ModuleReference for RequireContextAssetReference { ...@@ -262,15 +262,15 @@ impl ModuleReference for RequireContextAssetReference {
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl ValueToString for RequireContextAssetReference { impl ValueToString for RequireContextAssetReference {
#[turbo_tasks::function] #[turbo_tasks::function]
async fn to_string(&self) -> Result<Vc<RcStr>> { async fn to_string(&self) -> Vc<RcStr> {
Ok(Vc::cell( Vc::cell(
format!( format!(
"require.context {}/{}", "require.context {}/{}",
self.dir, self.dir,
if self.include_subdirs { "**" } else { "*" }, if self.include_subdirs { "**" } else { "*" },
) )
.into(), .into(),
)) )
} }
} }
...@@ -317,8 +317,8 @@ impl ModuleReference for ResolvedModuleReference { ...@@ -317,8 +317,8 @@ impl ModuleReference for ResolvedModuleReference {
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl ValueToString for ResolvedModuleReference { impl ValueToString for ResolvedModuleReference {
#[turbo_tasks::function] #[turbo_tasks::function]
fn to_string(&self) -> Result<Vc<RcStr>> { fn to_string(&self) -> Vc<RcStr> {
Ok(Vc::cell("resolved reference".into())) Vc::cell("resolved reference".into())
} }
} }
......
...@@ -97,10 +97,8 @@ impl ModuleReference for TsReferencePathAssetReference { ...@@ -97,10 +97,8 @@ impl ModuleReference for TsReferencePathAssetReference {
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl ValueToString for TsReferencePathAssetReference { impl ValueToString for TsReferencePathAssetReference {
#[turbo_tasks::function] #[turbo_tasks::function]
async fn to_string(&self) -> Result<Vc<RcStr>> { async fn to_string(&self) -> Vc<RcStr> {
Ok(Vc::cell( Vc::cell(format!("typescript reference path comment {}", self.path,).into())
format!("typescript reference path comment {}", self.path,).into(),
))
} }
} }
...@@ -138,9 +136,7 @@ impl ModuleReference for TsReferenceTypeAssetReference { ...@@ -138,9 +136,7 @@ impl ModuleReference for TsReferenceTypeAssetReference {
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl ValueToString for TsReferenceTypeAssetReference { impl ValueToString for TsReferenceTypeAssetReference {
#[turbo_tasks::function] #[turbo_tasks::function]
async fn to_string(&self) -> Result<Vc<RcStr>> { async fn to_string(&self) -> Vc<RcStr> {
Ok(Vc::cell( Vc::cell(format!("typescript reference type comment {}", self.module,).into())
format!("typescript reference type comment {}", self.module,).into(),
))
} }
} }
...@@ -162,8 +162,8 @@ impl ChunkItem for EcmascriptModuleFacadeChunkItem { ...@@ -162,8 +162,8 @@ impl ChunkItem for EcmascriptModuleFacadeChunkItem {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn asset_ident(&self) -> Result<Vc<AssetIdent>> { fn asset_ident(&self) -> Vc<AssetIdent> {
Ok(self.module.ident()) self.module.ident()
} }
#[turbo_tasks::function] #[turbo_tasks::function]
......
...@@ -61,10 +61,10 @@ impl EcmascriptModuleFacadeModule { ...@@ -61,10 +61,10 @@ impl EcmascriptModuleFacadeModule {
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl Module for EcmascriptModuleFacadeModule { impl Module for EcmascriptModuleFacadeModule {
#[turbo_tasks::function] #[turbo_tasks::function]
fn ident(&self) -> Result<Vc<AssetIdent>> { fn ident(&self) -> Vc<AssetIdent> {
let inner = self.module.ident(); let inner = self.module.ident();
Ok(inner.with_part(self.ty)) inner.with_part(self.ty)
} }
#[turbo_tasks::function] #[turbo_tasks::function]
...@@ -135,10 +135,10 @@ impl Module for EcmascriptModuleFacadeModule { ...@@ -135,10 +135,10 @@ impl Module for EcmascriptModuleFacadeModule {
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl Asset for EcmascriptModuleFacadeModule { impl Asset for EcmascriptModuleFacadeModule {
#[turbo_tasks::function] #[turbo_tasks::function]
fn content(&self) -> Result<Vc<AssetContent>> { fn content(&self) -> Vc<AssetContent> {
let f = File::from(""); let f = File::from("");
Ok(AssetContent::file(FileContent::Content(f).cell())) AssetContent::file(FileContent::Content(f).cell())
} }
} }
...@@ -286,14 +286,14 @@ impl ChunkableModule for EcmascriptModuleFacadeModule { ...@@ -286,14 +286,14 @@ impl ChunkableModule for EcmascriptModuleFacadeModule {
fn as_chunk_item( fn as_chunk_item(
self: Vc<Self>, self: Vc<Self>,
chunking_context: Vc<Box<dyn ChunkingContext>>, chunking_context: Vc<Box<dyn ChunkingContext>>,
) -> Result<Vc<Box<dyn turbopack_core::chunk::ChunkItem>>> { ) -> Vc<Box<dyn turbopack_core::chunk::ChunkItem>> {
Ok(Vc::upcast( Vc::upcast(
EcmascriptModuleFacadeChunkItem { EcmascriptModuleFacadeChunkItem {
module: self, module: self,
chunking_context, chunking_context,
} }
.cell(), .cell(),
)) )
} }
} }
......
...@@ -83,8 +83,8 @@ impl ChunkItem for EcmascriptModuleLocalsChunkItem { ...@@ -83,8 +83,8 @@ impl ChunkItem for EcmascriptModuleLocalsChunkItem {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn asset_ident(&self) -> Result<Vc<AssetIdent>> { fn asset_ident(&self) -> Vc<AssetIdent> {
Ok(self.module.ident()) self.module.ident()
} }
#[turbo_tasks::function] #[turbo_tasks::function]
......
...@@ -41,10 +41,10 @@ impl EcmascriptModuleLocalsModule { ...@@ -41,10 +41,10 @@ impl EcmascriptModuleLocalsModule {
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl Module for EcmascriptModuleLocalsModule { impl Module for EcmascriptModuleLocalsModule {
#[turbo_tasks::function] #[turbo_tasks::function]
fn ident(&self) -> Result<Vc<AssetIdent>> { fn ident(&self) -> Vc<AssetIdent> {
let inner = self.module.ident(); let inner = self.module.ident();
Ok(inner.with_part(ModulePart::locals())) inner.with_part(ModulePart::locals())
} }
#[turbo_tasks::function] #[turbo_tasks::function]
...@@ -115,13 +115,13 @@ impl ChunkableModule for EcmascriptModuleLocalsModule { ...@@ -115,13 +115,13 @@ impl ChunkableModule for EcmascriptModuleLocalsModule {
fn as_chunk_item( fn as_chunk_item(
self: Vc<Self>, self: Vc<Self>,
chunking_context: Vc<Box<dyn ChunkingContext>>, chunking_context: Vc<Box<dyn ChunkingContext>>,
) -> Result<Vc<Box<dyn turbopack_core::chunk::ChunkItem>>> { ) -> Vc<Box<dyn turbopack_core::chunk::ChunkItem>> {
Ok(Vc::upcast( Vc::upcast(
EcmascriptModuleLocalsChunkItem { EcmascriptModuleLocalsChunkItem {
module: self, module: self,
chunking_context, chunking_context,
} }
.cell(), .cell(),
)) )
} }
} }
...@@ -44,27 +44,27 @@ impl EcmascriptParsable for EcmascriptModulePartAsset { ...@@ -44,27 +44,27 @@ impl EcmascriptParsable for EcmascriptModulePartAsset {
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) -> Result<Vc<ParseResult>> { fn parse_original(&self) -> Vc<ParseResult> {
Ok(self.full_module.parse_original()) self.full_module.parse_original()
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn ty(&self) -> Result<Vc<EcmascriptModuleAssetType>> { fn ty(&self) -> Vc<EcmascriptModuleAssetType> {
Ok(self.full_module.ty()) self.full_module.ty()
} }
} }
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl EcmascriptAnalyzable for EcmascriptModulePartAsset { impl EcmascriptAnalyzable for EcmascriptModulePartAsset {
#[turbo_tasks::function] #[turbo_tasks::function]
fn analyze(&self) -> Result<Vc<AnalyzeEcmascriptModuleResult>> { fn analyze(&self) -> Vc<AnalyzeEcmascriptModuleResult> {
let part = self.part; let part = self.part;
Ok(analyse_ecmascript_module(self.full_module, Some(part))) analyse_ecmascript_module(self.full_module, Some(part))
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn module_content_without_analysis(&self) -> Result<Vc<EcmascriptModuleContent>> { fn module_content_without_analysis(&self) -> Vc<EcmascriptModuleContent> {
Ok(self.full_module.module_content_without_analysis()) self.full_module.module_content_without_analysis()
} }
#[turbo_tasks::function] #[turbo_tasks::function]
...@@ -72,10 +72,9 @@ impl EcmascriptAnalyzable for EcmascriptModulePartAsset { ...@@ -72,10 +72,9 @@ impl EcmascriptAnalyzable for EcmascriptModulePartAsset {
&self, &self,
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>> { ) -> Vc<EcmascriptModuleContent> {
Ok(self self.full_module
.full_module .module_content(chunking_context, async_module_info)
.module_content(chunking_context, async_module_info))
} }
} }
...@@ -207,22 +206,22 @@ impl ChunkableModule for EcmascriptModulePartAsset { ...@@ -207,22 +206,22 @@ impl ChunkableModule for EcmascriptModulePartAsset {
fn as_chunk_item( fn as_chunk_item(
self: Vc<Self>, self: Vc<Self>,
chunking_context: Vc<Box<dyn ChunkingContext>>, chunking_context: Vc<Box<dyn ChunkingContext>>,
) -> Result<Vc<Box<dyn turbopack_core::chunk::ChunkItem>>> { ) -> Vc<Box<dyn turbopack_core::chunk::ChunkItem>> {
Ok(Vc::upcast( Vc::upcast(
EcmascriptModulePartChunkItem { EcmascriptModulePartChunkItem {
module: self, module: self,
chunking_context, chunking_context,
} }
.cell(), .cell(),
)) )
} }
} }
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl EcmascriptModulePartAsset { impl EcmascriptModulePartAsset {
#[turbo_tasks::function] #[turbo_tasks::function]
pub(super) fn analyze(&self) -> Result<Vc<AnalyzeEcmascriptModuleResult>> { pub(super) fn analyze(&self) -> Vc<AnalyzeEcmascriptModuleResult> {
Ok(analyze(self.full_module, self.part)) analyze(self.full_module, self.part)
} }
} }
...@@ -230,8 +229,8 @@ impl EcmascriptModulePartAsset { ...@@ -230,8 +229,8 @@ impl EcmascriptModulePartAsset {
fn analyze( fn analyze(
module: Vc<EcmascriptModuleAsset>, module: Vc<EcmascriptModuleAsset>,
part: Vc<ModulePart>, part: Vc<ModulePart>,
) -> Result<Vc<AnalyzeEcmascriptModuleResult>> { ) -> Vc<AnalyzeEcmascriptModuleResult> {
Ok(analyse_ecmascript_module(module, Some(part))) analyse_ecmascript_module(module, Some(part))
} }
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
......
...@@ -80,8 +80,8 @@ impl ChunkItem for EcmascriptModulePartChunkItem { ...@@ -80,8 +80,8 @@ impl ChunkItem for EcmascriptModulePartChunkItem {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn asset_ident(&self) -> Result<Vc<AssetIdent>> { fn asset_ident(&self) -> Vc<AssetIdent> {
Ok(self.module.ident()) self.module.ident()
} }
#[turbo_tasks::function] #[turbo_tasks::function]
......
...@@ -114,13 +114,13 @@ impl ModuleReference for WebpackChunkAssetReference { ...@@ -114,13 +114,13 @@ impl ModuleReference for WebpackChunkAssetReference {
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl ValueToString for WebpackChunkAssetReference { impl ValueToString for WebpackChunkAssetReference {
#[turbo_tasks::function] #[turbo_tasks::function]
async fn to_string(&self) -> Result<Vc<RcStr>> { async fn to_string(&self) -> Vc<RcStr> {
let chunk_id = match &self.chunk_id { let chunk_id = match &self.chunk_id {
Lit::Str(str) => str.value.to_string(), Lit::Str(str) => str.value.to_string(),
Lit::Num(num) => format!("{num}"), Lit::Num(num) => format!("{num}"),
_ => todo!(), _ => todo!(),
}; };
Ok(Vc::cell(format!("webpack chunk {}", chunk_id).into())) Vc::cell(format!("webpack chunk {}", chunk_id).into())
} }
} }
...@@ -147,8 +147,8 @@ impl ModuleReference for WebpackEntryAssetReference { ...@@ -147,8 +147,8 @@ impl ModuleReference for WebpackEntryAssetReference {
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl ValueToString for WebpackEntryAssetReference { impl ValueToString for WebpackEntryAssetReference {
#[turbo_tasks::function] #[turbo_tasks::function]
fn to_string(&self) -> Result<Vc<RcStr>> { fn to_string(&self) -> Vc<RcStr> {
Ok(Vc::cell("webpack entry".into())) Vc::cell("webpack entry".into())
} }
} }
......
...@@ -112,8 +112,8 @@ impl ChunkItem for WorkerLoaderChunkItem { ...@@ -112,8 +112,8 @@ impl ChunkItem for WorkerLoaderChunkItem {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn content_ident(&self) -> Result<Vc<AssetIdent>> { fn content_ident(&self) -> Vc<AssetIdent> {
Ok(self.module.ident()) self.module.ident()
} }
#[turbo_tasks::function] #[turbo_tasks::function]
......
...@@ -70,13 +70,13 @@ impl ChunkableModule for WorkerLoaderModule { ...@@ -70,13 +70,13 @@ impl ChunkableModule for WorkerLoaderModule {
fn as_chunk_item( fn as_chunk_item(
self: Vc<Self>, self: Vc<Self>,
chunking_context: Vc<Box<dyn ChunkingContext>>, chunking_context: Vc<Box<dyn ChunkingContext>>,
) -> Result<Vc<Box<dyn turbopack_core::chunk::ChunkItem>>> { ) -> Vc<Box<dyn turbopack_core::chunk::ChunkItem>> {
Ok(Vc::upcast( Vc::upcast(
WorkerLoaderChunkItem { WorkerLoaderChunkItem {
chunking_context, chunking_context,
module: self, module: self,
} }
.cell(), .cell(),
)) )
} }
} }
...@@ -66,11 +66,11 @@ impl ChunkableModule for JsonModuleAsset { ...@@ -66,11 +66,11 @@ impl ChunkableModule for JsonModuleAsset {
fn as_chunk_item( fn as_chunk_item(
self: Vc<Self>, self: Vc<Self>,
chunking_context: Vc<Box<dyn ChunkingContext>>, chunking_context: Vc<Box<dyn ChunkingContext>>,
) -> Result<Vc<Box<dyn turbopack_core::chunk::ChunkItem>>> { ) -> Vc<Box<dyn turbopack_core::chunk::ChunkItem>> {
Ok(Vc::upcast(JsonChunkItem::cell(JsonChunkItem { Vc::upcast(JsonChunkItem::cell(JsonChunkItem {
module: self, module: self,
chunking_context, chunking_context,
}))) }))
} }
} }
......
use anyhow::Result;
use turbo_tasks::Vc; use turbo_tasks::Vc;
use turbo_tasks_env::ProcessEnv; use turbo_tasks_env::ProcessEnv;
use turbo_tasks_fs::FileSystemPath; use turbo_tasks_fs::FileSystemPath;
...@@ -28,17 +27,17 @@ impl ExecutionContext { ...@@ -28,17 +27,17 @@ impl ExecutionContext {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn project_path(&self) -> Result<Vc<FileSystemPath>> { pub fn project_path(&self) -> Vc<FileSystemPath> {
Ok(self.project_path) self.project_path
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn chunking_context(&self) -> Result<Vc<Box<dyn ChunkingContext>>> { pub fn chunking_context(&self) -> Vc<Box<dyn ChunkingContext>> {
Ok(self.chunking_context) self.chunking_context
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn env(&self) -> Result<Vc<Box<dyn ProcessEnv>>> { pub fn env(&self) -> Vc<Box<dyn ProcessEnv>> {
Ok(self.env) self.env
} }
} }
...@@ -261,13 +261,13 @@ pub fn get_intermediate_asset( ...@@ -261,13 +261,13 @@ pub fn get_intermediate_asset(
chunking_context: Vc<Box<dyn ChunkingContext>>, chunking_context: Vc<Box<dyn ChunkingContext>>,
main_entry: Vc<Box<dyn Module>>, main_entry: Vc<Box<dyn Module>>,
other_entries: Vc<EvaluatableAssets>, other_entries: Vc<EvaluatableAssets>,
) -> Result<Vc<Box<dyn OutputAsset>>> { ) -> Vc<Box<dyn OutputAsset>> {
Ok(Vc::upcast(chunking_context.root_entry_chunk_group_asset( Vc::upcast(chunking_context.root_entry_chunk_group_asset(
chunking_context.chunk_path(main_entry.ident(), ".js".into()), chunking_context.chunk_path(main_entry.ident(), ".js".into()),
main_entry, main_entry,
OutputAssets::empty(), OutputAssets::empty(),
other_entries, other_entries,
))) ))
} }
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
......
use anyhow::Result;
use turbo_tasks::Vc; use turbo_tasks::Vc;
use turbo_tasks_fs::FileSystemPath; use turbo_tasks_fs::FileSystemPath;
use turbopack_core::issue::{Issue, IssueStage, OptionStyledString, StyledString}; use turbopack_core::issue::{Issue, IssueStage, OptionStyledString, StyledString};
...@@ -34,7 +33,7 @@ impl Issue for RenderingIssue { ...@@ -34,7 +33,7 @@ impl Issue for RenderingIssue {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
async fn detail(&self) -> Result<Vc<OptionStyledString>> { async fn detail(&self) -> Vc<OptionStyledString> {
let mut details = vec![]; let mut details = vec![];
if let Some(status) = self.status { if let Some(status) = self.status {
...@@ -45,7 +44,7 @@ impl Issue for RenderingIssue { ...@@ -45,7 +44,7 @@ impl Issue for RenderingIssue {
} }
} }
Ok(Vc::cell(Some(StyledString::Stack(details).cell()))) Vc::cell(Some(StyledString::Stack(details).cell()))
} }
// TODO parse stack trace into source location // TODO parse stack trace into source location
......
...@@ -71,8 +71,8 @@ pub struct NodeApiContentSource { ...@@ -71,8 +71,8 @@ pub struct NodeApiContentSource {
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl NodeApiContentSource { impl NodeApiContentSource {
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn get_pathname(&self) -> Result<Vc<RcStr>> { pub fn get_pathname(&self) -> Vc<RcStr> {
Ok(self.pathname) self.pathname
} }
} }
...@@ -174,14 +174,14 @@ impl Introspectable for NodeApiContentSource { ...@@ -174,14 +174,14 @@ impl Introspectable for NodeApiContentSource {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
async fn details(&self) -> Result<Vc<RcStr>> { async fn details(&self) -> Vc<RcStr> {
Ok(Vc::cell( Vc::cell(
format!( format!(
"base: {:?}\ntype: {:?}", "base: {:?}\ntype: {:?}",
self.base_segments, self.route_type self.base_segments, self.route_type
) )
.into(), .into(),
)) )
} }
#[turbo_tasks::function] #[turbo_tasks::function]
......
...@@ -99,8 +99,8 @@ pub struct NodeRenderContentSource { ...@@ -99,8 +99,8 @@ pub struct NodeRenderContentSource {
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl NodeRenderContentSource { impl NodeRenderContentSource {
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn get_pathname(&self) -> Result<Vc<RcStr>> { pub fn get_pathname(&self) -> Vc<RcStr> {
Ok(self.pathname) self.pathname
} }
} }
...@@ -263,14 +263,14 @@ impl Introspectable for NodeRenderContentSource { ...@@ -263,14 +263,14 @@ impl Introspectable for NodeRenderContentSource {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
async fn details(&self) -> Result<Vc<RcStr>> { async fn details(&self) -> Vc<RcStr> {
Ok(Vc::cell( Vc::cell(
format!( format!(
"base: {:?}\ntype: {:?}", "base: {:?}\ntype: {:?}",
self.base_segments, self.route_type self.base_segments, self.route_type
) )
.into(), .into(),
)) )
} }
#[turbo_tasks::function] #[turbo_tasks::function]
......
...@@ -171,7 +171,7 @@ struct ProcessPostCssResult { ...@@ -171,7 +171,7 @@ struct ProcessPostCssResult {
async fn config_changed( async fn config_changed(
asset_context: Vc<Box<dyn AssetContext>>, asset_context: Vc<Box<dyn AssetContext>>,
postcss_config_path: Vc<FileSystemPath>, postcss_config_path: Vc<FileSystemPath>,
) -> Result<Vc<Completion>> { ) -> Vc<Completion> {
let config_asset = asset_context let config_asset = asset_context
.process( .process(
Vc::upcast(FileSource::new(postcss_config_path)), Vc::upcast(FileSource::new(postcss_config_path)),
...@@ -179,11 +179,11 @@ async fn config_changed( ...@@ -179,11 +179,11 @@ async fn config_changed(
) )
.module(); .module();
Ok(Vc::<Completions>::cell(vec![ Vc::<Completions>::cell(vec![
any_content_changed_of_module(config_asset), any_content_changed_of_module(config_asset),
extra_configs_changed(asset_context, postcss_config_path), extra_configs_changed(asset_context, postcss_config_path),
]) ])
.completed()) .completed()
} }
#[turbo_tasks::function] #[turbo_tasks::function]
...@@ -360,7 +360,7 @@ fn postcss_executor( ...@@ -360,7 +360,7 @@ fn postcss_executor(
asset_context: Vc<Box<dyn AssetContext>>, asset_context: Vc<Box<dyn AssetContext>>,
project_path: Vc<FileSystemPath>, project_path: Vc<FileSystemPath>,
postcss_config_path: Vc<FileSystemPath>, postcss_config_path: Vc<FileSystemPath>,
) -> Result<Vc<ProcessResult>> { ) -> Vc<ProcessResult> {
let config_asset = asset_context let config_asset = asset_context
.process( .process(
config_loader_source(project_path, postcss_config_path), config_loader_source(project_path, postcss_config_path),
...@@ -368,7 +368,7 @@ fn postcss_executor( ...@@ -368,7 +368,7 @@ fn postcss_executor(
) )
.module(); .module();
Ok(asset_context.process( asset_context.process(
Vc::upcast(VirtualSource::new( Vc::upcast(VirtualSource::new(
postcss_config_path.join("transform.ts".into()), postcss_config_path.join("transform.ts".into()),
AssetContent::File(embed_file("transforms/postcss.ts".into())).cell(), AssetContent::File(embed_file("transforms/postcss.ts".into())).cell(),
...@@ -376,7 +376,7 @@ fn postcss_executor( ...@@ -376,7 +376,7 @@ fn postcss_executor(
Value::new(ReferenceType::Internal(Vc::cell(indexmap! { Value::new(ReferenceType::Internal(Vc::cell(indexmap! {
"CONFIG".into() => config_asset "CONFIG".into() => config_asset
}))), }))),
)) )
} }
async fn find_config_in_location( async fn find_config_in_location(
......
...@@ -820,7 +820,7 @@ impl Issue for EvaluateErrorLoggingIssue { ...@@ -820,7 +820,7 @@ impl Issue for EvaluateErrorLoggingIssue {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn description(&self) -> Result<Vc<OptionStyledString>> { fn description(&self) -> Vc<OptionStyledString> {
fn fmt_args(prefix: String, args: &[JsonValue]) -> String { fn fmt_args(prefix: String, args: &[JsonValue]) -> String {
let mut iter = args.iter(); let mut iter = args.iter();
let Some(first) = iter.next() else { let Some(first) = iter.next() else {
...@@ -854,6 +854,6 @@ impl Issue for EvaluateErrorLoggingIssue { ...@@ -854,6 +854,6 @@ impl Issue for EvaluateErrorLoggingIssue {
} }
}) })
.collect::<Vec<_>>(); .collect::<Vec<_>>();
Ok(Vc::cell(Some(StyledString::Stack(lines).cell()))) Vc::cell(Some(StyledString::Stack(lines).cell()))
} }
} }
...@@ -363,8 +363,8 @@ impl ChunkingContext for NodeJsChunkingContext { ...@@ -363,8 +363,8 @@ impl ChunkingContext for NodeJsChunkingContext {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn chunk_item_id_from_ident(&self, ident: Vc<AssetIdent>) -> Result<Vc<ModuleId>> { fn chunk_item_id_from_ident(&self, ident: Vc<AssetIdent>) -> Vc<ModuleId> {
Ok(self.module_id_strategy.get_module_id(ident)) self.module_id_strategy.get_module_id(ident)
} }
#[turbo_tasks::function] #[turbo_tasks::function]
......
...@@ -41,8 +41,8 @@ impl EcmascriptBuildNodeChunk { ...@@ -41,8 +41,8 @@ impl EcmascriptBuildNodeChunk {
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl ValueToString for EcmascriptBuildNodeChunk { impl ValueToString for EcmascriptBuildNodeChunk {
#[turbo_tasks::function] #[turbo_tasks::function]
fn to_string(&self) -> Result<Vc<RcStr>> { fn to_string(&self) -> Vc<RcStr> {
Ok(Vc::cell("Ecmascript Build Node Chunk".into())) Vc::cell("Ecmascript Build Node Chunk".into())
} }
} }
......
...@@ -35,13 +35,13 @@ impl EcmascriptBuildNodeChunkContent { ...@@ -35,13 +35,13 @@ impl EcmascriptBuildNodeChunkContent {
chunking_context: Vc<NodeJsChunkingContext>, chunking_context: Vc<NodeJsChunkingContext>,
chunk: Vc<EcmascriptBuildNodeChunk>, chunk: Vc<EcmascriptBuildNodeChunk>,
content: Vc<EcmascriptChunkContent>, content: Vc<EcmascriptChunkContent>,
) -> Result<Vc<Self>> { ) -> Vc<Self> {
Ok(EcmascriptBuildNodeChunkContent { EcmascriptBuildNodeChunkContent {
content, content,
chunking_context, chunking_context,
chunk, chunk,
} }
.cell()) .cell()
} }
} }
......
...@@ -144,16 +144,16 @@ impl EcmascriptBuildNodeEntryChunk { ...@@ -144,16 +144,16 @@ impl EcmascriptBuildNodeEntryChunk {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn runtime_chunk(&self) -> Result<Vc<EcmascriptBuildNodeRuntimeChunk>> { fn runtime_chunk(&self) -> Vc<EcmascriptBuildNodeRuntimeChunk> {
Ok(EcmascriptBuildNodeRuntimeChunk::new(self.chunking_context)) EcmascriptBuildNodeRuntimeChunk::new(self.chunking_context)
} }
} }
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl ValueToString for EcmascriptBuildNodeEntryChunk { impl ValueToString for EcmascriptBuildNodeEntryChunk {
#[turbo_tasks::function] #[turbo_tasks::function]
fn to_string(&self) -> Result<Vc<RcStr>> { fn to_string(&self) -> Vc<RcStr> {
Ok(Vc::cell("Ecmascript Build Node Evaluate Chunk".into())) Vc::cell("Ecmascript Build Node Evaluate Chunk".into())
} }
} }
......
...@@ -91,8 +91,8 @@ impl EcmascriptBuildNodeRuntimeChunk { ...@@ -91,8 +91,8 @@ impl EcmascriptBuildNodeRuntimeChunk {
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl ValueToString for EcmascriptBuildNodeRuntimeChunk { impl ValueToString for EcmascriptBuildNodeRuntimeChunk {
#[turbo_tasks::function] #[turbo_tasks::function]
fn to_string(&self) -> Result<Vc<RcStr>> { fn to_string(&self) -> Vc<RcStr> {
Ok(Vc::cell("Ecmascript Build Node Runtime Chunk".into())) Vc::cell("Ecmascript Build Node Runtime Chunk".into())
} }
} }
......
...@@ -519,11 +519,8 @@ impl Issue for TsConfigIssue { ...@@ -519,11 +519,8 @@ impl Issue for TsConfigIssue {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn title(&self) -> Result<Vc<StyledString>> { fn title(&self) -> Vc<StyledString> {
Ok( StyledString::Text("An issue occurred while parsing a tsconfig.json file.".into()).cell()
StyledString::Text("An issue occurred while parsing a tsconfig.json file.".into())
.cell(),
)
} }
#[turbo_tasks::function] #[turbo_tasks::function]
......
use anyhow::Result;
use turbo_tasks::Vc; use turbo_tasks::Vc;
use turbo_tasks_fs::FileSystemPath; use turbo_tasks_fs::FileSystemPath;
use turbopack_core::{ use turbopack_core::{
...@@ -31,8 +30,8 @@ impl FixedStaticAsset { ...@@ -31,8 +30,8 @@ impl FixedStaticAsset {
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl OutputAsset for FixedStaticAsset { impl OutputAsset for FixedStaticAsset {
#[turbo_tasks::function] #[turbo_tasks::function]
fn ident(&self) -> Result<Vc<AssetIdent>> { fn ident(&self) -> Vc<AssetIdent> {
Ok(AssetIdent::from_path(self.output_path)) AssetIdent::from_path(self.output_path)
} }
} }
......
...@@ -60,11 +60,8 @@ impl StaticModuleAsset { ...@@ -60,11 +60,8 @@ impl StaticModuleAsset {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn static_asset( fn static_asset(&self, chunking_context: Vc<Box<dyn ChunkingContext>>) -> Vc<StaticAsset> {
&self, StaticAsset::new(chunking_context, self.source)
chunking_context: Vc<Box<dyn ChunkingContext>>,
) -> Result<Vc<StaticAsset>> {
Ok(StaticAsset::new(chunking_context, self.source))
} }
} }
...@@ -93,12 +90,12 @@ impl ChunkableModule for StaticModuleAsset { ...@@ -93,12 +90,12 @@ impl ChunkableModule for StaticModuleAsset {
fn as_chunk_item( fn as_chunk_item(
self: Vc<Self>, self: Vc<Self>,
chunking_context: Vc<Box<dyn ChunkingContext>>, chunking_context: Vc<Box<dyn ChunkingContext>>,
) -> Result<Vc<Box<dyn turbopack_core::chunk::ChunkItem>>> { ) -> Vc<Box<dyn turbopack_core::chunk::ChunkItem>> {
Ok(Vc::upcast(ModuleChunkItem::cell(ModuleChunkItem { Vc::upcast(ModuleChunkItem::cell(ModuleChunkItem {
module: self, module: self,
chunking_context, chunking_context,
static_asset: self.static_asset(Vc::upcast(chunking_context)), static_asset: self.static_asset(Vc::upcast(chunking_context)),
}))) }))
} }
} }
......
...@@ -62,9 +62,7 @@ pub(crate) async fn instantiating_loader_source( ...@@ -62,9 +62,7 @@ pub(crate) async fn instantiating_loader_source(
/// Create a javascript loader to compile the WebAssembly module and export it /// Create a javascript loader to compile the WebAssembly module and export it
/// without instantiating. /// without instantiating.
#[turbo_tasks::function] #[turbo_tasks::function]
pub(crate) fn compiling_loader_source( pub(crate) fn compiling_loader_source(source: Vc<WebAssemblySource>) -> Vc<Box<dyn Source>> {
source: Vc<WebAssemblySource>,
) -> Result<Vc<Box<dyn Source>>> {
let code: RcStr = formatdoc! { let code: RcStr = formatdoc! {
r#" r#"
import wasmPath from "WASM_PATH"; import wasmPath from "WASM_PATH";
...@@ -76,8 +74,8 @@ pub(crate) fn compiling_loader_source( ...@@ -76,8 +74,8 @@ pub(crate) fn compiling_loader_source(
} }
.into(); .into();
Ok(Vc::upcast(VirtualSource::new( Vc::upcast(VirtualSource::new(
source.ident().path().append("_.loader.mjs".into()), source.ident().path().append("_.loader.mjs".into()),
AssetContent::file(File::from(code).into()), AssetContent::file(File::from(code).into()),
))) ))
} }
...@@ -136,14 +136,14 @@ impl ChunkableModule for WebAssemblyModuleAsset { ...@@ -136,14 +136,14 @@ impl ChunkableModule for WebAssemblyModuleAsset {
fn as_chunk_item( fn as_chunk_item(
self: Vc<Self>, self: Vc<Self>,
chunking_context: Vc<Box<dyn ChunkingContext>>, chunking_context: Vc<Box<dyn ChunkingContext>>,
) -> Result<Vc<Box<dyn turbopack_core::chunk::ChunkItem>>> { ) -> Vc<Box<dyn turbopack_core::chunk::ChunkItem>> {
Ok(Vc::upcast( Vc::upcast(
ModuleChunkItem { ModuleChunkItem {
module: self, module: self,
chunking_context, chunking_context,
} }
.cell(), .cell(),
)) )
} }
} }
...@@ -192,13 +192,13 @@ impl ChunkItem for ModuleChunkItem { ...@@ -192,13 +192,13 @@ impl ChunkItem for ModuleChunkItem {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
fn references(&self) -> Result<Vc<ModuleReferences>> { fn references(&self) -> Vc<ModuleReferences> {
let loader = self let loader = self
.module .module
.loader() .loader()
.as_chunk_item(Vc::upcast(self.chunking_context)); .as_chunk_item(Vc::upcast(self.chunking_context));
Ok(loader.references()) loader.references()
} }
#[turbo_tasks::function] #[turbo_tasks::function]
......
use anyhow::Result;
use turbo_tasks::{RcStr, Vc}; use turbo_tasks::{RcStr, Vc};
use turbopack_core::{ use turbopack_core::{
asset::{Asset, AssetContent}, asset::{Asset, AssetContent},
...@@ -40,12 +39,12 @@ impl WebAssemblyAsset { ...@@ -40,12 +39,12 @@ impl WebAssemblyAsset {
#[turbo_tasks::value_impl] #[turbo_tasks::value_impl]
impl OutputAsset for WebAssemblyAsset { impl OutputAsset for WebAssemblyAsset {
#[turbo_tasks::function] #[turbo_tasks::function]
fn ident(&self) -> Result<Vc<AssetIdent>> { fn ident(&self) -> Vc<AssetIdent> {
let ident = self.source.ident().with_modifier(modifier()); let ident = self.source.ident().with_modifier(modifier());
let asset_path = self.chunking_context.chunk_path(ident, ".wasm".into()); let asset_path = self.chunking_context.chunk_path(ident, ".wasm".into());
Ok(AssetIdent::from_path(asset_path)) AssetIdent::from_path(asset_path)
} }
} }
......
...@@ -77,15 +77,15 @@ impl ChunkableModule for RawWebAssemblyModuleAsset { ...@@ -77,15 +77,15 @@ impl ChunkableModule for RawWebAssemblyModuleAsset {
fn as_chunk_item( fn as_chunk_item(
self: Vc<Self>, self: Vc<Self>,
chunking_context: Vc<Box<dyn ChunkingContext>>, chunking_context: Vc<Box<dyn ChunkingContext>>,
) -> Result<Vc<Box<dyn turbopack_core::chunk::ChunkItem>>> { ) -> Vc<Box<dyn turbopack_core::chunk::ChunkItem>> {
Ok(Vc::upcast( Vc::upcast(
RawModuleChunkItem { RawModuleChunkItem {
module: self, module: self,
chunking_context, chunking_context,
wasm_asset: self.wasm_asset(Vc::upcast(chunking_context)), wasm_asset: self.wasm_asset(Vc::upcast(chunking_context)),
} }
.cell(), .cell(),
)) )
} }
} }
......
...@@ -368,13 +368,13 @@ impl ModuleAssetContext { ...@@ -368,13 +368,13 @@ impl ModuleAssetContext {
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn module_options_context(&self) -> Result<Vc<ModuleOptionsContext>> { pub fn module_options_context(&self) -> Vc<ModuleOptionsContext> {
Ok(self.module_options_context) self.module_options_context
} }
#[turbo_tasks::function] #[turbo_tasks::function]
pub fn resolve_options_context(&self) -> Result<Vc<ResolveOptionsContext>> { pub fn resolve_options_context(&self) -> Vc<ResolveOptionsContext> {
Ok(self.resolve_options_context) self.resolve_options_context
} }
#[turbo_tasks::function] #[turbo_tasks::function]
......
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