Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove "use client" and mark packages as client-only instead #5826

Merged
merged 2 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions .parcelrc-build

This file was deleted.

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ publish-nightly: build
yarn publish:nightly

build:
parcel build packages/@react-{spectrum,aria,stately}/*/ packages/@internationalized/{message,string,date,number}/ packages/react-aria-components --no-optimize --config .parcelrc-build
parcel build packages/@react-{spectrum,aria,stately}/*/ packages/@internationalized/{message,string,date,number}/ packages/react-aria-components --no-optimize
yarn lerna run prepublishOnly
for pkg in packages/@react-{spectrum,aria,stately}/*/ packages/@internationalized/{message,string,date,number}/ packages/@adobe/react-spectrum/ packages/react-aria/ packages/react-stately/ packages/react-aria-components/; \
do node scripts/buildEsm.js $$pkg; \
Expand Down
5 changes: 3 additions & 2 deletions packages/@adobe/react-spectrum/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
],
"sideEffects": false,
"scripts": {
"prepublishOnly": "mkdir -p dist; cp src/index.ts dist/types.d.ts; sed -i.bak 's/'\\''use client'\\'';//' dist/types.d.ts; rm dist/types.d.ts.bak; grep -v '^export type' src/index.ts > dist/module.js; babel --root-mode upward src/index.ts -o dist/main.js"
"prepublishOnly": "mkdir -p dist; cp src/index.ts dist/types.d.ts; grep -v '^export type' src/index.ts > dist/module.js; babel --root-mode upward src/index.ts -o dist/main.js"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -92,7 +92,8 @@
"@react-spectrum/well": "^3.4.9",
"@react-stately/collections": "^3.10.4",
"@react-stately/data": "^3.11.0",
"@react-types/shared": "^3.22.0"
"@react-types/shared": "^3.22.0",
"client-only": "^0.0.1"
},
"publishConfig": {
"access": "public"
Expand Down
4 changes: 3 additions & 1 deletion packages/@adobe/react-spectrum/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
* governing permissions and limitations under the License.
*/

'use client';
// Mark as a client only package. This will cause a build time error if you try
// to import it from a React Server Component in a framework like Next.js.
import 'client-only';

export {ActionGroup} from '@react-spectrum/actiongroup';
export {Badge} from '@react-spectrum/badge';
Expand Down
30 changes: 0 additions & 30 deletions packages/dev/parcel-optimizer-react-client/ReactClientOptimizer.js

This file was deleted.

12 changes: 0 additions & 12 deletions packages/dev/parcel-optimizer-react-client/package.json

This file was deleted.

1 change: 1 addition & 0 deletions packages/react-aria-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"@react-types/shared": "^3.22.0",
"@react-types/table": "^3.9.2",
"@swc/helpers": "^0.5.0",
"client-only": "^0.0.1",
"react-aria": "^3.31.1",
"react-stately": "^3.29.1",
"use-sync-external-store": "^1.2.0"
Expand Down
4 changes: 4 additions & 0 deletions packages/react-aria-components/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
* governing permissions and limitations under the License.
*/

// Mark as a client only package. This will cause a build time error if you try
// to import it from a React Server Component in a framework like Next.js.
import 'client-only';

export {Breadcrumbs, BreadcrumbsContext, Breadcrumb} from './Breadcrumbs';
export {Button, ButtonContext} from './Button';
export {Calendar, CalendarGrid, CalendarGridHeader, CalendarGridBody, CalendarHeaderCell, CalendarCell, RangeCalendar, CalendarContext, RangeCalendarContext, CalendarStateContext, RangeCalendarStateContext} from './Calendar';
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9165,6 +9165,11 @@ cli-width@^2.0.0:
resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.2.0.tgz#ff19ede8a9a5e579324147b0c11f0fbcbabed639"
integrity sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=

client-only@^0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/client-only/-/client-only-0.0.1.tgz#38bba5d403c41ab150bff64a95c85013cf73bca1"
integrity sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA==

clipanion@3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/clipanion/-/clipanion-3.1.0.tgz#3e217dd6476bb9236638b07eb4673f7309839819"
Expand Down