timhall / svelte-apollo

Svelte integration for Apollo GraphQL
MIT License
945 stars 67 forks source link

Cannot use library - Bundling errors #110

Open ollyde opened 2 years ago

ollyde commented 2 years ago

After installing the library I get the following errors.

No idea what the solution is. :-/

Pre-bundling dependencies:
  svelte
  @apollo/client
  svelte/animate
  svelte/easing
  svelte/internal
  (...and 3 more)
(this will be run only when your dependencies or config have changed)
 > node_modules/@apollo/client/react/hooks/useReactiveVar.js:1:36: error: Could not resolve "react" (mark it as external to exclude it from the bundle)
    1 │ import { useEffect, useState } from 'react';
      ╵                                     ~~~~~~~

 > node_modules/@apollo/client/react/context/ApolloContext.js:1:23: error: Could not resolve "react" (mark it as external to exclude it from the bundle)
    1 │ import * as React from 'react';
      ╵                        ~~~~~~~

 > node_modules/@apollo/client/react/context/ApolloConsumer.js:2:23: error: Could not resolve "react" (mark it as external to exclude it from the bundle)
    2 │ import * as React from 'react';
      ╵                        ~~~~~~~

 > node_modules/@apollo/client/react/hooks/useApolloClient.js:2:23: error: Could not resolve "react" (mark it as external to exclude it from the bundle)
    2 │ import * as React from 'react';
      ╵                        ~~~~~~~

 > node_modules/@apollo/client/react/context/ApolloProvider.js:2:23: error: Could not resolve "react" (mark it as external to exclude it from the bundle)
    2 │ import * as React from 'react';
      ╵                        ~~~~~~~

 > node_modules/@apollo/client/react/hooks/useMutation.js:2:56: error: Could not resolve "react" (mark it as external to exclude it from the bundle)
    2 │ import { useContext, useState, useRef, useEffect } from 'react';
      ╵                                                         ~~~~~~~

 > node_modules/@apollo/client/react/hooks/useSubscription.js:3:68: error: Could not resolve "react" (mark it as external to exclude it from the bundle)
    3 │ import { useContext, useState, useRef, useEffect, useReducer } from 'react';
      ╵                                                                     ~~~~~~~

 > node_modules/@apollo/client/react/hooks/utils/useBaseQuery.js:3:58: error: Could not resolve "react" (mark it as external to exclude it from the bundle)
    3 │ import { useContext, useEffect, useReducer, useRef } from 'react';
      ╵                                                           ~~~~~~~

 > node_modules/@apollo/client/react/hooks/utils/useAfterFastRefresh.js:2:34: error: Could not resolve "react" (mark it as external to exclude it from the bundle)
    2 │ import { useEffect, useRef } from "react";
      ╵                                   ~~~~~~~

 > node_modules/@apollo/client/react/hooks/utils/useDeepMemo.js:1:23: error: Could not resolve "react" (mark it as external to exclude it from the bundle)
    1 │ import { useRef } from 'react';
      ╵                        ~~~~~~~

error when starting dev server:
Error: Build failed with 10 errors:
node_modules/@apollo/client/react/context/ApolloConsumer.js:2:23: error: Could not resolve "react" (mark it as external to exclude it from the bundle)
node_modules/@apollo/client/react/context/ApolloContext.js:1:23: error: Could not resolve "react" (mark it as external to exclude it from the bundle)
node_modules/@apollo/client/react/context/ApolloProvider.js:2:23: error: Could not resolve "react" (mark it as external to exclude it from the bundle)
node_modules/@apollo/client/react/hooks/useApolloClient.js:2:23: error: Could not resolve "react" (mark it as external to exclude it from the bundle)
node_modules/@apollo/client/react/hooks/useMutation.js:2:56: error: Could not resolve "react" (mark it as external to exclude it from the bundle)
...
    at failureErrorWithLog (/Users/technotechno/Downloads/webrtc-test/node_modules/esbuild/lib/main.js:1493:15)
    at /Users/technotechno/Downloads/webrtc-test/node_modules/esbuild/lib/main.js:1151:28
    at runOnEndCallbacks (/Users/technotechno/Downloads/webrtc-test/node_modules/esbuild/lib/main.js:941:63)
    at buildResponseToResult (/Users/technotechno/Downloads/webrtc-test/node_modules/esbuild/lib/main.js:1149:7)
    at /Users/technotechno/Downloads/webrtc-test/node_modules/esbuild/lib/main.js:1258:14
    at /Users/technotechno/Downloads/webrtc-test/node_modules/esbuild/lib/main.js:629:9
    at handleIncomingPacket (/Users/technotechno/Downloads/webrtc-test/node_modules/esbuild/lib/main.js:726:9)
    at Socket.readFromStdout (/Users/technotechno/Downloads/webrtc-test/node_modules/esbuild/lib/main.js:596:7)
    at Socket.emit (node:events:390:28)
    at addChunk (node:internal/streams/readable:324:12)
cesargdm commented 2 years ago

See https://github.com/timhall/svelte-apollo/issues/82#issuecomment-778137588