0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-03-10 23:01:26 -05:00

Add workerd and worker to cloudflare adapter bundling (#7092)

This commit is contained in:
Johannes Spohr 2023-05-16 14:00:29 +02:00 committed by GitHub
parent 14544e896e
commit 4300a73418
8 changed files with 68 additions and 277 deletions

View file

@ -0,0 +1,2 @@
# Astro cloudflare directory mode creates a function directory
functions

View file

@ -98,6 +98,7 @@ export default function createIntegration(args?: Options): AstroIntegration {
await esbuild.build({
target: 'es2020',
platform: 'browser',
conditions: ["workerd", "worker", "browser"],
entryPoints: [entryPath],
outfile: buildPath,
allowOverwrite: true,

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,9 @@
import { defineConfig } from 'astro/config';
import cloudflare from '@astrojs/cloudflare';
import solidJs from "@astrojs/solid-js";
export default defineConfig({
integrations: [solidJs()],
adapter: cloudflare(),
output: 'server',
});

View file

@ -0,0 +1,11 @@
{
"name": "@test/astro-cloudflare-with-solid-js",
"version": "0.0.0",
"private": true,
"dependencies": {
"@astrojs/cloudflare": "workspace:*",
"@astrojs/solid-js": "workspace:*",
"solid-js": "*",
"astro": "workspace:*"
}
}

View file

@ -0,0 +1 @@
export const Component = () => <div class="solid">Solid Content</div>

View file

@ -0,0 +1,13 @@
---
import {Component} from "../components/Component";
---
<html>
<head>
<title>Testing</title>
</head>
<body>
<h1>Testing</h1>
<Component />
</body>
</html>

View file

@ -0,0 +1,31 @@
import {loadFixture, runCLI} from './test-utils.js';
import { expect } from 'chai';
import * as cheerio from "cheerio";
describe('With SolidJS', () => {
/** @type {import('./test-utils').Fixture} */
let fixture;
before(async () => {
fixture = await loadFixture({
root: './fixtures/with-solid-js/',
});
await fixture.build();
});
it('renders the solid component', async () => {
const { ready, stop } = runCLI('./fixtures/with-solid-js/', { silent: true });
try {
await ready;
let res = await fetch(`http://localhost:8787/`);
expect(res.status).to.equal(200);
let html = await res.text();
let $ = cheerio.load(html);
expect($('.solid').text()).to.equal('Solid Content');
} finally {
stop();
}
});
});