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
Which package?
@formatjs/unplugin/viteDescribe the bug
React Router splits routes that export
clientAction/clientLoaderinto virtual chunk modules (e.g.route.tsx?route-chunk=main). The formatjs unplugin'stransformIncludefilter rejects these IDs because they don’t end in.tsx, sodefineMessagecalls in those chunks never get theiridinjected.To Reproduce
Have a project that uses both React Router and FormatJS
Have a vite config that includes both
formatjsandreactRouterpluginsDon’t write
ids in the application code, rely on FormatJS to insert theseHave a route that exports a
clientLoader/clientActionCreate a production build (via the dev server, everything works as expected)
Expected behavior
FormatJS transform works regardless of React Router setup