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

feat(contextcondition): support InPath contextcondition #4521

Merged
merged 1 commit into from
Apr 18, 2023

Conversation

kwonoj
Copy link
Contributor

@kwonoj kwonoj commented Apr 10, 2023

Description

Attempt to close WEB-862.

Currently turbopack in next-swc applies all of moduleoptionscontext into any kind of internal assets. Current available contextcondition (ContextCondition::InDirectory) does not gives enough context to determine where it comes from, makes non trivial to determine if given context need to be treated differently.

I'm trying to workaround by supplying addtional context for the filesystemkind, and caller can use it for creating a new contextcondition. In case of turbopack, I assume any embedded assets in the binary won't be an external / user's. Next-swc will assign a new condition like vercel/next.js@canary...client-context-embedded-fs#diff-92086db0c6bc192f76dab5d612a562df8fddffea05244c1c00d58e7288879e11R213-R214.

Still bit unsure if this is a legit apporach or would be better way to go. PR is for the POC + further improvement based on the feedback.

Per review suggestion, this PR now supports InPath(FileSystemVc) as new condition instead.

@kwonoj kwonoj requested a review from a team as a code owner April 10, 2023 19:09
@vercel
Copy link

vercel bot commented Apr 10, 2023

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

Name Status Preview Comments Updated (UTC)
examples-vite-web 🔄 Building (Inspect) Apr 18, 2023 7:03am
turbo-site ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 18, 2023 7:03am
9 Ignored Deployments
Name Status Preview Comments Updated (UTC)
examples-basic-web ⬜️ Ignored (Inspect) Apr 18, 2023 7:03am
examples-cra-web ⬜️ Ignored (Inspect) Apr 18, 2023 7:03am
examples-designsystem-docs ⬜️ Ignored (Inspect) Apr 18, 2023 7:03am
examples-gatsby-web ⬜️ Ignored (Inspect) Apr 18, 2023 7:03am
examples-kitchensink-blog ⬜️ Ignored (Inspect) Apr 18, 2023 7:03am
examples-native-web ⬜️ Ignored (Inspect) Apr 18, 2023 7:03am
examples-nonmonorepo ⬜️ Ignored (Inspect) Apr 18, 2023 7:03am
examples-svelte-web ⬜️ Ignored (Inspect) Apr 18, 2023 7:03am
examples-tailwind-web ⬜️ Ignored (Inspect) Apr 18, 2023 7:03am

@github-actions
Copy link
Contributor

✅ This changes can build next-swc

@github-actions
Copy link
Contributor

github-actions bot commented Apr 10, 2023

🟢 CI successful 🟢

Thanks

crates/turbopack/src/condition.rs Show resolved Hide resolved
crates/turbopack/src/condition.rs Outdated Show resolved Hide resolved
crates/turbo-tasks-fs/src/lib.rs Outdated Show resolved Hide resolved
@github-actions
Copy link
Contributor

Benchmark for 51f96a4

Click to view benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 9843.14µs ± 43.01µs 9840.63µs ± 69.85µs -0.03%
bench_hmr_to_eval/Turbopack CSR/1000 modules 8805.89µs ± 50.46µs 8942.53µs ± 213.62µs +1.55%
bench_startup/Turbopack CSR/1000 modules 906.86ms ± 2.66ms 907.17ms ± 4.84ms +0.03%

@github-actions
Copy link
Contributor

Benchmark for 1802874

Click to view benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 9567.86µs ± 46.07µs 9718.38µs ± 70.59µs +1.57%
bench_hmr_to_eval/Turbopack CSR/1000 modules 8695.62µs ± 71.53µs 8759.11µs ± 194.78µs +0.73%
bench_startup/Turbopack CSR/1000 modules 882.17ms ± 2.13ms 881.96ms ± 3.85ms -0.02%

path.fs
.root()
.await
.map_or(false, |root| context.is_inside(&root))
Copy link
Member

Choose a reason for hiding this comment

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

This ignores the error here, but it's better to propagate the error upwards

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So change fn matches(...) -> bool signature to fn matches(..) -> Result<bool>?

@github-actions
Copy link
Contributor

Benchmark for b669582

Test Base PR % Significant %
bench_hmr_to_eval/Turbopack CSR/1000 modules 8007.04µs ± 37.34µs 8182.54µs ± 50.12µs +2.19% +0.01%
Click to view full benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 8996.35µs ± 57.54µs 9035.25µs ± 53.10µs +0.43%
bench_hmr_to_eval/Turbopack CSR/1000 modules 8007.04µs ± 37.34µs 8182.54µs ± 50.12µs +2.19% +0.01%
bench_startup/Turbopack CSR/1000 modules 871.64ms ± 1.43ms 874.58ms ± 4.23ms +0.34%

@kwonoj kwonoj force-pushed the context-condition-test branch from dd6b308 to b2dce94 Compare April 18, 2023 07:02
@sokra sokra changed the title feat(contextcondition): support filesystemkind contextcondition feat(contextcondition): support InPath contextcondition Apr 18, 2023
@kwonoj kwonoj added the pr: automerge Kodiak will merge these automatically after checks pass label Apr 18, 2023
@kodiakhq kodiakhq bot merged commit 75c5705 into main Apr 18, 2023
@kodiakhq kodiakhq bot deleted the context-condition-test branch April 18, 2023 07:14
@github-actions
Copy link
Contributor

Benchmark for 3f7a125

Click to view benchmark
Test Base PR % Significant %
bench_hmr_to_commit/Turbopack CSR/1000 modules 9502.85µs ± 85.70µs 9485.98µs ± 45.96µs -0.18%
bench_hmr_to_eval/Turbopack CSR/1000 modules 8557.28µs ± 72.98µs 8829.74µs ± 233.06µs +3.18%
bench_startup/Turbopack CSR/1000 modules 881.32ms ± 1.00ms 888.85ms ± 5.89ms +0.85%

sokra added a commit to vercel/next.js that referenced this pull request Apr 20, 2023
### What?

add support for blur placeholder generation to turbopack

add `StructuredImageModuleType` which is used with `ModuleType::Custom`
to allow importing an image as `{ url, width, height, blurDataURL,
blurWidth, blurHeight }`

in contrast to next.js with webpack this will also generate blur
placeholder in development instead of using a _next/image reference.
This should lead to more production-like experience (at the cost of a
little bit of compilation time).

turbo PR: vercel/turborepo#4621

### Why?

Turbopack was crashing on `placeholder="blur"` before.

fixes WEB-534

### Turbopack changes

* vercel/turborepo#4521 <!-- OJ Kwon -
feat(contextcondition): support InPath contextcondition -->
* vercel/turborepo#4601 <!-- Alex Kirszenberg -
Chunking Context Refactor pt. 3: Address PR comments from pt. 2 -->
* vercel/turborepo#4623 <!-- Tobias Koppers -
exclude turborepo from turbopack bench tests -->
* vercel/turborepo#4399 <!-- Leah - support
require.context -->
* vercel/turborepo#4610 <!-- OJ Kwon - test(subset):
add mdx test into subset -->
* vercel/turborepo#4624 <!-- Tobias Koppers - run
benchmarks on windows and macOS too -->
* vercel/turborepo#4620 <!-- Alex Kirszenberg - Make
ContainmentTree fully generic -->
* vercel/turborepo#4600 <!-- Tobias Koppers - add
getChunkPath method -->
* vercel/turborepo#4621 <!-- Tobias Koppers - add
turbopack-image -->
* vercel/turborepo#4639 <!-- Tobias Koppers -
restrict snapshot path for windows path length limit -->
* vercel/turborepo#4641 <!-- Tobias Koppers - put
webp behind a feature flag -->
NicholasLYang pushed a commit to NicholasLYang/turbo that referenced this pull request Apr 21, 2023
### Description

Attempt to close WEB-862.

Currently turbopack in next-swc applies all of moduleoptionscontext into
any kind of internal assets. Current available contextcondition
(`ContextCondition::InDirectory`) does not gives enough context to
determine where it comes from, makes non trivial to determine if given
context need to be treated differently.

~I'm trying to workaround by supplying addtional context for the
filesystemkind, and caller can use it for creating a new
contextcondition. In case of turbopack, I assume any embedded assets in
the binary won't be an external / user's. Next-swc will assign a new
condition like
vercel/next.js@canary...client-context-embedded-fs#diff-92086db0c6bc192f76dab5d612a562df8fddffea05244c1c00d58e7288879e11R213-R214.~

~Still bit unsure if this is a legit apporach or would be better way to
go. PR is for the POC + further improvement based on the feedback.~

Per review suggestion, this PR now supports `InPath(FileSystemVc)` as
new condition instead.
kodiakhq bot pushed a commit to vercel/next.js that referenced this pull request May 2, 2023
### What?
This is necessary changes for the WEB-862, however dependent to vercel/turborepo#4521.
ForsakenHarmony pushed a commit to vercel/next.js that referenced this pull request Jul 25, 2024
…repo#4521)

### Description

Attempt to close WEB-862.

Currently turbopack in next-swc applies all of moduleoptionscontext into
any kind of internal assets. Current available contextcondition
(`ContextCondition::InDirectory`) does not gives enough context to
determine where it comes from, makes non trivial to determine if given
context need to be treated differently.

~I'm trying to workaround by supplying addtional context for the
filesystemkind, and caller can use it for creating a new
contextcondition. In case of turbopack, I assume any embedded assets in
the binary won't be an external / user's. Next-swc will assign a new
condition like
canary...client-context-embedded-fs#diff-92086db0c6bc192f76dab5d612a562df8fddffea05244c1c00d58e7288879e11R213-R214.~

~Still bit unsure if this is a legit apporach or would be better way to
go. PR is for the POC + further improvement based on the feedback.~

Per review suggestion, this PR now supports `InPath(FileSystemVc)` as
new condition instead.
ForsakenHarmony pushed a commit to vercel/next.js that referenced this pull request Jul 29, 2024
…repo#4521)

### Description

Attempt to close WEB-862.

Currently turbopack in next-swc applies all of moduleoptionscontext into
any kind of internal assets. Current available contextcondition
(`ContextCondition::InDirectory`) does not gives enough context to
determine where it comes from, makes non trivial to determine if given
context need to be treated differently.

~I'm trying to workaround by supplying addtional context for the
filesystemkind, and caller can use it for creating a new
contextcondition. In case of turbopack, I assume any embedded assets in
the binary won't be an external / user's. Next-swc will assign a new
condition like
canary...client-context-embedded-fs#diff-92086db0c6bc192f76dab5d612a562df8fddffea05244c1c00d58e7288879e11R213-R214.~

~Still bit unsure if this is a legit apporach or would be better way to
go. PR is for the POC + further improvement based on the feedback.~

Per review suggestion, this PR now supports `InPath(FileSystemVc)` as
new condition instead.
ForsakenHarmony pushed a commit to vercel/next.js that referenced this pull request Aug 1, 2024
…repo#4521)

### Description

Attempt to close WEB-862.

Currently turbopack in next-swc applies all of moduleoptionscontext into
any kind of internal assets. Current available contextcondition
(`ContextCondition::InDirectory`) does not gives enough context to
determine where it comes from, makes non trivial to determine if given
context need to be treated differently.

~I'm trying to workaround by supplying addtional context for the
filesystemkind, and caller can use it for creating a new
contextcondition. In case of turbopack, I assume any embedded assets in
the binary won't be an external / user's. Next-swc will assign a new
condition like
canary...client-context-embedded-fs#diff-92086db0c6bc192f76dab5d612a562df8fddffea05244c1c00d58e7288879e11R213-R214.~

~Still bit unsure if this is a legit apporach or would be better way to
go. PR is for the POC + further improvement based on the feedback.~

Per review suggestion, this PR now supports `InPath(FileSystemVc)` as
new condition instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: automerge Kodiak will merge these automatically after checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants