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
-
Parceljs
is unable to deal with"use client"
directive. I've a monorepo (pnpm workspaces + turborepo).apps/web
is dependent onpkgs/ui
that 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.ts
has 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 dev
that 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.ts
Bundle
pkgs/ui/dist/module.js
Desired Bundle
pkgs/ui/dist/module.js
Beta Was this translation helpful? Give feedback.
All reactions