Skip to content

transformInclude should ignore query parameters #6455

@lensbart

Description

@lensbart

Which package?

@formatjs/unplugin/vite

Describe the bug

React Router splits routes that export clientAction/clientLoader into virtual chunk modules (e.g. route.tsx?route-chunk=main). The formatjs unplugin's transformInclude filter rejects these IDs because they don’t end in .tsx, so defineMessage calls in those chunks never get their id injected.

To Reproduce

  • Have a project that uses both React Router and FormatJS

  • Have a vite config that includes both formatjs and reactRouter plugins

  • Don’t write ids in the application code, rely on FormatJS to insert these

  • Have a route that exports a clientLoader/clientAction

  • Create a production build (via the dev server, everything works as expected)

    plugins: [
      formatjs({
        idInterpolationPattern,
        removeDefaultMessage: true,
      }),
      reactRouter()
    ]
    

Expected behavior

FormatJS transform works regardless of React Router setup

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions