0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-23 21:53:55 -05:00

wip: revert sitemap PR

This commit is contained in:
bholmesdev 2022-06-16 11:40:01 -04:00
parent a4c78b544e
commit 7cd2a8a5ea
10 changed files with 6 additions and 84 deletions

View file

@ -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"

View file

@ -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",

View file

@ -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);
},

View file

@ -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';

View file

@ -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
}
})

View file

@ -1,9 +0,0 @@
{
"name": "@test/netlify-edge-astro-dynimport",
"version": "0.0.0",
"private": true,
"dependencies": {
"astro": "workspace:*",
"@astrojs/netlify": "workspace:*"
}
}

View file

@ -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`);

View file

@ -1,4 +0,0 @@
---
---
<div id="thing">testing</div>

View file

@ -1,11 +0,0 @@
---
const { default: Thing } = await import('../components/Thing.astro');
---
<html>
<head>
<title>testing</title>
</head>
<body>
<Thing />
</body>
</html>

View file

@ -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) {