Skip to content

Some server-side modules incorrectly bundled into the client? #5738

Open
AmanVarshney01/create-better-t-stack
#690

Description

@wobsoriano

Which project does this relate to?

Start

Describe the bug

Starting with @tanstack/react-start@1.134.7, I think server-side modules are being incorrectly bundled into the client bundle. For example, in the Clerk SDK, this error shows up in the browser console when running dev server:

Uncaught (in promise) SyntaxError: The requested module '/node_modules/cookie/dist/index.js?v=d2ee33e7' does not provide an export named 'parse' (at chunk-CEKR2FXD.mjs?v=d2ee33e7:4283:10)Understand this error
client:865 

Likely related to #5717

Your Example Website or App

https://github.com/clerk/clerk-tanstack-react-start-quickstart/pull/6/files

Steps to Reproduce the Bug or Issue

  1. Clone the repo attached
  2. Switch to the cookie-module-leak branch
  3. Run npm run dev, see browser console

Expected behavior

Properly externalize server-side modules in client builds.

Screenshots or Videos

No response

Platform

  • Router / Start Version: 1.134.9
  • OS: [e.g. macOS, Windows, Linux]
  • Browser: [e.g. Chrome, Safari, Firefox]
  • Browser Version: [e.g. 91.1]
  • Bundler: Vite
  • Bundler Version: [e.g. 7.0.0]

Additional context

No response

Activity

  1. changed the title [-]cookie module leaking in client?[/-] [+]Some server-side modules incorrectly bundled into the client?[/+] on Nov 3, 2025
  2. mackattack3k commented on Nov 5, 2025

    @mackattack3k

    I'm getting this error for swr which is a dependency of Clerk.
    Uncaught (in promise) SyntaxError: The requested module 'http://localhost:3000/node_modules/use-sync-external-store/shim/index.js?v=f1295605' doesn't provide an export named: 'useSyncExternalStore'

    The index.js is for node_modules/swr/dist/index.mjs. Note that this is not imported by tanstack form but only clerk for me.

    $ bun why swr
    swr@2.3.4
      └─ @clerk/shared@3.31.0 (requires 2.3.4)
         ├─ @clerk/backend@2.19.3 (requires ^3.31.0)
         │  └─ @clerk/tanstack-react-start@0.26.7 (requires ^2.19.3)

    If I understand #5726 correctly it only affects tanstacks internal libraries and not others.

  3. JamalLyons commented on Nov 7, 2025

    @JamalLyons

    I'm getting this error for swr which is a dependency of Clerk. Uncaught (in promise) SyntaxError: The requested module 'http://localhost:3000/node_modules/use-sync-external-store/shim/index.js?v=f1295605' doesn't provide an export named: 'useSyncExternalStore'

    The index.js is for node_modules/swr/dist/index.mjs. Note that this is not imported by tanstack form but only clerk for me.

    $ bun why swr
    swr@2.3.4
    └─ @clerk/shared@3.31.0 (requires 2.3.4)
    ├─ @clerk/backend@2.19.3 (requires ^3.31.0)
    │ └─ @clerk/tanstack-react-start@0.26.7 (requires ^2.19.3)
    If I understand #5726 correctly it only affects tanstacks internal libraries and not others.

    I'm getting this same issue, and its coming from clerk. Did you find a fix?

  4. mackattack3k commented on Nov 7, 2025

    @mackattack3k

    I'm getting this error for swr which is a dependency of Clerk. Uncaught (in promise) SyntaxError: The requested module 'http://localhost:3000/node_modules/use-sync-external-store/shim/index.js?v=f1295605' doesn't provide an export named: 'useSyncExternalStore'
    The index.js is for node_modules/swr/dist/index.mjs. Note that this is not imported by tanstack form but only clerk for me.
    $ bun why swr
    swr@2.3.4
    └─ @clerk/shared@3.31.0 (requires 2.3.4)
    ├─ @clerk/backend@2.19.3 (requires ^3.31.0)
    │ └─ @clerk/tanstack-react-start@0.26.7 (requires ^2.19.3)
    If I understand #5726 correctly it only affects tanstacks internal libraries and not others.

    I'm getting this same issue, and its coming from clerk. Did you find a fix?

    I solved it now by using the same approach with optimizeDeps like the PR I linked.
    In my vite.config.ts I added these

    optimizeDeps: {
        include: ['@clerk/tanstack-react-start', 'cookie'],
      },
    

    One for the clerk issue with useSyncExternalStore and one for cookie which had an issue with parse import. Hope it works for you ✌️

  5. RadomirNowak commented on Nov 7, 2025

    @RadomirNowak

    I'm getting this error for swr which is a dependency of Clerk. Uncaught (in promise) SyntaxError: The requested module 'http://localhost:3000/node_modules/use-sync-external-store/shim/index.js?v=f1295605' doesn't provide an export named: 'useSyncExternalStore'

    The index.js is for node_modules/swr/dist/index.mjs. Note that this is not imported by tanstack form but only clerk for me.

    $ bun why swr
    swr@2.3.4
    └─ @clerk/shared@3.31.0 (requires 2.3.4)
    ├─ @clerk/backend@2.19.3 (requires ^3.31.0)
    │ └─ @clerk/tanstack-react-start@0.26.7 (requires ^2.19.3)
    If I understand #5726 correctly it only affects tanstacks internal libraries and not others.

    to me the fix was to rollback @tanstack/react-start to 1.134.6. Any other combinations of optimizeDeps and what not unfortunately did not work at all.

  6. jjrise commented on Nov 7, 2025

    @jjrise

    I can also confirm when using Clerk

  7. z4p5a9 commented on Nov 9, 2025

    @z4p5a9

    I'm getting this error for swr which is a dependency of Clerk. Uncaught (in promise) SyntaxError: The requested module 'http://localhost:3000/node_modules/use-sync-external-store/shim/index.js?v=f1295605' doesn't provide an export named: 'useSyncExternalStore'
    The index.js is for node_modules/swr/dist/index.mjs. Note that this is not imported by tanstack form but only clerk for me.
    $ bun why swr
    swr@2.3.4
    └─ @clerk/shared@3.31.0 (requires 2.3.4)
    ├─ @clerk/backend@2.19.3 (requires ^3.31.0)
    │ └─ @clerk/tanstack-react-start@0.26.7 (requires ^2.19.3)
    If I understand #5726 correctly it only affects tanstacks internal libraries and not others.

    to me the fix was to rollback @tanstack/react-start to 1.134.6. Any other combinations of optimizeDeps and what not unfortunately did not work at all.

    I have the same problem trying to use work os with start. Rolling back @tanstack/react-start to 1.134.6 fixed the issue also for me

  8. gbark commented on Nov 10, 2025

    @gbark

    Can also confirm that rolling back to 1.134.6 solved the issue

  9. DanielSintimbrean commented on Nov 10, 2025

    @DanielSintimbrean

    I'm getting this error for swr which is a dependency of Clerk. Uncaught (in promise) SyntaxError: The requested module 'http://localhost:3000/node_modules/use-sync-external-store/shim/index.js?v=f1295605' doesn't provide an export named: 'useSyncExternalStore'
    The index.js is for node_modules/swr/dist/index.mjs. Note that this is not imported by tanstack form but only clerk for me.
    $ bun why swr
    swr@2.3.4
    └─ @clerk/shared@3.31.0 (requires 2.3.4)
    ├─ @clerk/backend@2.19.3 (requires ^3.31.0)
    │ └─ @clerk/tanstack-react-start@0.26.7 (requires ^2.19.3)
    If I understand #5726 correctly it only affects tanstacks internal libraries and not others.

    I'm getting this same issue, and its coming from clerk. Did you find a fix?

    I solved it now by using the same approach with optimizeDeps like the PR I linked. In my vite.config.ts I added these

    optimizeDeps: {
        include: ['@clerk/tanstack-react-start', 'cookie'],
      },
    

    One for the clerk issue with useSyncExternalStore and one for cookie which had an issue with parse import. Hope it works for you ✌️

    With pnpm, I also had to add public-hoist-pattern[]=cookie to the .npmrc file.
    Tested in 1.134.18

  10. deleted a comment from alexi-build on Nov 14, 2025
  11. leonfs commented on Dec 8, 2025

    @leonfs

    has this been finally solved upstream?

  12. athammer commented on Dec 9, 2025

    @athammer

    Downgrading hasn't helped in my case, sadly. I've downgraded all the way down to 1.125.0 for Tanstack and 0.26.0 for Clerk. This appears to have happened when I introduced Clerk into Tanstack Start application.

    However, after following a bunch of advice for both this and the other thread, I managed to get a bandaid fix working.

    For my vite.config.ts file I added:

      resolve: {
        alias: [
          {
            find: "use-sync-external-store/shim/index.js",
            replacement: "react",
          },
          {
            find: "cookie",
            replacement: "cookie-es",
          },
        ],
      },
    

    For my package.json file I added:
    "cookie-es": "^2.0.0",

    My versions are: (I've tested a lot of different versions and doesn't appear to matter tmk)

      # TanStack
      "@tanstack/react-form": ^1.27.1
      "@tanstack/react-query": ^5.90.12
      "@tanstack/react-query-devtools": ^5.91.1
      "@tanstack/react-router": ^1.140.0
      "@tanstack/react-router-devtools": ^1.140.0
      "@tanstack/react-router-ssr-query": ^1.140.0
      "@tanstack/react-start": ^1.140.0
      "@tanstack/react-table": ^8.21.3
    
      # Auth
      "@clerk/tanstack-react-start": ^0.27.8
    

    No other code changes needed on my end, and this seems to be the maximum changes needed, remove any of this (at least for me) and it seems to break sadly. Hope this helps someone!

  13. tedjames commented on Dec 22, 2025

    @tedjames

    Still an issue and I can confirm that rolling back to 1.134.4 seems to fix things for now.

  14. nikosdouvlis commented on Dec 24, 2025

    @nikosdouvlis

    Can confirm that the issue still exists - the server modules are incorrectly bundled into the client-side using @tanstack/react-start@1.142.5

  15. schiller-manuel commented on Dec 24, 2025

    @schiller-manuel
    Collaborator

    @nikosdouvlis please provide a reproducer

  16. arikark commented on Dec 25, 2025

    @arikark

    Add below to vite.config.ts:
    resolve: { alias: [ { find: "use-sync-external-store/shim/index.js", replacement: "react", }, { find: "cookie", replacement: "cookie-es", }, ], },

    "@tanstack/react-start": "^1.132.0",
    "@clerk/tanstack-react-start": "^0.27.8",

  17. wobsoriano commented on Jan 8, 2026

    @wobsoriano
    ContributorAuthor

    Add below to vite.config.ts: resolve: { alias: [ { find: "use-sync-external-store/shim/index.js", replacement: "react", }, { find: "cookie", replacement: "cookie-es", }, ], },

    "@tanstack/react-start": "^1.132.0", "@clerk/tanstack-react-start": "^0.27.8",

    You can update @clerk/tanstack-react-start to latest and remove the cookie-es replacement here. The cookie package is now bundled into the @clerk/backend package.

    PR updating the starter to have this temporary fix - #6341

  18. jjrise commented on Jan 9, 2026

    @jjrise

    yeah @wobsoriano I'm still getting this and have for months. It's becoming more of a problem because I have to have my tanstack start versions pinned and can't update. Seemingly a Clerk issue...

    Thanks for all the help.

    Uncaught (in promise) SyntaxError: The requested module '/@fs/acme/node_modules/.bun/use-sync-external-store@1.6.0+83d5fd7b249dbeef/node_modules/use-sync-external-store/shim/index.js?v=5fc99785' does not provide an export named 'useSyncExternalStore' (at index.mjs?v=5fc99785:2:10)
    
  19. wobsoriano commented on Jan 9, 2026

    @wobsoriano
    ContributorAuthor

    yeah @wobsoriano I'm still getting this and have for months. It's becoming more of a problem because I have to have my tanstack start versions pinned and can't update. Seemingly a Clerk issue...

    Thanks for all the help.

    Uncaught (in promise) SyntaxError: The requested module '/@fs/acme/node_modules/.bun/use-sync-external-store@1.6.0+83d5fd7b249dbeef/node_modules/use-sync-external-store/shim/index.js?v=5fc99785' does not provide an export named 'useSyncExternalStore' (at index.mjs?v=5fc99785:2:10)
    

    You can skip pinning versions and add the temporary fix! (ref)

  20. jjrise commented on Jan 10, 2026

    @jjrise

    yeah @wobsoriano I'm still getting this and have for months. It's becoming more of a problem because I have to have my tanstack start versions pinned and can't update. Seemingly a Clerk issue...
    Thanks for all the help.

    Uncaught (in promise) SyntaxError: The requested module '/@fs/acme/node_modules/.bun/use-sync-external-store@1.6.0+83d5fd7b249dbeef/node_modules/use-sync-external-store/shim/index.js?v=5fc99785' does not provide an export named 'useSyncExternalStore' (at index.mjs?v=5fc99785:2:10)
    

    You can skip pinning versions and add the temporary fix! (ref)

    the temporary fix being 0.27.14? If so, I still have this same error on that version too

  21. wobsoriano commented on Jan 11, 2026

    @wobsoriano
    ContributorAuthor

    @jjrise the alias here. There's an old, similar issue here.

    fwiw, we're removing SWR in favor of TanStack Query and that means this error will be gone as well.

  22. leonfs commented on Jan 19, 2026

    @leonfs

    @wobsoriano - has the SWR dependency been finally removed then? Are we safe to update to latest version without any of the patches mentioned above?

  23. wobsoriano commented on Jan 19, 2026

    @wobsoriano
    ContributorAuthor

    @leonfs SWR will be removed in the next Clerk SDKs major release. That's probably next month. For now you still need to patch use-sync-external-store

    // vite.config.ts
    resolve: { alias: [ { find: "use-sync-external-store/shim/index.js", replacement: "react", } ], }
  24. wobsoriano commented on Mar 4, 2026

    @wobsoriano
    ContributorAuthor

    Hi all 👋

    We released Clerk Core 3, which includes a migration from swr to @tanstack/react-query. This means the error described here is now resolved for Clerk users.

    I'm leaving the issue open, as it still applies to developers who are using libraries that depend on use-sync-external-store, like swr.

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions