diff --git a/packages/integrations/deno/package.json b/packages/integrations/deno/package.json index 8392a1469..14d99a1b5 100644 --- a/packages/integrations/deno/package.json +++ b/packages/integrations/deno/package.json @@ -22,7 +22,9 @@ "build": "astro-scripts build \"src/**/*.ts\" && tsc", "build:ci": "astro-scripts build \"src/**/*.ts\"", "dev": "astro-scripts dev \"src/**/*.ts\"", - "test": "deno test --allow-run --allow-env --allow-read --allow-net ./test/" + "test:import": "deno test --allow-run --allow-env --allow-read --allow-net --ignore=test/dynamic-import.test.js ./test/", + "test:subprocess": "deno test --allow-run --allow-env --allow-net ./test/dynamic-import.test.js", + "test": "npm run test:import && npm run test:subprocess" }, "dependencies": { "esbuild": "^0.14.42" diff --git a/packages/integrations/netlify/package.json b/packages/integrations/netlify/package.json index b6672cc45..b9a46ca1e 100644 --- a/packages/integrations/netlify/package.json +++ b/packages/integrations/netlify/package.json @@ -30,8 +30,7 @@ "test": "npm run test-fn" }, "dependencies": { - "@astrojs/webapi": "^0.12.0", - "esbuild": "^0.14.42" + "@astrojs/webapi": "^0.12.0" }, "devDependencies": { "@netlify/edge-handler-types": "^0.34.1", diff --git a/packages/integrations/netlify/src/integration-edge-functions.ts b/packages/integrations/netlify/src/integration-edge-functions.ts index a4bd66e51..e43a7f482 100644 --- a/packages/integrations/netlify/src/integration-edge-functions.ts +++ b/packages/integrations/netlify/src/integration-edge-functions.ts @@ -1,8 +1,5 @@ -import type { AstroAdapter, AstroConfig, AstroIntegration, BuildConfig, RouteData } from 'astro'; -import esbuild from 'esbuild'; +import type { AstroAdapter, AstroConfig, AstroIntegration, RouteData } from 'astro'; import * as fs from 'fs'; -import * as npath from 'path'; -import { fileURLToPath } from 'url'; import { createRedirects } from './shared.js'; export function getAdapter(): AstroAdapter { @@ -65,35 +62,9 @@ async function createEdgeManifest(routes: RouteData[], entryFile: string, dir: U await fs.promises.writeFile(manifestURL, _manifest, 'utf-8'); } -async function bundleServerEntry(buildConfig: BuildConfig, vite: any) { - const entryUrl = new URL(buildConfig.serverEntry, buildConfig.server); - const pth = fileURLToPath(entryUrl); - await esbuild.build({ - target: 'es2020', - platform: 'browser', - entryPoints: [pth], - outfile: pth, - allowOverwrite: true, - format: 'esm', - bundle: true, - external: ['@astrojs/markdown-remark'], - }); - - // Remove chunks, if they exist. Since we have bundled via esbuild these chunks are trash. - try { - const chunkFileNames = - vite?.build?.rollupOptions?.output?.chunkFileNames ?? 'chunks/chunk.[hash].mjs'; - const chunkPath = npath.dirname(chunkFileNames); - const chunksDirUrl = new URL(chunkPath + '/', buildConfig.server); - await fs.promises.rm(chunksDirUrl, { recursive: true, force: true }); - } catch {} -} - export function netlifyEdgeFunctions({ dist }: NetlifyEdgeFunctionsOptions = {}): AstroIntegration { let _config: AstroConfig; let entryFile: string; - let _buildConfig: BuildConfig; - let _vite: any; return { name: '@astrojs/netlify/edge-functions', hooks: { @@ -109,7 +80,6 @@ export function netlifyEdgeFunctions({ dist }: NetlifyEdgeFunctionsOptions = {}) _config = config; }, 'astro:build:start': async ({ buildConfig }) => { - _buildConfig = buildConfig; entryFile = buildConfig.serverEntry.replace(/\.m?js/, ''); buildConfig.client = _config.outDir; buildConfig.server = new URL('./.netlify/edge-functions/', _config.root); @@ -117,7 +87,6 @@ export function netlifyEdgeFunctions({ dist }: NetlifyEdgeFunctionsOptions = {}) }, 'astro:build:setup': ({ vite, target }) => { if (target === 'server') { - _vite = vite; vite.resolve = vite.resolve || {}; vite.resolve.alias = vite.resolve.alias || {}; @@ -137,7 +106,6 @@ export function netlifyEdgeFunctions({ dist }: NetlifyEdgeFunctionsOptions = {}) } }, 'astro:build:done': async ({ routes, dir }) => { - await bundleServerEntry(_buildConfig, _vite); await createEdgeManifest(routes, entryFile, _config.root); await createRedirects(routes, dir, entryFile, true); }, diff --git a/packages/integrations/netlify/test/edge-functions/deps.ts b/packages/integrations/netlify/test/edge-functions/deps.ts index 498b7e09e..1b23a94f7 100644 --- a/packages/integrations/netlify/test/edge-functions/deps.ts +++ b/packages/integrations/netlify/test/edge-functions/deps.ts @@ -2,4 +2,3 @@ export { fromFileUrl } from 'https://deno.land/std@0.110.0/path/mod.ts'; export { assertEquals, assert } from 'https://deno.land/std@0.132.0/testing/asserts.ts'; export * from 'https://deno.land/x/deno_dom/deno-dom-wasm.ts'; -export * from 'https://deno.land/std@0.142.0/streams/conversion.ts'; diff --git a/packages/integrations/netlify/test/edge-functions/fixtures/dynimport/astro.config.mjs b/packages/integrations/netlify/test/edge-functions/fixtures/dynimport/astro.config.mjs deleted file mode 100644 index c55135e43..000000000 --- a/packages/integrations/netlify/test/edge-functions/fixtures/dynimport/astro.config.mjs +++ /dev/null @@ -1,11 +0,0 @@ -import { defineConfig } from 'astro/config'; -import { netlifyEdgeFunctions } from '@astrojs/netlify'; - -export default defineConfig({ - adapter: netlifyEdgeFunctions({ - dist: new URL('./dist/', import.meta.url), - }), - experimental: { - ssr: true - } -}) diff --git a/packages/integrations/netlify/test/edge-functions/fixtures/dynimport/package.json b/packages/integrations/netlify/test/edge-functions/fixtures/dynimport/package.json deleted file mode 100644 index 201a243d0..000000000 --- a/packages/integrations/netlify/test/edge-functions/fixtures/dynimport/package.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "@test/netlify-edge-astro-dynimport", - "version": "0.0.0", - "private": true, - "dependencies": { - "astro": "workspace:*", - "@astrojs/netlify": "workspace:*" - } -} diff --git a/packages/integrations/netlify/test/edge-functions/fixtures/dynimport/prod.js b/packages/integrations/netlify/test/edge-functions/fixtures/dynimport/prod.js deleted file mode 100644 index 3e7d6e64d..000000000 --- a/packages/integrations/netlify/test/edge-functions/fixtures/dynimport/prod.js +++ /dev/null @@ -1,11 +0,0 @@ -import handler from './.netlify/edge-functions/entry.js'; -import { Server } from 'https://deno.land/std@0.132.0/http/server.ts'; - -const _server = new Server({ - port: 8085, - hostname: '0.0.0.0', - handler, -}); - -_server.listenAndServe(); -console.error(`Server running on port 8085`); diff --git a/packages/integrations/netlify/test/edge-functions/fixtures/dynimport/src/components/Thing.astro b/packages/integrations/netlify/test/edge-functions/fixtures/dynimport/src/components/Thing.astro deleted file mode 100644 index 8d8ef929a..000000000 --- a/packages/integrations/netlify/test/edge-functions/fixtures/dynimport/src/components/Thing.astro +++ /dev/null @@ -1,4 +0,0 @@ ---- - ---- -
testing
diff --git a/packages/integrations/netlify/test/edge-functions/fixtures/dynimport/src/pages/index.astro b/packages/integrations/netlify/test/edge-functions/fixtures/dynimport/src/pages/index.astro deleted file mode 100644 index 852cb6201..000000000 --- a/packages/integrations/netlify/test/edge-functions/fixtures/dynimport/src/pages/index.astro +++ /dev/null @@ -1,11 +0,0 @@ ---- -const { default: Thing } = await import('../components/Thing.astro'); ---- - - - testing - - - - - diff --git a/packages/integrations/netlify/test/edge-functions/test-utils.ts b/packages/integrations/netlify/test/edge-functions/test-utils.ts index 7c2400d93..67ab43850 100644 --- a/packages/integrations/netlify/test/edge-functions/test-utils.ts +++ b/packages/integrations/netlify/test/edge-functions/test-utils.ts @@ -1,5 +1,5 @@ // @ts-ignore -import { fromFileUrl, readableStreamFromReader } from './deps.ts'; +import { fromFileUrl } from './deps.ts'; const dir = new URL('./', import.meta.url); export async function runBuild(fixturePath: string) {