Skip to content

Commit

Permalink
Add workerd and worker to cloudflare adapter bundling (#7092)
Browse files Browse the repository at this point in the history
  • Loading branch information
johannesspohr committed May 16, 2023
1 parent d7007a1 commit 2a1fa09
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 277 deletions.
5 changes: 5 additions & 0 deletions .changeset/rich-crews-fry.md
@@ -0,0 +1,5 @@
---
'@astrojs/cloudflare': minor
---

Add `worked` and `worker` import condition for worker bundling
2 changes: 2 additions & 0 deletions packages/integrations/cloudflare/.gitignore
@@ -0,0 +1,2 @@
# Astro cloudflare directory mode creates a function directory
functions
1 change: 1 addition & 0 deletions packages/integrations/cloudflare/src/index.ts
Expand Up @@ -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,
Expand Down

This file was deleted.

@@ -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',
});
@@ -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:*"
}
}
@@ -0,0 +1 @@
export const Component = () => <div class="solid">Solid Content</div>
@@ -0,0 +1,13 @@
---
import {Component} from "../components/Component";
---

<html>
<head>
<title>Testing</title>
</head>
<body>
<h1>Testing</h1>
<Component />
</body>
</html>
31 changes: 31 additions & 0 deletions packages/integrations/cloudflare/test/with-solid-js.js
@@ -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();
}
});
});
15 changes: 15 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2a1fa09

Please sign in to comment.