Skip to content

Commit

Permalink
fix(svelte-query): ensure compatibility with NodeNext (#7825)
Browse files Browse the repository at this point in the history
* fix(svelte-query): ensure compatibility with NodeNext

* Same for devtools and persist-client
  • Loading branch information
lachlancollins authored Jul 31, 2024
1 parent 74f10b7 commit 01e63a5
Show file tree
Hide file tree
Showing 57 changed files with 108 additions and 108 deletions.
3 changes: 2 additions & 1 deletion packages/svelte-query-devtools/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"moduleResolution": "Bundler"
"module": "NodeNext",
"moduleResolution": "NodeNext"
},
"include": [
"src/**/*.js",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { createQuery } from '@tanstack/svelte-query'
import { sleep } from '../utils'
import { sleep } from '../utils.js'
import type { Writable } from 'svelte/store'
export let states: Writable<Array<string>>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script lang="ts">
import { createQuery } from '@tanstack/svelte-query'
import { sleep } from '../utils'
import { sleep } from '../utils.js'
import type { Writable } from 'svelte/store'
import type { StatusResult } from '../utils'
import type { StatusResult } from '../utils.js'
export let states: Writable<Array<StatusResult<string>>>
export let fetched: Writable<boolean>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import type { OmitKeyof, QueryClient } from '@tanstack/svelte-query'
import type { PersistQueryClientOptions } from '@tanstack/query-persist-client-core'
import type { Writable } from 'svelte/store'
import type { StatusResult } from '../utils'
import type { StatusResult } from '../utils.js'
export let queryClient: QueryClient
export let persistOptions: OmitKeyof<PersistQueryClientOptions, 'queryClient'>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script lang="ts">
import { createQuery } from '@tanstack/svelte-query'
import { sleep } from '../utils'
import { sleep } from '../utils.js'
import type { Writable } from 'svelte/store'
import type { StatusResult } from '../utils'
import type { StatusResult } from '../utils.js'
export let states: Writable<Array<StatusResult<string>>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import type { OmitKeyof, QueryClient } from '@tanstack/svelte-query'
import type { PersistQueryClientOptions } from '@tanstack/query-persist-client-core'
import type { Writable } from 'svelte/store'
import type { StatusResult } from '../utils'
import type { StatusResult } from '../utils.js'
export let queryClient: QueryClient
export let persistOptions: OmitKeyof<PersistQueryClientOptions, 'queryClient'>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { createQuery } from '@tanstack/svelte-query'
import { sleep } from '../utils'
import { sleep } from '../utils.js'
const query = createQuery({
queryKey: ['test'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import InitialData from './InitialData/Provider.svelte'
import RemoveCache from './RemoveCache/Provider.svelte'
import RestoreCache from './RestoreCache/Provider.svelte'
import UseQueries from './UseQueries/Provider.svelte'
import { createQueryClient, sleep } from './utils'
import { createQueryClient, sleep } from './utils.js'

import type {
PersistedClient,
Persister,
} from '@tanstack/query-persist-client-core'
import type { Writable } from 'svelte/store'
import type { StatusResult } from './utils'
import type { StatusResult } from './utils.js'

const createMockPersister = (): Persister => {
let storedState: PersistedClient | undefined
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { createQuery } from '@tanstack/svelte-query'
import { sleep } from '../utils'
import { sleep } from '../utils.js'
const query = createQuery({
queryKey: ['test'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import type { OmitKeyof, QueryClient } from '@tanstack/svelte-query'
import type { PersistQueryClientOptions } from '@tanstack/query-persist-client-core'
import type { Writable } from 'svelte/store'
import type { StatusResult } from '../utils'
import type { StatusResult } from '../utils.js'
export let queryClient: QueryClient
export let persistOptions: OmitKeyof<PersistQueryClientOptions, 'queryClient'>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script lang="ts">
import { createQuery } from '@tanstack/svelte-query'
import { sleep } from '../utils'
import { sleep } from '../utils.js'
import type { Writable } from 'svelte/store'
import type { StatusResult } from '../utils'
import type { StatusResult } from '../utils.js'
export let states: Writable<Array<StatusResult<string>>>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import type { OmitKeyof, QueryClient } from '@tanstack/svelte-query'
import type { PersistQueryClientOptions } from '@tanstack/query-persist-client-core'
import type { Writable } from 'svelte/store'
import type { StatusResult } from '../utils'
import type { StatusResult } from '../utils.js'
export let queryClient: QueryClient
export let persistOptions: OmitKeyof<PersistQueryClientOptions, 'queryClient'>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script lang="ts">
import { createQueries } from '@tanstack/svelte-query'
import { sleep } from '../utils'
import { sleep } from '../utils.js'
import type { Writable } from 'svelte/store'
import type { StatusResult } from '../utils'
import type { StatusResult } from '../utils.js'
export let states: Writable<Array<StatusResult<string>>>
Expand Down
3 changes: 2 additions & 1 deletion packages/svelte-query-persist-client/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"moduleResolution": "Bundler"
"module": "NodeNext",
"moduleResolution": "NodeNext"
},
"include": [
"src/**/*.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/svelte-query/src/HydrationBoundary.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { useHydrate } from './useHydrate'
import { useHydrate } from './useHydrate.js'
import type {
DehydratedState,
HydrateOptions,
Expand Down
2 changes: 1 addition & 1 deletion packages/svelte-query/src/QueryClientProvider.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import { onDestroy, onMount } from 'svelte'
import { QueryClient } from '@tanstack/query-core'
import { setQueryClientContext } from './context'
import { setQueryClientContext } from './context.js'
export let client = new QueryClient()
Expand Down
8 changes: 4 additions & 4 deletions packages/svelte-query/src/createBaseQuery.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { derived, get, readable } from 'svelte/store'
import { notifyManager } from '@tanstack/query-core'
import { useIsRestoring } from './useIsRestoring'
import { useQueryClient } from './useQueryClient'
import { isSvelteStore } from './utils'
import { useIsRestoring } from './useIsRestoring.js'
import { useQueryClient } from './useQueryClient.js'
import { isSvelteStore } from './utils.js'
import type {
QueryClient,
QueryKey,
Expand All @@ -13,7 +13,7 @@ import type {
CreateBaseQueryOptions,
CreateBaseQueryResult,
StoreOrVal,
} from './types'
} from './types.js'

export function createBaseQuery<
TQueryFnData,
Expand Down
4 changes: 2 additions & 2 deletions packages/svelte-query/src/createInfiniteQuery.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { InfiniteQueryObserver } from '@tanstack/query-core'
import { createBaseQuery } from './createBaseQuery'
import { createBaseQuery } from './createBaseQuery.js'
import type {
DefaultError,
InfiniteData,
Expand All @@ -11,7 +11,7 @@ import type {
CreateInfiniteQueryOptions,
CreateInfiniteQueryResult,
StoreOrVal,
} from './types'
} from './types.js'

export function createInfiniteQuery<
TQueryFnData,
Expand Down
6 changes: 3 additions & 3 deletions packages/svelte-query/src/createMutation.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { derived, get, readable } from 'svelte/store'
import { MutationObserver, notifyManager } from '@tanstack/query-core'
import { useQueryClient } from './useQueryClient'
import { isSvelteStore, noop } from './utils'
import { useQueryClient } from './useQueryClient.js'
import { isSvelteStore, noop } from './utils.js'
import type {
CreateMutateFunction,
CreateMutationOptions,
CreateMutationResult,
StoreOrVal,
} from './types'
} from './types.js'
import type { DefaultError, QueryClient } from '@tanstack/query-core'

export function createMutation<
Expand Down
8 changes: 4 additions & 4 deletions packages/svelte-query/src/createQueries.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { QueriesObserver, notifyManager } from '@tanstack/query-core'
import { derived, get, readable } from 'svelte/store'
import { useIsRestoring } from './useIsRestoring'
import { useQueryClient } from './useQueryClient'
import { isSvelteStore } from './utils'
import { useIsRestoring } from './useIsRestoring.js'
import { useQueryClient } from './useQueryClient.js'
import { isSvelteStore } from './utils.js'
import type { Readable } from 'svelte/store'
import type { StoreOrVal } from './types'
import type { StoreOrVal } from './types.js'
import type {
DefaultError,
DefinedQueryObserverResult,
Expand Down
6 changes: 3 additions & 3 deletions packages/svelte-query/src/createQuery.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { QueryObserver } from '@tanstack/query-core'
import { createBaseQuery } from './createBaseQuery'
import { createBaseQuery } from './createBaseQuery.js'
import type { DefaultError, QueryClient, QueryKey } from '@tanstack/query-core'
import type {
CreateQueryOptions,
CreateQueryResult,
DefinedCreateQueryResult,
StoreOrVal,
} from './types'
} from './types.js'
import type {
DefinedInitialDataOptions,
UndefinedInitialDataOptions,
} from './queryOptions'
} from './queryOptions.js'

export function createQuery<
TQueryFnData = unknown,
Expand Down
32 changes: 16 additions & 16 deletions packages/svelte-query/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@
export * from '@tanstack/query-core'

// Svelte Query
export * from './types'
export * from './context'
export * from './types.js'
export * from './context.js'

export { createQuery } from './createQuery'
export type { QueriesResults, QueriesOptions } from './createQueries'
export { createQuery } from './createQuery.js'
export type { QueriesResults, QueriesOptions } from './createQueries.js'
export type {
DefinedInitialDataOptions,
UndefinedInitialDataOptions,
} from './queryOptions'
export { queryOptions } from './queryOptions'
export { createQueries } from './createQueries'
export { createInfiniteQuery } from './createInfiniteQuery'
export { infiniteQueryOptions } from './infiniteQueryOptions'
export { createMutation } from './createMutation'
export { useMutationState } from './useMutationState'
export { useQueryClient } from './useQueryClient'
export { useIsFetching } from './useIsFetching'
export { useIsMutating } from './useIsMutating'
export { useIsRestoring } from './useIsRestoring'
export { useHydrate } from './useHydrate'
} from './queryOptions.js'
export { queryOptions } from './queryOptions.js'
export { createQueries } from './createQueries.js'
export { createInfiniteQuery } from './createInfiniteQuery.js'
export { infiniteQueryOptions } from './infiniteQueryOptions.js'
export { createMutation } from './createMutation.js'
export { useMutationState } from './useMutationState.js'
export { useQueryClient } from './useQueryClient.js'
export { useIsFetching } from './useIsFetching.js'
export { useIsMutating } from './useIsMutating.js'
export { useIsRestoring } from './useIsRestoring.js'
export { useHydrate } from './useHydrate.js'
export { default as HydrationBoundary } from './HydrationBoundary.svelte'
export { default as QueryClientProvider } from './QueryClientProvider.svelte'
2 changes: 1 addition & 1 deletion packages/svelte-query/src/infiniteQueryOptions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { DefaultError, InfiniteData, QueryKey } from '@tanstack/query-core'
import type { CreateInfiniteQueryOptions } from './types'
import type { CreateInfiniteQueryOptions } from './types.js'

export function infiniteQueryOptions<
TQueryFnData,
Expand Down
2 changes: 1 addition & 1 deletion packages/svelte-query/src/queryOptions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { DataTag, DefaultError, QueryKey } from '@tanstack/query-core'
import type { CreateQueryOptions } from './types'
import type { CreateQueryOptions } from './types.js'

export type UndefinedInitialDataOptions<
TQueryFnData = unknown,
Expand Down
2 changes: 1 addition & 1 deletion packages/svelte-query/src/useHydrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
type QueryClient,
hydrate,
} from '@tanstack/query-core'
import { useQueryClient } from './useQueryClient'
import { useQueryClient } from './useQueryClient.js'

export function useHydrate(
state?: unknown,
Expand Down
2 changes: 1 addition & 1 deletion packages/svelte-query/src/useIsFetching.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
notifyManager,
} from '@tanstack/query-core'
import { readable } from 'svelte/store'
import { useQueryClient } from './useQueryClient'
import { useQueryClient } from './useQueryClient.js'
import type { Readable } from 'svelte/store'

export function useIsFetching(
Expand Down
2 changes: 1 addition & 1 deletion packages/svelte-query/src/useIsMutating.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
notifyManager,
} from '@tanstack/query-core'
import { readable } from 'svelte/store'
import { useQueryClient } from './useQueryClient'
import { useQueryClient } from './useQueryClient.js'
import type { Readable } from 'svelte/store'

export function useIsMutating(
Expand Down
2 changes: 1 addition & 1 deletion packages/svelte-query/src/useIsRestoring.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getIsRestoringContext } from './context'
import { getIsRestoringContext } from './context.js'
import type { Readable } from 'svelte/store'

export function useIsRestoring(): Readable<boolean> {
Expand Down
4 changes: 2 additions & 2 deletions packages/svelte-query/src/useMutationState.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { readable } from 'svelte/store'
import { notifyManager, replaceEqualDeep } from '@tanstack/query-core'
import { useQueryClient } from './useQueryClient'
import { useQueryClient } from './useQueryClient.js'
import type {
MutationCache,
MutationState,
QueryClient,
} from '@tanstack/query-core'
import type { Readable } from 'svelte/store'
import type { MutationStateOptions } from './types'
import type { MutationStateOptions } from './types.js'

function getResult<TResult = MutationState>(
mutationCache: MutationCache,
Expand Down
2 changes: 1 addition & 1 deletion packages/svelte-query/src/useQueryClient.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getQueryClientContext } from './context'
import { getQueryClientContext } from './context.js'
import type { QueryClient } from '@tanstack/query-core'

export function useQueryClient(queryClient?: QueryClient): QueryClient {
Expand Down
2 changes: 1 addition & 1 deletion packages/svelte-query/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Readable } from 'svelte/store'
import type { StoreOrVal } from './types'
import type { StoreOrVal } from './types.js'

export function isSvelteStore<T extends object>(
obj: StoreOrVal<T>,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { createQuery } from '../../src/createQuery'
import { sleep } from '../utils'
import { createQuery } from '../../src/index.js'
import { sleep } from '../utils.js'
const query = createQuery({
queryKey: ['hello'],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { QueryClient } from '@tanstack/query-core'
import QueryClientProvider from '../../src/QueryClientProvider.svelte'
import { QueryClientProvider } from '../../src/index.js'
import ChildComponent from './ChildComponent.svelte'
import type { QueryCache } from '@tanstack/query-core'
Expand Down
2 changes: 1 addition & 1 deletion packages/svelte-query/tests/context/BaseExample.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import { getQueryClientContext } from '../../src/context'
import { getQueryClientContext } from '../../src/index.js'
getQueryClientContext()
</script>
2 changes: 1 addition & 1 deletion packages/svelte-query/tests/context/context.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, test } from 'vitest'
import { render } from '@testing-library/svelte'
import { getIsRestoringContext } from '../../src/context'
import { getIsRestoringContext } from '../../src/index.js'
import BaseExample from './BaseExample.svelte'

describe('getQueryClientContext', () => {
Expand Down
Loading

0 comments on commit 01e63a5

Please sign in to comment.