From 7ea5d12ce07171b0bb74f88c3f8be07ae05c61cd Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sun, 18 Apr 2021 18:40:08 -0400 Subject: [PATCH 1/3] fix cloudflare config --- packages/create-svelte/templates/default/package.json | 7 ++++--- packages/create-svelte/templates/default/wrangler.toml | 9 ++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/create-svelte/templates/default/package.json b/packages/create-svelte/templates/default/package.json index 208dbf239e8e..8f35e60a238c 100644 --- a/packages/create-svelte/templates/default/package.json +++ b/packages/create-svelte/templates/default/package.json @@ -7,13 +7,14 @@ "start": "svelte-kit start" }, "devDependencies": { + "@sveltejs/adapter-cloudflare-workers": "next", "@sveltejs/adapter-netlify": "next", "@sveltejs/adapter-vercel": "next", "@sveltejs/kit": "next", - "svelte": "^3.29.0", - "svelte-preprocess": "^4.7.0", + "svelte": "^3.37.0", + "svelte-preprocess": "^4.7.1", "typescript": "^4.2.4", - "vite": "^2.1.0" + "vite": "^2.1.5" }, "type": "module", "dependencies": { diff --git a/packages/create-svelte/templates/default/wrangler.toml b/packages/create-svelte/templates/default/wrangler.toml index b98a9fce0a98..054d6268a414 100644 --- a/packages/create-svelte/templates/default/wrangler.toml +++ b/packages/create-svelte/templates/default/wrangler.toml @@ -1,10 +1,13 @@ name = "svelte-kit-demo" -type = "javascript" -account_id = "f60df21486a4f0e5dbd85493882f1d53" +type = "webpack" +account_id = "32a8245cd45a24083dd0acae1d482048" workers_dev = true route = "" zone_id = "" [site] bucket = "./.cloudflare/assets" -entry-point = "./.cloudflare/worker" \ No newline at end of file +entry-point = "./.cloudflare/worker" + +[build] +upload = { format = "service-worker" } \ No newline at end of file From ae7ff34f43f164fd4e0a1c1dce0a9eb8be5b76ef Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sun, 18 Apr 2021 18:41:09 -0400 Subject: [PATCH 2/3] generate required package.json --- .changeset/brown-bugs-arrive.md | 5 +++++ packages/adapter-cloudflare-workers/index.js | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 .changeset/brown-bugs-arrive.md diff --git a/.changeset/brown-bugs-arrive.md b/.changeset/brown-bugs-arrive.md new file mode 100644 index 000000000000..403cca2943dc --- /dev/null +++ b/.changeset/brown-bugs-arrive.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/adapter-cloudflare-workers': patch +--- + +Generate required package.json diff --git a/packages/adapter-cloudflare-workers/index.js b/packages/adapter-cloudflare-workers/index.js index b75eb73cc40d..b259895c5e4f 100644 --- a/packages/adapter-cloudflare-workers/index.js +++ b/packages/adapter-cloudflare-workers/index.js @@ -32,9 +32,11 @@ module.exports = function () { entryPoints: ['.svelte/cloudflare-workers/entry.js'], outfile: `${entrypoint}/index.js`, bundle: true, - platform: 'node' + platform: 'node' // TODO would be great if we could generate ESM and use type = "javascript" }); + fs.writeFileSync(`${entrypoint}/package.json`, JSON.stringify({ main: 'index.js' })); + utils.log.info('Prerendering static pages...'); await utils.prerender({ dest: bucket From 4427949167d39b28b7bbb73a478ae2b517f1ea3d Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sun, 18 Apr 2021 18:42:13 -0400 Subject: [PATCH 3/3] lockfile --- pnpm-lock.yaml | 44 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d8e2abe0a344..0c97bef98338 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -179,26 +179,28 @@ importers: specifiers: '@fontsource/fira-mono': ^4.2.2 '@lukeed/uuid': ^2.0.0 + '@sveltejs/adapter-cloudflare-workers': next '@sveltejs/adapter-netlify': next '@sveltejs/adapter-vercel': next '@sveltejs/kit': next cookie: ^0.4.1 - svelte: ^3.29.0 - svelte-preprocess: ^4.7.0 + svelte: ^3.37.0 + svelte-preprocess: ^4.7.1 typescript: ^4.2.4 - vite: ^2.1.0 + vite: ^2.1.5 dependencies: '@fontsource/fira-mono': 4.2.2 '@lukeed/uuid': 2.0.0 cookie: 0.4.1 devDependencies: + '@sveltejs/adapter-cloudflare-workers': link:../../../adapter-cloudflare-workers '@sveltejs/adapter-netlify': link:../../../adapter-netlify '@sveltejs/adapter-vercel': link:../../../adapter-vercel '@sveltejs/kit': link:../../../kit - svelte: 3.35.0 - svelte-preprocess: 4.7.0_svelte@3.35.0+typescript@4.2.4 + svelte: 3.37.0 + svelte-preprocess: 4.7.1_svelte@3.37.0+typescript@4.2.4 typescript: 4.2.4 - vite: 2.1.0 + vite: 2.1.5 packages/kit: specifiers: @@ -1522,6 +1524,12 @@ packages: requiresBuild: true dev: true + /esbuild/0.9.7: + resolution: {integrity: sha512-VtUf6aQ89VTmMLKrWHYG50uByMF4JQlVysb8dmg6cOgW8JnFCipmz7p+HNBl+RR3LLCuBxFGVauAe2wfnF9bLg==} + hasBin: true + requiresBuild: true + dev: true + /escalade/3.1.1: resolution: {integrity: sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==} engines: {node: '>=6'} @@ -3461,8 +3469,8 @@ packages: strip-indent: 3.0.0 dev: true - /svelte-preprocess/4.7.0_svelte@3.35.0+typescript@4.2.4: - resolution: {integrity: sha512-iNrY4YGqi0LD2e6oT9YbdSzOKntxk8gmzfqso1z/lUJOZh4o6fyIqkirmiZ8/dDJFqtIE1spVgDFWgkfhLEYlw==} + /svelte-preprocess/4.7.1_svelte@3.37.0+typescript@4.2.4: + resolution: {integrity: sha512-sOjDPvNmAgyX8vhb0UfOFneDVRXoJHzQsbxNcUq0a5hq0+01G+boxk1D0ZUN8wIa9lLWFcsjSiuprQp7N8YbqQ==} engines: {node: '>= 9.11.2'} requiresBuild: true peerDependencies: @@ -3506,7 +3514,7 @@ packages: '@types/sass': 1.16.0 detect-indent: 6.0.0 strip-indent: 3.0.0 - svelte: 3.35.0 + svelte: 3.37.0 typescript: 4.2.4 dev: true @@ -3515,6 +3523,11 @@ packages: engines: {node: '>= 8'} dev: true + /svelte/3.37.0: + resolution: {integrity: sha512-TRF30F4W4+d+Jr2KzUUL1j8Mrpns/WM/WacxYlo5MMb2E5Qy2Pk1Guj6GylxsW9OnKQl1tnF8q3hG/hQ3h6VUA==} + engines: {node: '>= 8'} + dev: true + /table/6.0.7: resolution: {integrity: sha512-rxZevLGTUzWna/qBLObOe16kB2RTnnbhciwgPbMMlazz1yZGVEgnZK762xyVdVznhqxrfCeBMmMkgOOaPwjH7g==} engines: {node: '>=10.0.0'} @@ -3759,6 +3772,19 @@ packages: fsevents: 2.3.2 dev: true + /vite/2.1.5: + resolution: {integrity: sha512-tYU5iaYeUgQYvK/CNNz3tiJ8vYqPWfCE9IQ7K0iuzYovWw7lzty7KRYGWwV3CQPh0NKxWjOczAqiJsCL0Xb+Og==} + engines: {node: '>=12.0.0'} + hasBin: true + dependencies: + esbuild: 0.9.7 + postcss: 8.2.8 + resolve: 1.20.0 + rollup: 2.42.3 + optionalDependencies: + fsevents: 2.3.2 + dev: true + /wcwidth/1.0.1: resolution: {integrity: sha1-8LDc+RW8X/FSivrbLA4XtTLaL+g=} dependencies: