denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
98.16k stars 5.4k forks source link

SvelteKit x Cloudflare template cannot work #25513

Open ryuapp opened 2 months ago

ryuapp commented 2 months ago

Version: Deno 2.0.0-rc.1+ce1d668 (canary, release, x86_64-pc-windows-msvc)

// Select `SvelteKit demo app`.
npm create cloudflare@latest -- my-svelte-app --framework=svelte

We can confirm that it does not work after runningdeno install.

my-svelte-app> deno install
Warning rollup-plugin-inject@3.0.2 is deprecated: This package has been deprecated and is no longer maintained. Please use @rollup/plugin-inject.
Warning glob@7.2.3 is deprecated: Glob versions prior to v9 are no longer supported
Warning sourcemap-codec@1.4.8 is deprecated: Please use @jridgewell/sourcemap-codec instead
Warning rimraf@2.7.1 is deprecated: Rimraf versions prior to v4 are no longer supported
Warning inflight@1.0.6 is deprecated: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
Warning Packages contained npm lifecycle scripts (preinstall/install/postinstall) that were not executed.
    This may cause the packages to not work correctly. To run them, use the `--allow-scripts` flag with `deno cache` or `deno install`
    (e.g. `deno cache --allow-scripts=pkg1,pkg2 <entrypoint>` or `deno install --allow-scripts=pkg1,pkg2`):
      npm:@sveltejs/kit@2.5.26, npm:esbuild@0.21.5, npm:svelte-preprocess@5.1.4, npm:esbuild@0.17.19, npm:workerd@1.20240821.1
my-svelte-app> deno task dev
Task dev vite dev
error when starting dev server:
TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))
    at Function.from (<anonymous>)
    at Object.<anonymous> (file:///C:/Users/xxxx/my-svelte-app/node_modules/miniflare/dist/src/index.js:6744:64)
    at Object.<anonymous> (file:///C:/Users/xxxx/my-svelte-app/node_modules/miniflare/dist/src/index.js:10197:4)
    at Module._compile (node:module:735:34)
    at Object.Module._extensions..js (node:module:756:11)
    at Module.load (node:module:655:32)
    at Function.Module._load (node:module:523:13)
    at Module.require (node:module:674:19)
    at require (node:module:800:16)
    at Object.<anonymous> (file:///C:/Users/xxxx/my-svelte-app/node_modules/wrangler/wrangler-dist/cli.js:152430:24)

https://developers.cloudflare.com/pages/framework-guides/deploy-a-svelte-site/

There seems to be a problem with compatibility with Wrangler. related: #17248 #17977

nounder commented 2 months ago

With DENO_FUTURE=1 deno 1.46.3 after deno install I get following error with miniflare (Running on SvelteKit):

error: Uncaught (in worker "[worker eval]") (in promise) ReferenceError: require is not defined
    at data:text/javascript,const { createRequir......eadableStream"      :1:27

Seems like scripts created with data URI string are not properly working. It originates from vite worker code:

https://github.com/vitejs/vite/blob/bad0cccee80c02fa309f274220f6d324d03c3b19/packages/vite/src/node/plugins/worker.ts#L336

bartlomieju commented 2 months ago

@nounder please try again with Deno v2.0.0-rc.6.

nounder commented 2 months ago

@bartlomieju Unfortunately Deno 2.0.0-rc.6 still results in the same error even after rm node_modules && deno clean && deno install