Cloudflare prerender branch
This commit is contained in:
parent
5fd9208d44
commit
f135b0d94b
9 changed files with 85 additions and 3 deletions
|
@ -49,7 +49,7 @@ export default function createIntegration(args?: Options): AstroIntegration {
|
|||
build: {
|
||||
client: new URL(`.${config.base}`, config.outDir),
|
||||
server: new URL(`.${SERVER_BUILD_FOLDER}`, config.outDir),
|
||||
serverEntry: '_worker.js',
|
||||
serverEntry: '_worker.mjs',
|
||||
},
|
||||
});
|
||||
},
|
||||
|
@ -89,9 +89,12 @@ export default function createIntegration(args?: Options): AstroIntegration {
|
|||
}
|
||||
},
|
||||
'astro:build:done': async () => {
|
||||
console.log('BUILD DONE');
|
||||
const entryPath = fileURLToPath(new URL(_buildConfig.serverEntry, _buildConfig.server)),
|
||||
entryUrl = new URL(_buildConfig.serverEntry, _config.outDir),
|
||||
buildPath = fileURLToPath(entryUrl);
|
||||
|
||||
console.log("ENTRY", buildPath);
|
||||
await esbuild.build({
|
||||
target: 'es2020',
|
||||
platform: 'browser',
|
||||
|
|
|
@ -2,7 +2,7 @@ import type { SSRManifest } from 'astro';
|
|||
import { App } from 'astro/app';
|
||||
import { getProcessEnvProxy } from './util.js';
|
||||
|
||||
process.env = getProcessEnvProxy();
|
||||
//process.env = getProcessEnvProxy();
|
||||
|
||||
type Env = {
|
||||
ASSETS: { fetch: (req: Request) => Promise<Response> };
|
||||
|
|
|
@ -2,7 +2,7 @@ import type { SSRManifest } from 'astro';
|
|||
import { App } from 'astro/app';
|
||||
import { getProcessEnvProxy } from './util.js';
|
||||
|
||||
process.env = getProcessEnvProxy();
|
||||
//process.env = getProcessEnvProxy();
|
||||
|
||||
export function createExports(manifest: SSRManifest) {
|
||||
const app = new App(manifest, false);
|
||||
|
|
7
packages/integrations/cloudflare/test/fixtures/prerender/astro.config.mjs
vendored
Normal file
7
packages/integrations/cloudflare/test/fixtures/prerender/astro.config.mjs
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
import { defineConfig } from 'astro/config';
|
||||
import cloudflare from '@astrojs/cloudflare';
|
||||
|
||||
export default defineConfig({
|
||||
adapter: cloudflare(),
|
||||
output: 'server',
|
||||
});
|
9
packages/integrations/cloudflare/test/fixtures/prerender/package.json
vendored
Normal file
9
packages/integrations/cloudflare/test/fixtures/prerender/package.json
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"name": "@test/astro-cloudflare-prerender",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@astrojs/cloudflare": "workspace:*",
|
||||
"astro": "workspace:*"
|
||||
}
|
||||
}
|
8
packages/integrations/cloudflare/test/fixtures/prerender/src/pages/index.astro
vendored
Normal file
8
packages/integrations/cloudflare/test/fixtures/prerender/src/pages/index.astro
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Testing</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Testing</h1>
|
||||
</body>
|
||||
</html>
|
11
packages/integrations/cloudflare/test/fixtures/prerender/src/pages/one.astro
vendored
Normal file
11
packages/integrations/cloudflare/test/fixtures/prerender/src/pages/one.astro
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
---
|
||||
export const prerender = true;
|
||||
---
|
||||
<html>
|
||||
<head>
|
||||
<title>Testing</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Testing</h1>
|
||||
</body>
|
||||
</html>
|
36
packages/integrations/cloudflare/test/prerender.test.js
Normal file
36
packages/integrations/cloudflare/test/prerender.test.js
Normal file
|
@ -0,0 +1,36 @@
|
|||
import { loadFixture } from './test-utils.js';
|
||||
import { expect } from 'chai';
|
||||
|
||||
process.on('exit', () => {
|
||||
console.log('process [exit]');
|
||||
});
|
||||
|
||||
process.on('uncaughtException', err => {
|
||||
console.log('uncaughtException');
|
||||
});
|
||||
|
||||
process.on('unhandledRejection', rej => {
|
||||
console.log('unhandledRejection');
|
||||
});
|
||||
|
||||
describe('Prerendering', () => {
|
||||
/** @type {import('./test-utils').Fixture} */
|
||||
let fixture;
|
||||
|
||||
before(async () => {
|
||||
fixture = await loadFixture({
|
||||
root: './fixtures/prerender/',
|
||||
});
|
||||
try {
|
||||
console.log("BEFORE");
|
||||
await fixture.build();
|
||||
console.log('done');
|
||||
} catch(err) {
|
||||
console.log('after build', err);
|
||||
}
|
||||
});
|
||||
|
||||
it('works', async () => {
|
||||
console.log('works');
|
||||
});
|
||||
});
|
|
@ -2631,6 +2631,14 @@ importers:
|
|||
'@astrojs/cloudflare': link:../../..
|
||||
astro: link:../../../../../astro
|
||||
|
||||
packages/integrations/cloudflare/test/fixtures/prerender:
|
||||
specifiers:
|
||||
'@astrojs/cloudflare': workspace:*
|
||||
astro: workspace:*
|
||||
dependencies:
|
||||
'@astrojs/cloudflare': link:../../..
|
||||
astro: link:../../../../../astro
|
||||
|
||||
packages/integrations/deno:
|
||||
specifiers:
|
||||
astro: workspace:*
|
||||
|
|
Loading…
Reference in a new issue