React "use client" directive with parceljs bundler
#9477
Unanswered
ar124officialwd
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Parceljsis unable to deal with"use client"directive. I've a monorepo (pnpm workspaces + turborepo).apps/webis dependent onpkgs/uithat includes UI components. Since components are all client side and need to access client side APIs, I need to add"use client"directive in my ui bundle file. Parcel bundler is misplacing the directive in output bundles, though the source filepkgs/ui/src/index.tshas used the directive at the top. Bundle has the directive somewhere at the bottom.How I may resolve this issue with minimal work (desireably if parcel could deal it on its side)?
Key considerations is dev / watch mode. When working in development mode with
turbo devthat will call all workspaces (apps/web pkgs/lib pkgs/ui) dev scripts - solution should work seamlessly when any of these gets rebuilt.I've posted same question on StackOverflow but couldn't gain an attention. Please see https://stackoverflow.com/questions/77781797/react-use-client-directive-with-parceljs-bundler
Source
pkgs/ui/src/index.tsBundle
pkgs/ui/dist/module.jsDesired Bundle
pkgs/ui/dist/module.jsBeta Was this translation helpful? Give feedback.
All reactions