Skip to content

From Collection.mjs : use-sync-external-store/shim/index.js doesn't provide an export named: 'useSyncExternalStore' #6694

@ppoulard

Description

@ppoulard

Provide a general summary of the issue here

I wrote my first components almost like the ones supplied in react-aria (with vanilla css), and they worked in Storybook
But when imported in my big app made with vite (just starting with a little Tooltip) it just crashes

🤔 Expected Behavior?

It should not crash

😯 Current Behavior

Fatal error in the console, due to react-aria-components/dist/Collection.mjs :

Uncaught SyntaxError: The requested module 'https://localradar.inria.fr:3000/@fs/.../node_modules/use-sync-external-store/shim/index.js?v=0d8975ec' doesn't provide an export named: 'useSyncExternalStore' [Collection.mjs:4:9](https://localradar.inria.fr:3000/@fs/...node_modules/react-aria-components/dist/Collection.mjs?v=0d8975ec)
    React 11
        lazyInitializer
        mountLazyComponent
        beginWork
        callCallback2
        invokeGuardedCallbackDev
        invokeGuardedCallback
        beginWork$1
        performUnitOfWork
        workLoopConcurrent
        renderRootConcurrent
        performConcurrentWorkOnRoot
    workLoop scheduler.development.js:266
    flushWork scheduler.development.js:239
    performWorkUntilDeadline scheduler.development.js:533

💁 Possible Solution

Temporarily, I used the following config in vite :

// https://vitejs.dev/config/
export default defineConfig({
    resolve: {
        alias: [{
            find: 'use-sync-external-store/shim/index.js',
            replacement: 'react'
        }],
   } 
})

but I'm not sure whether it is reliable because I read somewhere in the docs that there was some specific stuff in the shim that are expected by react-aria

However, I don't intend to use react < 18

Thanks for your help

🔦 Context

No response

🖥️ Steps to Reproduce

It's a rather big app, so I have not a minimal test case, but it sounds like a typescript import incompability cjs from mjs due to use-sync-external-store/shim

Version

"react-aria-components": "1.2.1"

What browsers are you seeing the problem on?

Firefox

If other, please specify.

No response

What operating system are you using?

Mac OS 14.4.1 (23E224)

🧢 Your Company/Team

No response

🕷 Tracking Issue

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