sdk-for-svelte icon indicating copy to clipboard operation
sdk-for-svelte copied to clipboard

Support SvelteKit and appwrite 0.3.0-beta

Open abovethewater opened this issue 4 years ago • 2 comments

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

abovethewater avatar Jul 09 '21 09:07 abovethewater

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

TorstenDittmann avatar Jul 09 '21 11:07 TorstenDittmann

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

EVDOG4LIFE avatar May 06 '24 22:05 EVDOG4LIFE