Skip to content

Commit

Permalink
wip: revert sitemap PR
Browse files Browse the repository at this point in the history
  • Loading branch information
bholmesdev committed Jun 16, 2022
1 parent a4c78b5 commit 7cd2a8a
Show file tree
Hide file tree
Showing 10 changed files with 6 additions and 84 deletions.
4 changes: 3 additions & 1 deletion packages/integrations/deno/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 1 addition & 2 deletions packages/integrations/netlify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
34 changes: 1 addition & 33 deletions packages/integrations/netlify/src/integration-edge-functions.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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: {
Expand All @@ -109,15 +80,13 @@ 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);
buildConfig.serverEntry = 'entry.js';
},
'astro:build:setup': ({ vite, target }) => {
if (target === 'server') {
_vite = vite;
vite.resolve = vite.resolve || {};
vite.resolve.alias = vite.resolve.alias || {};

Expand All @@ -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);
},
Expand Down
1 change: 0 additions & 1 deletion packages/integrations/netlify/test/edge-functions/deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@
export { fromFileUrl } from 'https://deno.land/[email protected]/path/mod.ts';
export { assertEquals, assert } from 'https://deno.land/[email protected]/testing/asserts.ts';
export * from 'https://deno.land/x/deno_dom/deno-dom-wasm.ts';
export * from 'https://deno.land/[email protected]/streams/conversion.ts';

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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) {
Expand Down

0 comments on commit 7cd2a8a

Please sign in to comment.