diff --git a/packages/integrations/cloudflare/src/index.ts b/packages/integrations/cloudflare/src/index.ts index 1df284fbb..e0b2d77bf 100644 --- a/packages/integrations/cloudflare/src/index.ts +++ b/packages/integrations/cloudflare/src/index.ts @@ -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', diff --git a/packages/integrations/cloudflare/src/server.advanced.ts b/packages/integrations/cloudflare/src/server.advanced.ts index 0d765d0bb..f2cc67761 100644 --- a/packages/integrations/cloudflare/src/server.advanced.ts +++ b/packages/integrations/cloudflare/src/server.advanced.ts @@ -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 }; diff --git a/packages/integrations/cloudflare/src/server.directory.ts b/packages/integrations/cloudflare/src/server.directory.ts index 69d008b0f..d72096cd1 100644 --- a/packages/integrations/cloudflare/src/server.directory.ts +++ b/packages/integrations/cloudflare/src/server.directory.ts @@ -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); diff --git a/packages/integrations/cloudflare/test/fixtures/prerender/astro.config.mjs b/packages/integrations/cloudflare/test/fixtures/prerender/astro.config.mjs new file mode 100644 index 000000000..bf47a0a33 --- /dev/null +++ b/packages/integrations/cloudflare/test/fixtures/prerender/astro.config.mjs @@ -0,0 +1,7 @@ +import { defineConfig } from 'astro/config'; +import cloudflare from '@astrojs/cloudflare'; + +export default defineConfig({ + adapter: cloudflare(), + output: 'server', +}); diff --git a/packages/integrations/cloudflare/test/fixtures/prerender/package.json b/packages/integrations/cloudflare/test/fixtures/prerender/package.json new file mode 100644 index 000000000..3b2c5fef5 --- /dev/null +++ b/packages/integrations/cloudflare/test/fixtures/prerender/package.json @@ -0,0 +1,9 @@ +{ + "name": "@test/astro-cloudflare-prerender", + "version": "0.0.0", + "private": true, + "dependencies": { + "@astrojs/cloudflare": "workspace:*", + "astro": "workspace:*" + } +} diff --git a/packages/integrations/cloudflare/test/fixtures/prerender/src/pages/index.astro b/packages/integrations/cloudflare/test/fixtures/prerender/src/pages/index.astro new file mode 100644 index 000000000..dfd71c3de --- /dev/null +++ b/packages/integrations/cloudflare/test/fixtures/prerender/src/pages/index.astro @@ -0,0 +1,8 @@ + + + Testing + + +

Testing

+ + diff --git a/packages/integrations/cloudflare/test/fixtures/prerender/src/pages/one.astro b/packages/integrations/cloudflare/test/fixtures/prerender/src/pages/one.astro new file mode 100644 index 000000000..30386a625 --- /dev/null +++ b/packages/integrations/cloudflare/test/fixtures/prerender/src/pages/one.astro @@ -0,0 +1,11 @@ +--- +export const prerender = true; +--- + + + Testing + + +

Testing

+ + diff --git a/packages/integrations/cloudflare/test/prerender.test.js b/packages/integrations/cloudflare/test/prerender.test.js new file mode 100644 index 000000000..87091c31c --- /dev/null +++ b/packages/integrations/cloudflare/test/prerender.test.js @@ -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'); + }); +}); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b1b1192f5..c986fa468 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -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:*