Add workerd
and worker
to cloudflare adapter bundling (#7092)
This commit is contained in:
parent
d7007a1a83
commit
2a1fa09b31
10 changed files with 88 additions and 277 deletions
5
.changeset/rich-crews-fry.md
Normal file
5
.changeset/rich-crews-fry.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'@astrojs/cloudflare': minor
|
||||
---
|
||||
|
||||
Add `worked` and `worker` import condition for worker bundling
|
2
packages/integrations/cloudflare/.gitignore
vendored
Normal file
2
packages/integrations/cloudflare/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
# Astro cloudflare directory mode creates a function directory
|
||||
functions
|
|
@ -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
9
packages/integrations/cloudflare/test/fixtures/with-solid-js/astro.config.mjs
vendored
Normal file
9
packages/integrations/cloudflare/test/fixtures/with-solid-js/astro.config.mjs
vendored
Normal 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',
|
||||
});
|
11
packages/integrations/cloudflare/test/fixtures/with-solid-js/package.json
vendored
Normal file
11
packages/integrations/cloudflare/test/fixtures/with-solid-js/package.json
vendored
Normal 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:*"
|
||||
}
|
||||
}
|
1
packages/integrations/cloudflare/test/fixtures/with-solid-js/src/components/Component.tsx
vendored
Normal file
1
packages/integrations/cloudflare/test/fixtures/with-solid-js/src/components/Component.tsx
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
export const Component = () => <div class="solid">Solid Content</div>
|
13
packages/integrations/cloudflare/test/fixtures/with-solid-js/src/pages/index.astro
vendored
Normal file
13
packages/integrations/cloudflare/test/fixtures/with-solid-js/src/pages/index.astro
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
---
|
||||
import {Component} from "../components/Component";
|
||||
---
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Testing</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Testing</h1>
|
||||
<Component />
|
||||
</body>
|
||||
</html>
|
31
packages/integrations/cloudflare/test/with-solid-js.js
Normal file
31
packages/integrations/cloudflare/test/with-solid-js.js
Normal 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();
|
||||
}
|
||||
});
|
||||
});
|
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue