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 d7007a1a83
commit 2a1fa09b31
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 88 additions and 277 deletions

View file

@ -0,0 +1,5 @@
---
'@astrojs/cloudflare': minor
---
Add `worked` and `worker` import condition for worker bundling

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();
}
});
});

View file

@ -3599,6 +3599,21 @@ importers:
specifier: workspace:*
version: link:../../../../../astro
packages/integrations/cloudflare/test/fixtures/with-solid-js:
dependencies:
'@astrojs/cloudflare':
specifier: workspace:*
version: link:../../..
'@astrojs/solid-js':
specifier: workspace:*
version: link:../../../../solid
astro:
specifier: workspace:*
version: link:../../../../../astro
solid-js:
specifier: '*'
version: 1.7.4
packages/integrations/deno:
dependencies:
esbuild: