From d9805b18fc68b74c76c1ed7029c9d833c347137d Mon Sep 17 00:00:00 2001 From: Amir Date: Sat, 8 Jun 2024 23:02:51 -0700 Subject: [PATCH] More fixes --- examples/01_minimal/relay.config.js | 6 +++--- examples/02_typescript/src/App.tsx | 2 +- examples/02_typescript/src/index.tsx | 1 - examples/03_errorhandling/src/App.tsx | 5 +++-- examples/03_errorhandling/src/index.tsx | 1 - package.json | 1 + pnpm-lock.yaml | 19 ++++++++++++++++--- src/atomWithMutation.ts | 5 +++-- src/common.ts | 3 ++- tests/01_basic.spec.tsx | 9 +++++++++ tests/01_basic_spec.tsx | 11 ----------- 11 files changed, 38 insertions(+), 25 deletions(-) create mode 100644 tests/01_basic.spec.tsx delete mode 100644 tests/01_basic_spec.tsx diff --git a/examples/01_minimal/relay.config.js b/examples/01_minimal/relay.config.js index 314a732..1d29314 100644 --- a/examples/01_minimal/relay.config.js +++ b/examples/01_minimal/relay.config.js @@ -1,6 +1,6 @@ -module.exports = { +export default { language: 'typescript', - src: `${__dirname}/src`, - schema: `${__dirname}/data/schema.graphql`, + src: '../src', + schema: './data/schema.graphql', exclude: ['**/node_modules/**', '**/__mocks__/**', '**/__generated__/**'], }; diff --git a/examples/02_typescript/src/App.tsx b/examples/02_typescript/src/App.tsx index 5f03509..3fc1b7f 100644 --- a/examples/02_typescript/src/App.tsx +++ b/examples/02_typescript/src/App.tsx @@ -1,4 +1,4 @@ -import React, { Suspense } from 'react'; +import { Suspense } from 'react'; import { Provider, useAtom } from 'jotai/react'; import { createStore } from 'jotai/vanilla'; import { environmentAtom, atomWithQuery } from 'jotai-relay'; diff --git a/examples/02_typescript/src/index.tsx b/examples/02_typescript/src/index.tsx index bfd6d8f..55b74de 100644 --- a/examples/02_typescript/src/index.tsx +++ b/examples/02_typescript/src/index.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import { createRoot } from 'react-dom/client'; import App from './App'; diff --git a/examples/03_errorhandling/src/App.tsx b/examples/03_errorhandling/src/App.tsx index b426a92..dafacb3 100644 --- a/examples/03_errorhandling/src/App.tsx +++ b/examples/03_errorhandling/src/App.tsx @@ -1,5 +1,6 @@ -import React, { Suspense } from 'react'; -import { ErrorBoundary, FallbackProps } from 'react-error-boundary'; +import { Suspense } from 'react'; +import { ErrorBoundary } from 'react-error-boundary'; +import type { FallbackProps } from 'react-error-boundary'; import { Provider, useAtom, useSetAtom } from 'jotai/react'; import { atom, createStore } from 'jotai/vanilla'; import { environmentAtom, atomWithQuery } from 'jotai-relay'; diff --git a/examples/03_errorhandling/src/index.tsx b/examples/03_errorhandling/src/index.tsx index bfd6d8f..55b74de 100644 --- a/examples/03_errorhandling/src/index.tsx +++ b/examples/03_errorhandling/src/index.tsx @@ -1,4 +1,3 @@ -import React from 'react'; import { createRoot } from 'react-dom/client'; import App from './App'; diff --git a/package.json b/package.json index 5cfe8ec..5d8d3ca 100644 --- a/package.json +++ b/package.json @@ -81,6 +81,7 @@ "eslint-plugin-react": "^7.34.1", "eslint-plugin-react-hooks": "^4.6.2", "graphql": "^16.8.1", + "happy-dom": "^14.12.0", "html-webpack-plugin": "^5.6.0", "jest": "^29.7.0", "jest-environment-jsdom": "^29.7.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6b9a48f..c02faa1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -77,6 +77,9 @@ devDependencies: graphql: specifier: ^16.8.1 version: 16.8.1 + happy-dom: + specifier: ^14.12.0 + version: 14.12.0 html-webpack-plugin: specifier: ^5.6.0 version: 5.6.0(webpack@5.91.0) @@ -121,7 +124,7 @@ devDependencies: version: 5.2.12 vitest: specifier: ^1.6.0 - version: 1.6.0 + version: 1.6.0(happy-dom@14.12.0) packages: @@ -2244,7 +2247,7 @@ packages: jest: 29.7.0(babel-plugin-macros@3.1.0) lodash: 4.17.21 redent: 3.0.0 - vitest: 1.6.0 + vitest: 1.6.0(happy-dom@14.12.0) dev: true /@testing-library/react@15.0.7(@types/react@18.3.3)(react-dom@18.3.1)(react@18.3.1): @@ -4581,6 +4584,15 @@ packages: engines: {node: ^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0} dev: true + /happy-dom@14.12.0: + resolution: {integrity: sha512-dHcnlGFY2o2CdxfuYpqwSrBrpj/Kuzv4u4f3TU5yHW1GL24dKij4pv1BRjXnXc3uWo8qsCbToF9weaDsm/He8A==} + engines: {node: '>=16.0.0'} + dependencies: + entities: 4.5.0 + webidl-conversions: 7.0.0 + whatwg-mimetype: 3.0.0 + dev: true + /has-bigints@1.0.2: resolution: {integrity: sha512-tSvCKtBr9lkF0Ex0aQiP9N+OpV4zi2r/Nee5VkRDbaqv35RLYMzbwQfFSZZH0kR+Rd6302UJZ2p/bJCEoR3VoQ==} dev: true @@ -7222,7 +7234,7 @@ packages: fsevents: 2.3.3 dev: true - /vitest@1.6.0: + /vitest@1.6.0(happy-dom@14.12.0): resolution: {integrity: sha512-H5r/dN06swuFnzNFhq/dnz37bPXnq8xB2xB5JOVk8K09rUtoeNN+LHWkoQ0A/i3hvbUKKcCei9KpbxqHMLhLLA==} engines: {node: ^18.0.0 || >=20.0.0} hasBin: true @@ -7256,6 +7268,7 @@ packages: chai: 4.4.1 debug: 4.3.5 execa: 8.0.1 + happy-dom: 14.12.0 local-pkg: 0.5.0 magic-string: 0.30.10 pathe: 1.1.2 diff --git a/src/atomWithMutation.ts b/src/atomWithMutation.ts index 50b3f9f..8e956da 100644 --- a/src/atomWithMutation.ts +++ b/src/atomWithMutation.ts @@ -1,4 +1,5 @@ -import { atom, Getter, WritableAtom } from 'jotai/vanilla'; +import { atom } from 'jotai/vanilla'; +import type { Getter, WritableAtom } from 'jotai/vanilla'; import type { Disposable, Environment, @@ -6,7 +7,7 @@ import type { MutationParameters, } from 'relay-runtime'; import { commitMutation } from 'relay-runtime'; -import { environmentAtom } from './environmentAtom'; +import { environmentAtom } from './environmentAtom.js'; /** * Creates a Jotai atom with a Relay mutation. diff --git a/src/common.ts b/src/common.ts index aab36bc..c1cd0d0 100644 --- a/src/common.ts +++ b/src/common.ts @@ -1,5 +1,6 @@ import type { Environment, Subscribable } from 'relay-runtime'; -import type { atom, Getter } from 'jotai/vanilla'; +import type { Getter } from 'jotai/vanilla'; +import { atom } from 'jotai/vanilla'; import { atomWithObservable } from 'jotai/vanilla/utils'; /** diff --git a/tests/01_basic.spec.tsx b/tests/01_basic.spec.tsx new file mode 100644 index 0000000..6d4a0b2 --- /dev/null +++ b/tests/01_basic.spec.tsx @@ -0,0 +1,9 @@ +import * as src from '../src/index.js'; +import { expect, test } from 'vitest'; + +test('should export functions', () => { + expect(src.environmentAtom).toBeDefined(); + expect(src.atomWithQuery).toBeDefined(); + expect(src.atomWithMutation).toBeDefined(); + expect(src.atomWithSubscription).toBeDefined(); +}); diff --git a/tests/01_basic_spec.tsx b/tests/01_basic_spec.tsx deleted file mode 100644 index c92d668..0000000 --- a/tests/01_basic_spec.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import * as src from '../src/index.js'; -import { expect, test } from 'vitest'; - -test('basic spec', () => { - it('should export functions', () => { - expect(src.environmentAtom).toBeDefined(); - expect(src.atomWithQuery).toBeDefined(); - expect(src.atomWithMutation).toBeDefined(); - expect(src.atomWithSubscription).toBeDefined(); - }); -});