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

add support for dynamic requests in require() and import() #7398

Merged
merged 5 commits into from
Feb 15, 2024

Conversation

sokra
Copy link
Member

@sokra sokra commented Feb 15, 2024

Description

Refactors PatternMatching to support a map of multiple matches by key. Based on the new RequestKey support for resolving.

Code Generation for require("./dir/"+ expr) will emit a map of __turbopack_lookup__({ "./a": () => ..., "./b": () => ... }, "./dir/" + expr).

The output format isn't really optimized yet, that's work for future PRs.

Testing Instructions

added a test case, enabled one previously skipped test case

Closes PACK-2512

Copy link

vercel bot commented Feb 15, 2024

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

Name Status Preview Comments Updated (UTC)
rust-docs ❌ Failed (Inspect) Feb 15, 2024 0:21am
10 Ignored Deployments
Name Status Preview Comments Updated (UTC)
examples-basic-web ⬜️ Ignored (Inspect) Visit Preview Feb 15, 2024 0:21am
examples-designsystem-docs ⬜️ Ignored (Inspect) Visit Preview Feb 15, 2024 0:21am
examples-gatsby-web ⬜️ Ignored (Inspect) Visit Preview Feb 15, 2024 0:21am
examples-kitchensink-blog ⬜️ Ignored (Inspect) Visit Preview Feb 15, 2024 0:21am
examples-native-web ⬜️ Ignored (Inspect) Visit Preview Feb 15, 2024 0:21am
examples-nonmonorepo ⬜️ Ignored (Inspect) Visit Preview Feb 15, 2024 0:21am
examples-svelte-web ⬜️ Ignored (Inspect) Visit Preview Feb 15, 2024 0:21am
examples-tailwind-web ⬜️ Ignored (Inspect) Visit Preview Feb 15, 2024 0:21am
examples-vite-web ⬜️ Ignored (Inspect) Visit Preview Feb 15, 2024 0:21am
turbo-site ⬜️ Ignored (Inspect) Visit Preview Feb 15, 2024 0:21am

Copy link
Contributor

github-actions bot commented Feb 15, 2024

🟢 Turbopack Benchmark CI successful 🟢

Thanks

Copy link
Contributor

github-actions bot commented Feb 15, 2024

⚠️ CI failed ⚠️

The following steps have failed in CI:

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

See workflow summary for details

Copy link
Contributor

✅ This change can build next-swc

@sokra sokra merged commit 509a4cb into main Feb 15, 2024
49 of 53 checks passed
@sokra sokra deleted the sokra/dynamc-requests branch February 15, 2024 14:12
sokra added a commit to vercel/next.js that referenced this pull request Feb 15, 2024
…#62092)

### What?

see vercel/turborepo#7398

### Turbopack Changes

* vercel/turborepo#7367 <!-- Tobias Koppers - add
custom_extensions to resolve options context -->
* vercel/turborepo#7398 <!-- Tobias Koppers - add
support for dynamic requests in require() and import() -->


Closes PACK-2513
if let Expr::Call(call_expr) = expr {
let args = std::mem::take(&mut call_expr.args);
*expr = match args.into_iter().next() {
Some(ExprOrSpread { expr, spread: None }) => pm.create_require(*expr),
Copy link
Contributor

Choose a reason for hiding this comment

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

Unfortunately I just noticed this now, but this looks very wrong, this should insert a string, not a require call

ForsakenHarmony pushed a commit to vercel/next.js that referenced this pull request Jul 25, 2024
…rborepo#7398)

### Description

Refactors `PatternMatching` to support a map of multiple matches by key.
Based on the new `RequestKey` support for resolving.

Code Generation for `require("./dir/"+ expr)` will emit a map of
`__turbopack_lookup__({ "./a": () => ..., "./b": () => ... }, "./dir/" +
expr)`.

The output format isn't really optimized yet, that's work for future
PRs.

### Testing Instructions

added a test case, enabled one previously skipped test case



Closes PACK-2512
ForsakenHarmony pushed a commit to vercel/next.js that referenced this pull request Jul 29, 2024
…rborepo#7398)

### Description

Refactors `PatternMatching` to support a map of multiple matches by key.
Based on the new `RequestKey` support for resolving.

Code Generation for `require("./dir/"+ expr)` will emit a map of
`__turbopack_lookup__({ "./a": () => ..., "./b": () => ... }, "./dir/" +
expr)`.

The output format isn't really optimized yet, that's work for future
PRs.

### Testing Instructions

added a test case, enabled one previously skipped test case



Closes PACK-2512
ForsakenHarmony pushed a commit to vercel/next.js that referenced this pull request Jul 29, 2024
…rborepo#7398)

### Description

Refactors `PatternMatching` to support a map of multiple matches by key.
Based on the new `RequestKey` support for resolving.

Code Generation for `require("./dir/"+ expr)` will emit a map of
`__turbopack_lookup__({ "./a": () => ..., "./b": () => ... }, "./dir/" +
expr)`.

The output format isn't really optimized yet, that's work for future
PRs.

### Testing Instructions

added a test case, enabled one previously skipped test case



Closes PACK-2512
ForsakenHarmony pushed a commit to vercel/next.js that referenced this pull request Aug 1, 2024
…rborepo#7398)

### Description

Refactors `PatternMatching` to support a map of multiple matches by key.
Based on the new `RequestKey` support for resolving.

Code Generation for `require("./dir/"+ expr)` will emit a map of
`__turbopack_lookup__({ "./a": () => ..., "./b": () => ... }, "./dir/" +
expr)`.

The output format isn't really optimized yet, that's work for future
PRs.

### Testing Instructions

added a test case, enabled one previously skipped test case



Closes PACK-2512
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.

2 participants