Skip to content

v1.132.2 Rollup failed to resolve import "tanstack-start-injected-head-scripts:v" #5196

@frixou89

Description

@frixou89

Which project does this relate to?

Start

Describe the bug

Error during build on version 1.132.2.

error during build:
[vite]: Rollup failed to resolve import "tanstack-start-injected-head-scripts:v" from /node_modules/@tanstack/start-server-core/dist/esm/loadVirtualModule.js".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
`build.rollupOptions.external`
    at viteLog (file://node_modules/vite/dist/node/chunks/dep-D5b0Zz6C.js:33954:57)
    at file://node_modules/vite/dist/node/chunks/dep-D5b0Zz6C.js:33990:73
    at onwarn (file://node_modules/@vitejs/plugin-react/dist/index.js:55:7)
    at file://node_modules/vite/dist/node/chunks/dep-D5b0Zz6C.js:33990:28
    at onRollupLog (file://node_modules/vite/dist/node/chunks/dep-D5b0Zz6C.js:33985:63)
    at onLog (file://node_modules/vite/dist/node/chunks/dep-D5b0Zz6C.js:33786:4)
    at file://node_modules/rollup/dist/es/shared/node-entry.js:20936:32
    at Object.logger [as onLog] (file://node_modules/rollup/dist/es/shared/node-entry.js:22822:9)
    at ModuleLoader.handleInvalidResolvedId (file://node_modules/rollup/dist/es/shared/node-entry.js:21566:26)
    at ModuleLoader.resolveDynamicImport (file://node_modules/rollup/dist/es/shared/node-entry.js:21624:58)

[vite] (client) Pre-transform error: Failed to resolve import "tanstack-start-injected-head-scripts:v" from "../../node_modules/@tanstack/start-server-core/dist/esm/loadVirtualModule.js?v=7e60bb72". Does the file exist?
  Plugin: vite:import-analysis
  File: /home/frixou89/projects/fitable-trpc/node_modules/@tanstack/start-server-core/dist/esm/loadVirtualModule.js?v=7e60bb72:17:27
  7  |        return await import("tanstack-start-server-fn-manifest:v");
  8  |      case VIRTUAL_MODULES.injectedHeadScripts:
  9  |        return await import("tanstack-start-injected-head-scripts:v");
     |                            ^
  10 |      default:
  11 |        throw new Error(`Unknown virtual module: ${id}`); (x2)

Your Example Website or App

N/A

Steps to Reproduce the Bug or Issue

__root.tsx

function RootComponent() {
  const { locale } = Route.useRouteContext();

  return (
      <RootDocument locale={locale}>
        <Outlet />
      </RootDocument>
  );
}

---
function RootDocument({
  children,
  locale,
}: Readonly<{ children: ReactNode; locale: string }>) {
  return (
    <html className="h-full" lang={locale}>
      <head>
        <HeadContent />
      </head>
      <body className="h-full">
        {children}
        <ReactQueryDevtools position="bottom" buttonPosition="bottom-right" />
        <Scripts />
      </body>
    </html>
  );
}

router.tsx

export function getRouter() {
  const router = createTanStackRouter({
    routeTree: routeTree,
    scrollRestoration: true,
    defaultPreloadStaleTime: 0,
    context: {
      queryClient,
      session: null,
    },
    defaultNotFoundComponent: () => <PageNotFound />,
    defaultErrorComponent: (props) => <PageError {...props} />,
    Wrap: ({ children }) => (
      <QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
    ),
  });

  return router;
}

Expected behavior

Should work as described in docs and starter app.

If I remove <Scripts /> from the RootDocument component then I get no errors on development but I do on vite build.

Screenshots or Videos

No response

Platform

  • Router / Start Version: 1.132.2
  • OS: Windows (WSL)
  • Browser: Chrome
  • Bundler: vite
  • Bundler Version: 7.1.6

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions