This repository has been archived by the owner on Feb 10, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix cloudflare ssr conditions setup (#465)
- Loading branch information
Showing
12 changed files
with
291 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@astrojs/cloudflare': patch | ||
--- | ||
|
||
Fixes setting custom `workerd` and `worker` conditions for the ssr environment only |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,15 +29,6 @@ | |
"packageManager": "[email protected]", | ||
"pnpm": { | ||
"peerDependencyRules": { | ||
"ignoreMissing": [ | ||
"rollup", | ||
"@babel/core", | ||
"@babel/plugin-transform-react-jsx", | ||
"vite", | ||
"react", | ||
"react-dom", | ||
"@types/react" | ||
], | ||
"allowAny": ["astro", "vite"] | ||
} | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
packages/cloudflare/test/fixtures/with-svelte/astro.config.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import cloudflare from '@astrojs/cloudflare'; | ||
import svelte from "@astrojs/svelte"; | ||
import { defineConfig } from 'astro/config'; | ||
|
||
export default defineConfig({ | ||
integrations: [svelte()], | ||
adapter: cloudflare(), | ||
output: 'server', | ||
}); |
11 changes: 11 additions & 0 deletions
11
packages/cloudflare/test/fixtures/with-svelte/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"name": "@test/astro-cloudflare-with-svelte", | ||
"version": "0.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"@astrojs/cloudflare": "workspace:*", | ||
"@astrojs/svelte": "^7.0.1", | ||
"astro": "^5.0.0", | ||
"svelte": "^5.6.0" | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
packages/cloudflare/test/fixtures/with-svelte/src/components/Component.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<div class="svelte">Svelte Content</div> |
13 changes: 13 additions & 0 deletions
13
packages/cloudflare/test/fixtures/with-svelte/src/pages/index.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
import Component from '../components/Component.svelte'; | ||
--- | ||
|
||
<html> | ||
<head> | ||
<title>Testing</title> | ||
</head> | ||
<body> | ||
<h1>Testing</h1> | ||
<Component /> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import * as assert from 'node:assert/strict'; | ||
import { after, before, describe, it } from 'node:test'; | ||
import { fileURLToPath } from 'node:url'; | ||
import * as cheerio from 'cheerio'; | ||
import { astroCli, wranglerCli } from './_test-utils.js'; | ||
|
||
const root = new URL('./fixtures/with-svelte/', import.meta.url); | ||
|
||
describe('Svelte', () => { | ||
let wrangler; | ||
before(async () => { | ||
await astroCli(fileURLToPath(root), 'build'); | ||
|
||
wrangler = wranglerCli(fileURLToPath(root)); | ||
await new Promise((resolve) => { | ||
wrangler.stdout.on('data', (data) => { | ||
// console.log('[stdout]', data.toString()); | ||
if (data.toString().includes('http://127.0.0.1:8788')) resolve(); | ||
}); | ||
wrangler.stderr.on('data', (data) => { | ||
// console.log('[stderr]', data.toString()); | ||
}); | ||
}); | ||
}); | ||
|
||
after((done) => { | ||
wrangler.kill(); | ||
}); | ||
|
||
it('renders the svelte component', async () => { | ||
const res = await fetch('http://127.0.0.1:8788/'); | ||
assert.equal(res.status, 200); | ||
const html = await res.text(); | ||
const $ = cheerio.load(html); | ||
assert.equal($('.svelte').text(), 'Svelte Content'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.