Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add workerd and worker to cloudflare adapter bundling #7092

Merged
merged 3 commits into from
May 16, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/rich-crews-fry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/cloudflare': minor
---

Add `worked` and `worker` import condition for worker bundling
1 change: 1 addition & 0 deletions packages/integrations/cloudflare/src/index.ts
Original file line number Diff line number Diff line change
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A good followup after this PR would be to clean this file up. I think we forgot to gitignore this directory.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -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',
});
Original file line number Diff line number Diff line change
@@ -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:*"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const Component = () => <div class="solid">Solid Content</div>
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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.