adobe / react-spectrum

A collection of libraries and tools that help you build adaptive, accessible, and robust user experiences.
https://react-spectrum.adobe.com
Apache License 2.0
12.73k stars 1.09k forks source link

(0 , $lislG$swchelperscjs_class_private_field_initcjs._) is not a function #7013

Closed Foxhoundn closed 3 weeks ago

Foxhoundn commented 3 weeks ago

Provide a general summary of the issue here

Hey,

We used react-aria in our own library https://github.com/qoretechnologies/reqore to create a date picker. It works fine in Storybook but when we incorporated it inside one of our products (https://github.com/qoretechnologies/qorus-ide) it crashes with the error (0 , $lislG$swchelperscjs_class_private_field_initcjs._) is not a function.

The product has pretty old infra, it's built on ejected create-react-app. There is also Storybook in the product repo, where it works just fine. It's only crashing when starting the dev server (or building for prod) from the create-react-app script.

๐Ÿค” Expected Behavior?

No error is thrown

๐Ÿ˜ฏ Current Behavior

(0 , $lislG$swchelperscjs_class_private_field_initcjs._) is not a function error is thrown

The whole stack:

TypeError: (0 , $lislG$swchelperscjs_class_private_field_initcjs._) is not a function
    at new $625ad1e1f4c43bc1$export$d3b7288e7994edea (CalendarDate.ts:303:1)
    at $4ae0260a69729f1d$export$1b96692a1ba042ac (conversion.ts:190:1)
    at $1f0f7ebf1ae6c530$export$461939dd4422153 (queries.ts:87:1)
    at $50d5d6a623389320$export$66aa2b09de4b1ea5 (utils.ts:224:1)
    at useDateFieldState.ts:183:1
    at mountState (react-dom.development.js:16986:1)
    at Object.useState (react-dom.development.js:17699:1)
    at useState (react.development.js:1622:1)
    at $596a1f0f523d6752$export$60e84778edff6d26 (useDateFieldState.ts:183:1)
    at DateField.tsx:228:1     

The _class_private_field_init.cjs is preset in node_modules/swc/helpers.

CleanShot 2024-09-09 at 11 01 20

๐Ÿ’ Possible Solution

I hope this is just a configuration (inside our Webpack) issue since it all works in 2 Storybooks (which also use Webpack)

๐Ÿ”ฆ Context

No response

๐Ÿ–ฅ๏ธ Steps to Reproduce

Steps to reproduce inside the app:

1) Clone https://github.com/qoretechnologies/qorus-ide 2) yarn install 3) yarn start

I've created a SWC React Spectrum bug interface where you can experience the bug behaviour

1) Navigate to localhost:3005 2) In the sidebar click Qogs 3) Search for SWC React Spectrum bug 4) Wait for the flow to load, then click on the blue Create Event state. 5) In the opened right panel, click Add Option (47) 6) Find Created and select it 7) Crash...

https://github.com/user-attachments/assets/ffe9fae9-50fe-4370-beff-0a05422a0911

Version

react-aria-components: ^1.2.0

What browsers are you seeing the problem on?

Chrome

If other, please specify.

No response

What operating system are you using?

MacOS & Linux

๐Ÿงข Your Company/Team

No response

๐Ÿ•ท Tracking Issue

No response

Foxhoundn commented 3 weeks ago

Fixed by adding cjs in every rule in the webpack config, sorry for spamming! :)