Files
Tobias Koppers 7e9d7cbd60 Turbopack: add support for matching loaders on resource queries (#88644)
### What?

Part of  PACK-1007

Adds `condition.query` support to Turbopack's loader rules, enabling loaders to match based on import query strings (e.g., `import './file?raw'`). This mirrors webpack's `resourceQuery` functionality.

The `query` condition accepts either a string (exact match) or RegExp (pattern match).

Adds tests and documentation for the new `condition.query` option.

### How to use

```js
// next.config.js
module.exports = {
  turbopack: {
    rules: {
      '*.txt': [
        // String: exact match
        { condition: { query: '?raw' }, loaders: ['raw-loader'], as: '*.js' },
        // RegExp: pattern match  
        { condition: { query: /\?transform/ }, loaders: ['transform-loader'], as: '*.js' },
      ],
    },
  },
}
```
2026-01-16 21:12:37 +01:00

5 lines
138 B
JavaScript

module.exports = function upperLoader(source) {
const upper = source.toUpperCase()
return `export default ${JSON.stringify(upper)}`
}