appwrite / sdk-for-svelte

Appwrite SDK for Svelte 🧡 ⚠️ Warning - this SDK was designed to support Appwrite 0.9 and is not compatible with the latest Appwrite versions. We are planing to refactor it as part of the SDK Generator for better support and maintenance.
https://appwrite.io
BSD 3-Clause "New" or "Revised" License
74 stars 13 forks source link

Support SvelteKit and appwrite 0.3.0-beta #17

Open abovethewater opened 3 years ago

abovethewater commented 3 years ago

The latest version in npm is tied to appwrite ^0.2.3-beta

This does not seem to work with sveltekit out of the box:

__vite_ssr_import_0__.default is not a constructor

Installing direct from master gets further:

ReferenceError: require is not defined
    at /node_modules/.pnpm/cross-fetch@3.1.4/node_modules/cross-fetch/dist/node-ponyfill.js?v=5ad71818:1:19
    at instantiateModule (/Users/jmathews/leavenoprints/leavenoprints-v1/node_modules/.pnpm/vite@2.4.1/node_modules/vite/dist/node/chunks/dep-cc49d7be.js:72639:166)
10:04:51 [vite] Error when evaluating SSR module /node_modules/.pnpm/isomorphic-form-data@2.0.0/node_modules/isomorphic-form-data/lib/index.js?v=5ad71818:
ReferenceError: module is not defined
    at /node_modules/.pnpm/isomorphic-form-data@2.0.0/node_modules/isomorphic-form-data/lib/index.js?v=5ad71818:1:19
    at instantiateModule (/Users/jmathews/leavenoprints/leavenoprints-v1/node_modules/.pnpm/vite@2.4.1/node_modules/vite/dist/node/chunks/dep-cc49d7be.js:72639:166)
10:04:51 [vite] Error when evaluating SSR module /node_modules/.pnpm/cross-fetch@3.1.4/node_modules/cross-fetch/dist/node-ponyfill.js?v=5ad71818:
ReferenceError: require is not defined
    at /node_modules/.pnpm/cross-fetch@3.1.4/node_modules/cross-fetch/dist/node-ponyfill.js?v=5ad71818:1:19
    at instantiateModule (/Users/jmathews/leavenoprints/leavenoprints-v1/node_modules/.pnpm/vite@2.4.1/node_modules/vite/dist/node/chunks/dep-cc49d7be.js:72639:166)

Adding the appwrite dependency explicitly, gets further, now compiles without issues, but the following error is seen in console:

Uncaught (in promise) SyntaxError: import not found: fetch

Adding appwrite to optimizeDeps fixes this:

  kit: {
    // hydrate the <div id="svelte"> element in src/app.html
    target: '#svelte',
    adapter: adapter(),
    vite: {
      optimizeDeps: {
        include: ['appwrite'],
      },
    }
  }

I am using pnpm if that makes a difference. Appwrite 3.2.0 SvelteKit v1.0.0-next.123

Thanks

TorstenDittmann commented 3 years ago

Yes, this library doesn't support svelte kit yet. But our normal Web SDK does Support SvelteKit/SSR.

EVDOG4LIFE commented 4 months ago

Due to age, and given that we are quite a few versions ahead - is this still needed?