Turbopack: add support for matching loaders on resource queries#88644
Turbopack: add support for matching loaders on resource queries#88644
Conversation
|
Allow CI Workflow Run
Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer |
|
Allow CI Workflow Run
Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer |
Failing test suitesCommit: 4bb3e1d | About building and testing Next.js
Expand output● Telemetry CLI › production mode › emits event when swc fails to load
Expand output● Error overlay - RSC build errors › Skipped in webpack › should handle successive HMR changes with errors correctly
Expand output● segment cache (revalidation) › re-fetch visible links after a navigation, if needed |
CodSpeed Performance ReportMerging this PR will not alter performanceComparing Summary
Footnotes
|
Stats from current PR✅ No significant changes detected📊 All Metrics📖 Metrics GlossaryDev Server Metrics:
Build Metrics:
Change Thresholds:
⚡ Dev Server
📦 Dev Server (Webpack) (Legacy)📦 Dev Server (Webpack)
⚡ Production Builds
📦 Production Builds (Webpack) (Legacy)📦 Production Builds (Webpack)
📦 Bundle SizesBundle Sizes⚡ TurbopackClient Main Bundles: **430 kB** → **430 kB** ✅ -82 B82 files with content-based hashes (individual files not comparable between builds) Server Middleware
Build DetailsBuild Manifests
📦 WebpackClient Main Bundles
Polyfills
Pages
Server Edge SSR
Middleware
Build DetailsBuild Manifests
Build Cache
🔄 Shared (bundler-independent)Runtimes
📝 Changed Files (2 files)Files with changes:
View diffspages-api.runtime.dev.jsDiff too large to display pages.runtime.dev.jsDiff too large to display |
|
@sokra As you could have read in the discussions this very issue links to, I had already implemented this weeks ago in #87291. I gotta say that it's quite disappointing to go through the effort of fixing a long-standing issue, only to not even get a review on the PR that was mentioned in all of the right places, including ones this PR doesn't. Feel free to close my PR, unless you can find something useful in it, still. For what it's worth, I agree with @bgw in that using exact string matching against query strings is essentially always the wrong choice, and should likely always be Overall I'm glad this finally got addressed, even at the cost of my own work getting discarded. |
|
@jwueller I'm very sorry about that. I didn't see your PR, but it looks good. I rebased it and got some value-able test, doc and performance improvements => #88801 I think we need to improve our workflow of handling PRs, but I don't really know how. We have >1k open PRs and github doesn't do the best job in making them discoverable... |
|
@sokra Thank you, I very much appreciate that! I'm happy to hear you got some mileage out of it still! And I understand that it's hard to keep track of literally over a thousand PRs, of course. I'm honestly not sure how I'd deal with that either. Looking at those other issue keys, I'm assuming you came at it from an internal issue tracker. That probably made surfacing related work in other places harder as well. |
|
Thanks for getting this over the line and huge thanks for @jwueller for the initial work. I've been waiting for this for almost 2 years now. @sokra, how can we load files with the default/internal file/url loader that |
|
@kevva I've been thinking about referencing internal loaders too, but that seems like a separate problem. Maybe we could have a "spread-like" placeholder for those, that can be inserted into custom loader arrays. As for URL loading, you can actually use this literal syntax with Turbopack, although I'm not sure if it's documented anywhere: new URL("./asset.png", import.meta.url)It gets replaced with the public URL during compile. |
|
@kevva Ah right, because it avoids matching to begin with, so the defaults still apply. I guess that's a decent workaround. Interesting that the URL literal is only documented in the context of experimental URL imports. It worked for local paths for quite a while before that already, I'm pretty sure. |
|
This PR also adds |

What?
Part of PACK-1007
Closes PACK-4958
Closes #79311
Adds
condition.querysupport to Turbopack's loader rules, enabling loaders to match based on import query strings (e.g.,import './file?raw'). This mirrors webpack'sresourceQueryfunctionality.The
querycondition accepts either a string (exact match) or RegExp (pattern match).Adds tests and documentation for the new
condition.queryoption.How to use