Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow to create internal modules via AssetContext #5095

Merged
merged 4 commits into from
May 26, 2023
Merged

Conversation

sokra
Copy link
Member

@sokra sokra commented May 25, 2023

Description

This allows to create an Module with inner asset via AssetContext.

This will also respect transitions.

This change allows use to use context.process(source, ReferenceType::Internal(inner_assets) instead of EcmascriptModuleAssetVc::new_with_inner_assets(..., ..., ..., ..., ..., inner_assets)

next.js PR: vercel/next.js#50338

@sokra sokra requested a review from a team as a code owner May 25, 2023 09:45
@vercel
Copy link

vercel bot commented May 25, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
examples-designsystem-docs 🔄 Building (Inspect) Visit Preview 💬 Add feedback May 25, 2023 9:15pm
examples-gatsby-web 🔄 Building (Inspect) Visit Preview 💬 Add feedback May 25, 2023 9:15pm
9 Ignored Deployments
Name Status Preview Comments Updated (UTC)
examples-basic-web ⬜️ Ignored (Inspect) Visit Preview May 25, 2023 9:15pm
examples-cra-web ⬜️ Ignored (Inspect) Visit Preview May 25, 2023 9:15pm
examples-kitchensink-blog ⬜️ Ignored (Inspect) Visit Preview May 25, 2023 9:15pm
examples-native-web ⬜️ Ignored (Inspect) Visit Preview May 25, 2023 9:15pm
examples-nonmonorepo ⬜️ Ignored (Inspect) Visit Preview May 25, 2023 9:15pm
examples-svelte-web ⬜️ Ignored (Inspect) Visit Preview May 25, 2023 9:15pm
examples-tailwind-web ⬜️ Ignored (Inspect) Visit Preview May 25, 2023 9:15pm
examples-vite-web ⬜️ Ignored (Inspect) Visit Preview May 25, 2023 9:15pm
turbo-site ⬜️ Ignored (Inspect) Visit Preview May 25, 2023 9:15pm

@github-actions
Copy link
Contributor

✅ This change can build next-swc

@github-actions
Copy link
Contributor

github-actions bot commented May 25, 2023

⚠️ CI failed ⚠️

The following steps have failed in CI:

  • Turbopack Rust tests (mac/win, non-blocking)

See workflow summary for details

@github-actions
Copy link
Contributor

Linux Benchmark for 8bcd5ce

Click to view benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 8373.48µs ± 70.58µs 8414.22µs ± 54.84µs +0.49%
bench_hmr_to_eval/Turbopack CSR/1000 modules 7513.19µs ± 33.82µs 7835.63µs ± 358.66µs +4.29%
bench_startup/Turbopack CSR/1000 modules 866.44ms ± 1.27ms 874.72ms ± 7.90ms +0.96%

@alexkirsz
Copy link
Contributor

Is there any reason for us to keep using EcmascriptModuleAssetVc::new_with_inner_assets directly, or should we make that method private and always use context.process instead?

@github-actions
Copy link
Contributor

Linux Benchmark for 4861425

Click to view benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 8516.06µs ± 68.17µs 8624.25µs ± 17.57µs +1.27%
bench_hmr_to_eval/Turbopack CSR/1000 modules 7593.23µs ± 50.64µs 7747.01µs ± 154.92µs +2.03%
bench_startup/Turbopack CSR/1000 modules 898.38ms ± 1.99ms 890.15ms ± 5.04ms -0.92%

@sokra
Copy link
Member Author

sokra commented May 25, 2023

Is there any reason for us to keep using EcmascriptModuleAssetVc::new_with_inner_assets directly, or should we make that method private and always use context.process instead?

We can't make them private as it's used from turbopack crate, where the ModuleAssetContext is implemented

@github-actions
Copy link
Contributor

Linux Benchmark for f1fc798

Test Base PR % Significant %
bench_startup/Turbopack CSR/1000 modules 881.26ms ± 1.36ms 902.46ms ± 8.52ms +2.40% +0.16%
Click to view full benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 8293.61µs ± 72.33µs 8010.49µs ± 71.40µs -3.41%
bench_hmr_to_eval/Turbopack CSR/1000 modules 7199.81µs ± 64.32µs 7469.21µs ± 375.96µs +3.74%
bench_startup/Turbopack CSR/1000 modules 881.26ms ± 1.36ms 902.46ms ± 8.52ms +2.40% +0.16%

use crate::{asset::AssetVc, resolve::ModulePartVc};

#[turbo_tasks::value(transparent)]
pub struct InnerAssets(IndexMap<String, AssetVc>);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add comments to these public structs, explaining why they exist.

@@ -133,6 +132,62 @@ struct MemoizedSuccessfulAnalysis {
exports: EcmascriptExportsReadRef,
}

pub struct EcmascriptModuleAssetBuilder {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment this public item and what each argument represents.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ReferenceType and *ReferenceSubType could #[derive(TaskInput)]. We never use them as Vc anyway.

@sokra sokra merged commit e8b8c0d into main May 26, 2023
42 of 44 checks passed
@sokra sokra deleted the sokra/dedupe-app-loader branch May 26, 2023 11:40
sokra added a commit to vercel/next.js that referenced this pull request May 27, 2023
### What?

create internal modules via `context.process` with
`ReferenceType::Internal`

### Why?

We need this for future refactoring where we want to the internal
modules with transitions.

### Turbopack Changes

* vercel/turbo#5095 <!-- Tobias Koppers - allow
to create internal modules via AssetContext -->
* vercel/turbo#5104 <!-- Alex Kirszenberg -
Stable chunk list ident -->
* vercel/turbo#5106 <!-- Tobias Koppers -
followup fix -->

---------

Co-authored-by: Alex Kirszenberg <alex.kirszenberg@vercel.com>
hydRAnger pushed a commit to hydRAnger/next.js that referenced this pull request Jun 12, 2023
### What?

create internal modules via `context.process` with
`ReferenceType::Internal`

### Why?

We need this for future refactoring where we want to the internal
modules with transitions.

### Turbopack Changes

* vercel/turbo#5095 <!-- Tobias Koppers - allow
to create internal modules via AssetContext -->
* vercel/turbo#5104 <!-- Alex Kirszenberg -
Stable chunk list ident -->
* vercel/turbo#5106 <!-- Tobias Koppers -
followup fix -->

---------

Co-authored-by: Alex Kirszenberg <alex.kirszenberg@vercel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants