Skip to content

Turbopack Fails with ResourceQuery in Glob Pattern #79311

@iamnafets

Description

@iamnafets

Link to the code that reproduces this issue

https://github.com/iamnafets/next-resourcequery/tree/main/reproduction-app

To Reproduce

  1. Start the application with yarn dev --turbo
  2. Load up / note the Unknown module type error.
  3. Start the application with yarn dev
  4. Note no errors.

Current vs. Expected behavior

Turbopack doesn't appear to support glob patterns that include the resource query. While the loaders themselves have access to the resource query, the extension patterns do not.

So a loader like this:

  {
  /// ...
  turbopack: {
    rules: {
      "*\\?raw": {
        loaders: [require.resolve("./loader.js")],
        as: "*.js"
      },

      // This also doesn't work
      {
        "*.txt\\?raw": {
        loaders: [require.resolve("./loader.js")],
        as: "*.js"
      },

      // This doesn't work either and crashes turbopack
      "*?raw": {
        loaders: [require.resolve("./loader.js")],
        as: "*.js"
      }
      */
    }
  }
 }

Does not work.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.6.0: Fri Jul  5 17:56:15 PDT 2024; root:xnu-10063.141.1~2/RELEASE_ARM64_T6031
  Available memory (MB): 65536
  Available CPU cores: 16
Binaries:
  Node: 22.14.0
  npm: 10.9.2
  Yarn: 1.22.22
  pnpm: N/A
Relevant Packages:
  next: 15.4.0-canary.36 // Latest available version is detected (15.4.0-canary.36).
  eslint-config-next: N/A
  react: 19.1.0
  react-dom: 19.1.0
  typescript: 5.8.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Turbopack

Which stage(s) are affected? (Select all that apply)

next dev (local)

Additional context

There doesn't appear to be a workaround here. I thought I might be able to write a custom loader that would pitch, interrogate the resource query, and then grab the resource if it matched but I have no way to override the loaders and the data in pitch is an empty object.

PACK-4958

Metadata

Metadata

Assignees

No one assigned

    Labels

    TurbopackRelated to Turbopack with Next.js.linear: turbopackConfirmed issue that is tracked by the Turbopack team.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions