-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Description
Provide a general summary of the issue here
When using the styles macro in S2, I get this error: import_url.fileURLToPath is not a function
🤔 Expected Behavior?
The error should not be there
😯 Current Behavior
The style macro works correctly on node, but doesn't work on the client, because of a hydration error.
It's caused by importing modules such as fs, path, url, etc... which aren't available on the browser. Here's the trace:
TypeError: import_url.fileURLToPath is not a function
<anonymous> http://localhost:3000/node_modules/.vite/deps/@react-spectrum_s2_style.js?v=6db6415d:53
💁 Possible Solution
The issue seems to be here:
| const json = JSON.parse(fs.readFileSync(__dirname + '/../package.json', 'utf8')); |
Where you import the JSON file manually using fs, etc... instead of importing the package.json normally, as done for properties.json done just 2 lines above.
🔦 Context
No response
🖥️ Steps to Reproduce
Just install and use react spectrum in vite
Version
1.1.0
What browsers are you seeing the problem on?
Firefox
If other, please specify.
No response
What operating system are you using?
Linux
🧢 Your Company/Team
No response
🕷 Tracking Issue
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels