Skip to content

[transform-imports] Query-suffixed module IDs are skipped by the transform filter #151

Open

Description

@Andresuito

Related package

@rolldown/plugin-transform-imports 0.1.2

Bug

The transform hook's ID filter (/\.[jt]sx?$/) skips JavaScript/TypeScript module IDs with query suffixes. TanStack Router's split routes use IDs such as route.tsx?tsr-split=component, so their imports remain pointed at the original barrel even when the plugin is configured.

In a Vite application using Tabler icons this leaves the LARGE_BARREL_MODULES warning and unnecessary barrel resolution in the client build. The issue can be reproduced with Rolldown alone; no TanStack, Vite, or icon library is required.

Minimal reproduction

In an empty directory:

npm init -y
npm install @rolldown/plugin-transform-imports@0.1.2 rolldown@1.2.9
# Save the following script as repro.mjs
node repro.mjs
import assert from 'node:assert/strict';
import { rolldown } from 'rolldown';
import transformImports from '@rolldown/plugin-transform-imports';

for (const id of ['/entry.tsx', '/entry.tsx?tsr-split=component']) {
  const bundle = await rolldown({
    input: id,
    external: (source) => source === 'icons' || source.startsWith('icons/'),
    plugins: [
      {
        name: 'virtual-entry',
        resolveId(source) { if (source === id) return source; },
        load(source) {
          if (source === id) return 'import { IconCheck } from "icons"; console.log(IconCheck);';
        },
      },
      transformImports({ icons: { transform: 'icons/{{member}}.js' } }),
    ],
  });
  const { output } = await bundle.generate({ format: 'esm' });
  await bundle.close();
  console.log(id, output[0].imports);
  assert.deepEqual(output[0].imports, ['icons/IconCheck.js']);
}

Actual output:

/entry.tsx [ 'icons/IconCheck.js' ]
/entry.tsx?tsr-split=component [ 'icons' ]
AssertionError [ERR_ASSERTION]

Expected: both entries import icons/IconCheck.js.

Possible fix

Allow query suffixes in the transform hook ID filter, or match against the ID with its query removed. I tested a local filter change to /\.[jt]sx?(?:\?.*)?$/ in the original application and its client/server builds completed without the barrel warning. No patch is retained in the application.

A regression test for the query-suffixed entry above would cover the case.

Environment

  • macOS, arm64
  • Node.js 24.22.0
  • pnpm
  • @rolldown/plugin-transform-imports 0.1.2 (unmodified published package in the minimal reproduction)
  • rolldown 1.2.9

Searched existing issues for transform-imports query and transform-imports TanStack; no matching report found.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions