Skip to content

Preserve 'use client' directives #5161

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

Merged
merged 3 commits into from
Mar 20, 2023
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
"react-dom-17": "npm:react-dom@^17.0.2",
"rimraf": "^3.0.2",
"rollup": "^2.70.2",
"rollup-plugin-preserve-directives": "0.1.0",
"rollup-plugin-size": "^0.2.2",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-visualizer": "^5.6.0",
Expand Down
1 change: 1 addition & 0 deletions packages/react-query/src/errorBoundaryUtils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client'
import type {
DefaultedQueryObserverOptions,
Query,
Expand Down
1 change: 1 addition & 0 deletions packages/react-query/src/reactBatchedUpdates.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
'use client'
import * as ReactDOM from 'react-dom'
export const unstable_batchedUpdates = ReactDOM.unstable_batchedUpdates
1 change: 1 addition & 0 deletions packages/react-query/src/useBaseQuery.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client'
import * as React from 'react'
import { useSyncExternalStore } from './useSyncExternalStore'

Expand Down
1 change: 1 addition & 0 deletions packages/react-query/src/useInfiniteQuery.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client'
import type {
QueryObserver,
QueryFunction,
Expand Down
1 change: 1 addition & 0 deletions packages/react-query/src/useIsFetching.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client'
import * as React from 'react'
import type { QueryKey, QueryFilters } from '@tanstack/query-core'
import { notifyManager, parseFilterArgs } from '@tanstack/query-core'
Expand Down
1 change: 1 addition & 0 deletions packages/react-query/src/useIsMutating.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client'
import * as React from 'react'
import { useSyncExternalStore } from './useSyncExternalStore'

Expand Down
1 change: 1 addition & 0 deletions packages/react-query/src/useMutation.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client'
import * as React from 'react'
import { useSyncExternalStore } from './useSyncExternalStore'

Expand Down
1 change: 1 addition & 0 deletions packages/react-query/src/useQueries.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client'
import * as React from 'react'
import { useSyncExternalStore } from './useSyncExternalStore'

Expand Down
1 change: 1 addition & 0 deletions packages/react-query/src/useQuery.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client'
import type { QueryFunction, QueryKey } from '@tanstack/query-core'
import { parseQueryArgs, QueryObserver } from '@tanstack/query-core'
import type {
Expand Down
1 change: 1 addition & 0 deletions packages/react-query/src/useSyncExternalStore.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client'
// Temporary workaround due to an issue with react-native uSES - https://github.com/TanStack/query/pull/3601
import { useSyncExternalStore as uSES } from 'use-sync-external-store/shim/index.js'

Expand Down
10 changes: 10 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import replace from '@rollup/plugin-replace'
import nodeResolve from '@rollup/plugin-node-resolve'
import commonJS from '@rollup/plugin-commonjs'
import path from 'path'
import preserveDirectives from 'rollup-plugin-preserve-directives'

type Options = {
input: string | string[]
Expand Down Expand Up @@ -285,6 +286,7 @@ function mjs({
commonJS(),
nodeResolve({ extensions: ['.ts', '.tsx', '.native.ts'] }),
forceDevEnv ? forceEnvPlugin('development') : undefined,
preserveDirectives(),
],
}
}
Expand Down Expand Up @@ -324,6 +326,7 @@ function esm({
commonJS(),
nodeResolve({ extensions: ['.ts', '.tsx', '.native.ts'] }),
forceDevEnv ? forceEnvPlugin('development') : undefined,
preserveDirectives(),
],
}
}
Expand Down Expand Up @@ -375,6 +378,7 @@ function cjs({
preventAssignment: true,
delimiters: ['', ''],
}),
preserveDirectives(),
],
}
}
Expand Down