radix-ui / primitives

Radix Primitives is an open-source UI component library for building high-quality, accessible design systems and web apps. Maintained by @workos.
https://radix-ui.com/primitives
MIT License
14.82k stars 717 forks source link

Module parse failed: Unexpected token (105:69) #2967

Closed Poem7200 closed 1 week ago

Poem7200 commented 1 week ago

Bug report

Current Behavior

In my project installed @radix-ui, 5 hours before I tried to reinstall dependencies. When running project, everything seems good, but when trying to running project in browser, here comes error listed below

截屏2024-06-21 14 20 28

Expected behavior

Running in browser successfully

Reproducible example

CodeSandbox Template

Suggested solution

Additional context

Your environment

Software Name(s) Version
Radix Package(s) @radix-ui/react-accordion 1.1.2
Radix Package(s) @radix-ui/react-checkbox 1.0.4
Radix Package(s) @radix-ui/react-dialog ^1.0.5
Radix Package(s) @radix-ui/react-direction ^1.0.1
Radix Package(s) @radix-ui/react-icons 1.3.0
Radix Package(s) @radix-ui/react-label 2.0.2
Radix Package(s) @radix-ui/react-navigation-menu ^1.1.4
Radix Package(s) @radix-ui/react-popover ^1.0.7
Radix Package(s) @radix-ui/react-portal ^1.0.4"
Radix Package(s) @radix-ui/react-radio-group ^1.1.3
Radix Package(s) @radix-ui/react-slider 1.1.2
Radix Package(s) @radix-ui/react-slot ^1.0.2
Radix Package(s) @radix-ui/react-tabs 1.0.4
Radix Package(s) @radix-ui/react-toast ^1.1.5
Radix Package(s) @radix-ui/themes ^2.0.3
React ^16.8 ^17.0 ^18.0
Browser Chrome 126.0.6478.62(arm64)
Assistive tech webpack 4.47.0
Assistive tech webpack-cli 4.4.0
Assistive tech webpack-dev-server ^4.15.1
Assistive tech webpack-node-externnals 3.0.0
Node v14.21.3
npm 6.14.18
Operating System macOS Sonoma 14.5
hanselninja commented 1 week ago

Having the same issue. Seems to have been introduced in the latest release. @Poem7200 I suggest using exact versions for now.

Poem7200 commented 1 week ago

Having the same issue. Seems to have been introduced in the latest release. @Poem7200 I suggest using exact versions for now.

Do you have any idea which exact version to use?

hanselninja commented 1 week ago

@Poem7200 should be fine with any version other than the latest one.

Poem7200 commented 1 week ago

@Poem7200 should be fine with any version other than the latest one.

I've tried two methods:

  1. update to latest version, @radix-ui/react-slot update to 1.1.0, and when trying npm ls @radix-ui/react-slot, all related dependencies all use version 1.1.0, but still don't work when running project and opening browser
  2. use exact version(listed above), but when trying to use some old version, some dependencies use @radix-ui/react-slot@1.1.0, it's strange and I think maybe author create some destructive upgrade

I have no idea about this issue……

hanselabreu commented 1 week ago

@Poem7200 are you using exact versions? For example, in your package.json remove the ^ from the dependencies like so: @radix-ui/react-slot: "1.1.0" instead of @radix-ui/react-slot: "^1.1.0". You can verify this by checking your yarn.lock or package-lock.json don't reference the latest version.

This is obviously just to unblock you, but essentially someone would have to look into this.

Poem7200 commented 1 week ago

@Poem7200 are you using exact versions? For example, in your package.json remove the ^ from the dependencies like so: @radix-ui/react-slot: "1.1.0" instead of @radix-ui/react-slot: "^1.1.0". You can verify this by checking your yarn.lock or package-lock.json don't reference the latest version.

yes I removed ^ and use versions listed above

hanselabreu commented 1 week ago

@Poem7200 check your package-lock.json you most likely have the latest release referenced.

Poem7200 commented 1 week ago

@Poem7200 check your package-lock.json you most likely have the latest release referenced.

actually each time I tried to reinstall dependencies, I clean node_modules and package-lock.json

vladmoroz commented 1 week ago

We had upgraded compilation targets to ES2020 in a recent release, and your Webpack setup seems to trip over the nullish coalescing operator, which has been supported across the board for a few years already.

You'll need to either upgrade your dev toolchain to support the modern syntax, or downgrade Radix to the previous versions. (And pin deps to exact versions).