Skip to content

Turbopack: resourceQuery from import isn't passed to loaders #69502

@fuma-nama

Description

@fuma-nama

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/5gxwzd

To Reproduce

  1. Copy test-loader.js into node_modules so it can be resolved by Turbopack correctly
  2. Run the app in dev mode
  3. The received resourceQuery will be printed to terminal

Current vs. Expected behavior

I imported the file with:

import file from "./test.mdx?test=hi"`

On my MDX loader, the received resourceQuery is always empty, even if query is set.

Normally, it should pass ?test=hi to the loader, same as Webpack.

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Sun Aug  6 20:05:33 UTC 2023
  Available memory (MB): 4102
  Available CPU cores: 2
Binaries:
  Node: 20.9.0
  npm: 9.8.1
  Yarn: 1.22.19
  pnpm: 8.10.2
Relevant Packages:
  next: 14.2.7 // Latest available version is detected (14.2.7).
  eslint-config-next: 14.1.0
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.3.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

I'm migrating Fumadocs to Turbopack.
For performance optimizations, I need to access the hash from resourceQuery:

import file from "./index.mdx?hash=0001"

Because the MDX loader bundles and executes the configuration file (TypeScript file) to obtain MDX options. To support auto-reload on the config file, every change to the config file will change the hash of MDX file import:

- import file from "./index.mdx?hash=0001"
+ import file from "./index.mdx?hash=0002"

Then, Turbopack will invoke MDX loaders again to re-compile the files. With the hash, we can determine if the config has updated, and reload the config if necessary.

Metadata

Metadata

Assignees

No one assigned

    Labels

    TurbopackRelated to Turbopack with Next.js.bugIssue was opened via the bug report template.linear: turbopackConfirmed issue that is tracked by the Turbopack team.locked

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions