Deno adapter (#2934)
* Bundle everything, commit 1 * Get everything working * Remove dependency on readable-stream * Adds a changeset * Fix ts errors * Use the node logger in tests * Callback the logger when done writing * Fix test helper to await the callback * Use serialize-javascript again * Remove dead code * Rename hook * Oops
This commit is contained in:
parent
364ece8776
commit
13b271bc7d
58 changed files with 867 additions and 426 deletions
6
.changeset/sour-eggs-wink.md
Normal file
6
.changeset/sour-eggs-wink.md
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
---
|
||||||
|
'astro': patch
|
||||||
|
'@astrojs/deno': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Add a Deno adapter for SSR
|
5
.github/workflows/ci.yml
vendored
5
.github/workflows/ci.yml
vendored
|
@ -134,6 +134,11 @@ jobs:
|
||||||
node-version: ${{ matrix.node_version }}
|
node-version: ${{ matrix.node_version }}
|
||||||
cache: 'pnpm'
|
cache: 'pnpm'
|
||||||
|
|
||||||
|
- name: Use Deno
|
||||||
|
uses: denoland/setup-deno@v1
|
||||||
|
with:
|
||||||
|
deno-version: v1.19.3
|
||||||
|
|
||||||
- name: Download Build Artifacts
|
- name: Download Build Artifacts
|
||||||
uses: actions/download-artifact@v3
|
uses: actions/download-artifact@v3
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { defineConfig } from 'astro/config';
|
import { defineConfig } from 'astro/config';
|
||||||
import svelte from '@astrojs/svelte';
|
import svelte from '@astrojs/svelte';
|
||||||
import nodejs from '@astrojs/node';
|
import deno from '@astrojs/deno';
|
||||||
|
|
||||||
// https://astro.build/config
|
// https://astro.build/config
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
adapter: nodejs(),
|
adapter: deno(),
|
||||||
integrations: [svelte()],
|
integrations: [svelte()],
|
||||||
});
|
});
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
"build:ci": "turbo run build:ci --no-deps --scope=astro --scope=create-astro --scope=\"@astrojs/*\"",
|
"build:ci": "turbo run build:ci --no-deps --scope=astro --scope=create-astro --scope=\"@astrojs/*\"",
|
||||||
"build:examples": "turbo run build --scope=\"@example/*\"",
|
"build:examples": "turbo run build --scope=\"@example/*\"",
|
||||||
"dev": "turbo run dev --no-deps --no-cache --parallel --scope=astro --scope=create-astro --scope=\"@astrojs/*\"",
|
"dev": "turbo run dev --no-deps --no-cache --parallel --scope=astro --scope=create-astro --scope=\"@astrojs/*\"",
|
||||||
"test": "pnpm run test --filter astro --filter @astrojs/webapi",
|
"test": "pnpm run test --filter astro --filter @astrojs/webapi --filter @astrojs/deno",
|
||||||
"test:match": "cd packages/astro && pnpm run test:match",
|
"test:match": "cd packages/astro && pnpm run test:match",
|
||||||
"test:templates": "pnpm run test --filter create-astro",
|
"test:templates": "pnpm run test --filter create-astro",
|
||||||
"test:smoke": "node scripts/smoke/index.js",
|
"test:smoke": "node scripts/smoke/index.js",
|
||||||
|
|
|
@ -107,6 +107,7 @@
|
||||||
"mime": "^3.0.0",
|
"mime": "^3.0.0",
|
||||||
"ora": "^6.1.0",
|
"ora": "^6.1.0",
|
||||||
"parse5": "^6.0.1",
|
"parse5": "^6.0.1",
|
||||||
|
"path-browserify": "^1.0.1",
|
||||||
"path-to-regexp": "^6.2.0",
|
"path-to-regexp": "^6.2.0",
|
||||||
"postcss": "^8.4.12",
|
"postcss": "^8.4.12",
|
||||||
"postcss-load-config": "^3.1.4",
|
"postcss-load-config": "^3.1.4",
|
||||||
|
@ -148,6 +149,7 @@
|
||||||
"@types/mime": "^2.0.3",
|
"@types/mime": "^2.0.3",
|
||||||
"@types/mocha": "^9.1.0",
|
"@types/mocha": "^9.1.0",
|
||||||
"@types/parse5": "^6.0.3",
|
"@types/parse5": "^6.0.3",
|
||||||
|
"@types/path-browserify": "^1.0.0",
|
||||||
"@types/prettier": "^2.4.4",
|
"@types/prettier": "^2.4.4",
|
||||||
"@types/resolve": "^1.20.1",
|
"@types/resolve": "^1.20.1",
|
||||||
"@types/rimraf": "^3.0.2",
|
"@types/rimraf": "^3.0.2",
|
||||||
|
|
|
@ -4,6 +4,7 @@ import type * as vite from 'vite';
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import type { AstroConfigSchema } from '../core/config';
|
import type { AstroConfigSchema } from '../core/config';
|
||||||
import type { AstroComponentFactory, Metadata } from '../runtime/server';
|
import type { AstroComponentFactory, Metadata } from '../runtime/server';
|
||||||
|
import type { ViteConfigWithSSR } from '../core/create-vite';
|
||||||
export type { SSRManifest } from '../core/app/types';
|
export type { SSRManifest } from '../core/app/types';
|
||||||
|
|
||||||
export interface AstroBuiltinProps {
|
export interface AstroBuiltinProps {
|
||||||
|
@ -680,6 +681,7 @@ export interface AstroIntegration {
|
||||||
'astro:server:start'?: (options: { address: AddressInfo }) => void | Promise<void>;
|
'astro:server:start'?: (options: { address: AddressInfo }) => void | Promise<void>;
|
||||||
'astro:server:done'?: () => void | Promise<void>;
|
'astro:server:done'?: () => void | Promise<void>;
|
||||||
'astro:build:start'?: (options: { buildConfig: BuildConfig }) => void | Promise<void>;
|
'astro:build:start'?: (options: { buildConfig: BuildConfig }) => void | Promise<void>;
|
||||||
|
'astro:build:setup'?: (options: { vite: ViteConfigWithSSR, target: 'client' | 'server' }) => void;
|
||||||
'astro:build:done'?: (options: { pages: { pathname: string }[]; dir: URL; routes: RouteData[] }) => void | Promise<void>;
|
'astro:build:done'?: (options: { pages: { pathname: string }[]; dir: URL; routes: RouteData[] }) => void | Promise<void>;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
/* eslint-disable no-console */
|
/* eslint-disable no-console */
|
||||||
|
|
||||||
import type { AstroConfig } from '../@types/astro';
|
import type { AstroConfig } from '../@types/astro';
|
||||||
import { enableVerboseLogging, LogOptions } from '../core/logger.js';
|
import { LogOptions } from '../core/logger/core.js';
|
||||||
|
|
||||||
import * as colors from 'kleur/colors';
|
import * as colors from 'kleur/colors';
|
||||||
import yargs from 'yargs-parser';
|
import yargs from 'yargs-parser';
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { defaultLogDestination } from '../core/logger.js';
|
import { nodeLogDestination, enableVerboseLogging } from '../core/logger/node.js';
|
||||||
import build from '../core/build/index.js';
|
import build from '../core/build/index.js';
|
||||||
import add from '../core/add/index.js';
|
import add from '../core/add/index.js';
|
||||||
import devServer from '../core/dev/index.js';
|
import devServer from '../core/dev/index.js';
|
||||||
|
@ -87,7 +87,7 @@ export async function cli(args: string[]) {
|
||||||
|
|
||||||
// logLevel
|
// logLevel
|
||||||
let logging: LogOptions = {
|
let logging: LogOptions = {
|
||||||
dest: defaultLogDestination,
|
dest: nodeLogDestination,
|
||||||
level: 'info',
|
level: 'info',
|
||||||
};
|
};
|
||||||
if (flags.verbose) {
|
if (flags.verbose) {
|
||||||
|
|
|
@ -10,7 +10,7 @@ import preferredPM from 'preferred-pm';
|
||||||
import ora from 'ora';
|
import ora from 'ora';
|
||||||
import { resolveConfigURL } from '../config.js';
|
import { resolveConfigURL } from '../config.js';
|
||||||
import { apply as applyPolyfill } from '../polyfill.js';
|
import { apply as applyPolyfill } from '../polyfill.js';
|
||||||
import { error, info, debug, LogOptions } from '../logger.js';
|
import { error, info, debug, LogOptions } from '../logger/core.js';
|
||||||
import { printHelp } from '../messages.js';
|
import { printHelp } from '../messages.js';
|
||||||
import * as msg from '../messages.js';
|
import * as msg from '../messages.js';
|
||||||
import * as CONSTS from './consts.js';
|
import * as CONSTS from './consts.js';
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
import type { ComponentInstance, EndpointHandler, ManifestData, RouteData } from '../../@types/astro';
|
import type { ComponentInstance, EndpointHandler, ManifestData, RouteData } from '../../@types/astro';
|
||||||
import type { SSRManifest as Manifest, RouteInfo } from './types';
|
import type { SSRManifest as Manifest, RouteInfo } from './types';
|
||||||
|
import type { LogOptions } from '../logger/core.js';
|
||||||
|
|
||||||
import mime from 'mime';
|
import mime from 'mime';
|
||||||
import { defaultLogOptions } from '../logger.js';
|
import { consoleLogDestination } from '../logger/console.js';
|
||||||
export { deserializeManifest } from './common.js';
|
export { deserializeManifest } from './common.js';
|
||||||
import { matchRoute } from '../routing/match.js';
|
import { matchRoute } from '../routing/match.js';
|
||||||
import { render } from '../render/core.js';
|
import { render } from '../render/core.js';
|
||||||
|
@ -18,7 +19,10 @@ export class App {
|
||||||
#routeDataToRouteInfo: Map<RouteData, RouteInfo>;
|
#routeDataToRouteInfo: Map<RouteData, RouteInfo>;
|
||||||
#routeCache: RouteCache;
|
#routeCache: RouteCache;
|
||||||
#encoder = new TextEncoder();
|
#encoder = new TextEncoder();
|
||||||
#logging = defaultLogOptions;
|
#logging: LogOptions = {
|
||||||
|
dest: consoleLogDestination,
|
||||||
|
level: 'info'
|
||||||
|
};
|
||||||
|
|
||||||
constructor(manifest: Manifest) {
|
constructor(manifest: Manifest) {
|
||||||
this.#manifest = manifest;
|
this.#manifest = manifest;
|
||||||
|
@ -26,7 +30,7 @@ export class App {
|
||||||
routes: manifest.routes.map((route) => route.routeData),
|
routes: manifest.routes.map((route) => route.routeData),
|
||||||
};
|
};
|
||||||
this.#routeDataToRouteInfo = new Map(manifest.routes.map((route) => [route.routeData, route]));
|
this.#routeDataToRouteInfo = new Map(manifest.routes.map((route) => [route.routeData, route]));
|
||||||
this.#routeCache = new RouteCache(defaultLogOptions);
|
this.#routeCache = new RouteCache(this.#logging);
|
||||||
}
|
}
|
||||||
match(request: Request): RouteData | undefined {
|
match(request: Request): RouteData | undefined {
|
||||||
const url = new URL(request.url);
|
const url = new URL(request.url);
|
||||||
|
@ -105,7 +109,7 @@ export class App {
|
||||||
const url = new URL(request.url);
|
const url = new URL(request.url);
|
||||||
const handler = mod as unknown as EndpointHandler;
|
const handler = mod as unknown as EndpointHandler;
|
||||||
const result = await callEndpoint(handler, {
|
const result = await callEndpoint(handler, {
|
||||||
logging: defaultLogOptions,
|
logging: this.#logging,
|
||||||
origin: url.origin,
|
origin: url.origin,
|
||||||
pathname: url.pathname,
|
pathname: url.pathname,
|
||||||
request,
|
request,
|
||||||
|
|
|
@ -5,7 +5,7 @@ import type { OutputAsset, OutputChunk, RollupOutput } from 'rollup';
|
||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
import type { AstroConfig, ComponentInstance, EndpointHandler, SSRLoadedRenderer } from '../../@types/astro';
|
import type { AstroConfig, ComponentInstance, EndpointHandler, SSRLoadedRenderer } from '../../@types/astro';
|
||||||
import type { BuildInternals } from '../../core/build/internal.js';
|
import type { BuildInternals } from '../../core/build/internal.js';
|
||||||
import { debug, info } from '../../core/logger.js';
|
import { debug, info } from '../logger/core.js';
|
||||||
import { appendForwardSlash, prependForwardSlash } from '../../core/path.js';
|
import { appendForwardSlash, prependForwardSlash } from '../../core/path.js';
|
||||||
import type { RenderOptions } from '../../core/render/core';
|
import type { RenderOptions } from '../../core/render/core';
|
||||||
import { BEFORE_HYDRATION_SCRIPT_ID } from '../../vite-plugin-scripts/index.js';
|
import { BEFORE_HYDRATION_SCRIPT_ID } from '../../vite-plugin-scripts/index.js';
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import type { AstroConfig, BuildConfig, ManifestData } from '../../@types/astro';
|
import type { AstroConfig, BuildConfig, ManifestData } from '../../@types/astro';
|
||||||
import type { LogOptions } from '../logger';
|
import type { LogOptions } from '../logger/core';
|
||||||
|
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import * as colors from 'kleur/colors';
|
import * as colors from 'kleur/colors';
|
||||||
|
@ -7,7 +7,8 @@ import { apply as applyPolyfill } from '../polyfill.js';
|
||||||
import { performance } from 'perf_hooks';
|
import { performance } from 'perf_hooks';
|
||||||
import * as vite from 'vite';
|
import * as vite from 'vite';
|
||||||
import { createVite, ViteConfigWithSSR } from '../create-vite.js';
|
import { createVite, ViteConfigWithSSR } from '../create-vite.js';
|
||||||
import { debug, defaultLogOptions, info, levels, timerMessage, warn, warnIfUsingExperimentalSSR } from '../logger.js';
|
import { debug, info, levels, timerMessage, warn, warnIfUsingExperimentalSSR } from '../logger/core.js';
|
||||||
|
import { nodeLogOptions } from '../logger/node.js';
|
||||||
import { createRouteManifest } from '../routing/index.js';
|
import { createRouteManifest } from '../routing/index.js';
|
||||||
import { generateSitemap } from '../render/sitemap.js';
|
import { generateSitemap } from '../render/sitemap.js';
|
||||||
import { collectPagesData } from './page-data.js';
|
import { collectPagesData } from './page-data.js';
|
||||||
|
@ -25,7 +26,7 @@ export interface BuildOptions {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** `astro build` */
|
/** `astro build` */
|
||||||
export default async function build(config: AstroConfig, options: BuildOptions = { logging: defaultLogOptions }): Promise<void> {
|
export default async function build(config: AstroConfig, options: BuildOptions = { logging: nodeLogOptions }): Promise<void> {
|
||||||
applyPolyfill();
|
applyPolyfill();
|
||||||
const builder = new AstroBuilder(config, options);
|
const builder = new AstroBuilder(config, options);
|
||||||
await builder.run();
|
await builder.run();
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import type { AstroConfig, ComponentInstance, ManifestData, RouteData } from '../../@types/astro';
|
import type { AstroConfig, ComponentInstance, ManifestData, RouteData } from '../../@types/astro';
|
||||||
import type { AllPagesData } from './types';
|
import type { AllPagesData } from './types';
|
||||||
import type { LogOptions } from '../logger';
|
import type { LogOptions } from '../logger/core';
|
||||||
import { info } from '../logger.js';
|
import { info } from '../logger/core.js';
|
||||||
import type { ViteDevServer } from 'vite';
|
import type { ViteDevServer } from 'vite';
|
||||||
|
|
||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
import * as colors from 'kleur/colors';
|
import * as colors from 'kleur/colors';
|
||||||
import { debug } from '../logger.js';
|
import { debug } from '../logger/core.js';
|
||||||
import { preload as ssrPreload } from '../render/dev/index.js';
|
import { preload as ssrPreload } from '../render/dev/index.js';
|
||||||
import { generateRssFunction } from '../render/rss.js';
|
import { generateRssFunction } from '../render/rss.js';
|
||||||
import { callGetStaticPaths, RouteCache, RouteCacheEntry } from '../render/route-cache.js';
|
import { callGetStaticPaths, RouteCache, RouteCacheEntry } from '../render/route-cache.js';
|
||||||
|
|
|
@ -2,7 +2,7 @@ import type { ViteDevServer } from 'vite';
|
||||||
import type { RollupOutput, RollupWatcher } from 'rollup';
|
import type { RollupOutput, RollupWatcher } from 'rollup';
|
||||||
import type { AstroConfig, RouteType } from '../../@types/astro';
|
import type { AstroConfig, RouteType } from '../../@types/astro';
|
||||||
import type { AllPagesData, PageBuildData } from './types';
|
import type { AllPagesData, PageBuildData } from './types';
|
||||||
import type { LogOptions } from '../logger';
|
import type { LogOptions } from '../logger/core';
|
||||||
import type { ViteConfigWithSSR } from '../create-vite.js';
|
import type { ViteConfigWithSSR } from '../create-vite.js';
|
||||||
|
|
||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
|
|
|
@ -9,7 +9,7 @@ import npath from 'path';
|
||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
import * as vite from 'vite';
|
import * as vite from 'vite';
|
||||||
import { createBuildInternals } from '../../core/build/internal.js';
|
import { createBuildInternals } from '../../core/build/internal.js';
|
||||||
import { info } from '../../core/logger.js';
|
import { info } from '../logger/core.js';
|
||||||
import { appendForwardSlash, prependForwardSlash } from '../../core/path.js';
|
import { appendForwardSlash, prependForwardSlash } from '../../core/path.js';
|
||||||
import { emptyDir, removeDir } from '../../core/util.js';
|
import { emptyDir, removeDir } from '../../core/util.js';
|
||||||
import { rollupPluginAstroBuildCSS } from '../../vite-plugin-build-css/index.js';
|
import { rollupPluginAstroBuildCSS } from '../../vite-plugin-build-css/index.js';
|
||||||
|
@ -20,6 +20,7 @@ import { vitePluginPages } from './vite-plugin-pages.js';
|
||||||
import { generatePages } from './generate.js';
|
import { generatePages } from './generate.js';
|
||||||
import { trackPageData } from './internal.js';
|
import { trackPageData } from './internal.js';
|
||||||
import { isBuildingToSSR } from '../util.js';
|
import { isBuildingToSSR } from '../util.js';
|
||||||
|
import { runHookBuildSetup } from '../../integrations/index.js';
|
||||||
import { getTimeStat } from './util.js';
|
import { getTimeStat } from './util.js';
|
||||||
|
|
||||||
export async function staticBuild(opts: StaticBuildOptions) {
|
export async function staticBuild(opts: StaticBuildOptions) {
|
||||||
|
@ -112,8 +113,8 @@ async function ssrBuild(opts: StaticBuildOptions, internals: BuildInternals, inp
|
||||||
const { astroConfig, viteConfig } = opts;
|
const { astroConfig, viteConfig } = opts;
|
||||||
const ssr = astroConfig.buildOptions.experimentalSsr;
|
const ssr = astroConfig.buildOptions.experimentalSsr;
|
||||||
const out = ssr ? opts.buildConfig.server : astroConfig.dist;
|
const out = ssr ? opts.buildConfig.server : astroConfig.dist;
|
||||||
// TODO: use vite.mergeConfig() here?
|
|
||||||
return await vite.build({
|
const viteBuildConfig = {
|
||||||
logLevel: 'error',
|
logLevel: 'error',
|
||||||
mode: 'production',
|
mode: 'production',
|
||||||
css: viteConfig.css,
|
css: viteConfig.css,
|
||||||
|
@ -122,7 +123,6 @@ async function ssrBuild(opts: StaticBuildOptions, internals: BuildInternals, inp
|
||||||
emptyOutDir: false,
|
emptyOutDir: false,
|
||||||
manifest: false,
|
manifest: false,
|
||||||
outDir: fileURLToPath(out),
|
outDir: fileURLToPath(out),
|
||||||
ssr: true,
|
|
||||||
rollupOptions: {
|
rollupOptions: {
|
||||||
input: [],
|
input: [],
|
||||||
output: {
|
output: {
|
||||||
|
@ -132,6 +132,7 @@ async function ssrBuild(opts: StaticBuildOptions, internals: BuildInternals, inp
|
||||||
assetFileNames: 'assets/asset.[hash][extname]',
|
assetFileNames: 'assets/asset.[hash][extname]',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
ssr: true,
|
||||||
// must match an esbuild target
|
// must match an esbuild target
|
||||||
target: 'esnext',
|
target: 'esnext',
|
||||||
// improve build performance
|
// improve build performance
|
||||||
|
@ -156,7 +157,13 @@ async function ssrBuild(opts: StaticBuildOptions, internals: BuildInternals, inp
|
||||||
server: viteConfig.server,
|
server: viteConfig.server,
|
||||||
base: astroConfig.buildOptions.site ? new URL(astroConfig.buildOptions.site).pathname : '/',
|
base: astroConfig.buildOptions.site ? new URL(astroConfig.buildOptions.site).pathname : '/',
|
||||||
ssr: viteConfig.ssr,
|
ssr: viteConfig.ssr,
|
||||||
} as ViteConfigWithSSR);
|
resolve: viteConfig.resolve
|
||||||
|
} as ViteConfigWithSSR;
|
||||||
|
|
||||||
|
await runHookBuildSetup({ config: astroConfig, vite: viteBuildConfig, target: 'server' });
|
||||||
|
|
||||||
|
// TODO: use vite.mergeConfig() here?
|
||||||
|
return await vite.build(viteBuildConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function clientBuild(opts: StaticBuildOptions, internals: BuildInternals, input: Set<string>) {
|
async function clientBuild(opts: StaticBuildOptions, internals: BuildInternals, input: Set<string>) {
|
||||||
|
@ -173,7 +180,7 @@ async function clientBuild(opts: StaticBuildOptions, internals: BuildInternals,
|
||||||
|
|
||||||
const out = isBuildingToSSR(astroConfig) ? opts.buildConfig.client : astroConfig.dist;
|
const out = isBuildingToSSR(astroConfig) ? opts.buildConfig.client : astroConfig.dist;
|
||||||
|
|
||||||
const buildResult = await vite.build({
|
const viteBuildConfig = {
|
||||||
logLevel: 'info',
|
logLevel: 'info',
|
||||||
mode: 'production',
|
mode: 'production',
|
||||||
css: viteConfig.css,
|
css: viteConfig.css,
|
||||||
|
@ -207,7 +214,11 @@ async function clientBuild(opts: StaticBuildOptions, internals: BuildInternals,
|
||||||
envPrefix: 'PUBLIC_',
|
envPrefix: 'PUBLIC_',
|
||||||
server: viteConfig.server,
|
server: viteConfig.server,
|
||||||
base: appendForwardSlash(astroConfig.buildOptions.site ? new URL(astroConfig.buildOptions.site).pathname : '/'),
|
base: appendForwardSlash(astroConfig.buildOptions.site ? new URL(astroConfig.buildOptions.site).pathname : '/'),
|
||||||
});
|
} as ViteConfigWithSSR;
|
||||||
|
|
||||||
|
await runHookBuildSetup({ config: astroConfig, vite: viteBuildConfig, target: 'client' });
|
||||||
|
|
||||||
|
const buildResult = await vite.build(viteBuildConfig);
|
||||||
info(opts.logging, null, dim(`Completed in ${getTimeStat(timer, performance.now())}.\n`));
|
info(opts.logging, null, dim(`Completed in ${getTimeStat(timer, performance.now())}.\n`));
|
||||||
return buildResult;
|
return buildResult;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import type { AstroConfig } from '../@types/astro';
|
import type { AstroConfig } from '../@types/astro';
|
||||||
import type { LogOptions } from './logger';
|
import type { LogOptions } from './logger/core';
|
||||||
|
|
||||||
import { builtinModules } from 'module';
|
import { builtinModules } from 'module';
|
||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
|
@ -81,6 +81,13 @@ export async function createVite(commandConfig: ViteConfigWithSSR, { astroConfig
|
||||||
css: {
|
css: {
|
||||||
postcss: astroConfig.styleOptions.postcss || {},
|
postcss: astroConfig.styleOptions.postcss || {},
|
||||||
},
|
},
|
||||||
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
// This is needed for Deno compatibility, as the non-browser version
|
||||||
|
// of this module depends on Node `crypto`
|
||||||
|
'randombytes': 'randombytes/browser'
|
||||||
|
}
|
||||||
|
},
|
||||||
// Note: SSR API is in beta (https://vitejs.dev/guide/ssr.html)
|
// Note: SSR API is in beta (https://vitejs.dev/guide/ssr.html)
|
||||||
ssr: {
|
ssr: {
|
||||||
external: [...ALWAYS_EXTERNAL],
|
external: [...ALWAYS_EXTERNAL],
|
||||||
|
|
|
@ -4,7 +4,8 @@ import * as vite from 'vite';
|
||||||
import type { AstroConfig } from '../../@types/astro';
|
import type { AstroConfig } from '../../@types/astro';
|
||||||
import { runHookConfigDone, runHookConfigSetup, runHookServerDone, runHookServerSetup, runHookServerStart } from '../../integrations/index.js';
|
import { runHookConfigDone, runHookConfigSetup, runHookServerDone, runHookServerSetup, runHookServerStart } from '../../integrations/index.js';
|
||||||
import { createVite } from '../create-vite.js';
|
import { createVite } from '../create-vite.js';
|
||||||
import { defaultLogOptions, info, LogOptions, warn, warnIfUsingExperimentalSSR } from '../logger.js';
|
import { info, LogOptions, warn, warnIfUsingExperimentalSSR } from '../logger/core.js';
|
||||||
|
import { nodeLogOptions } from '../logger/node.js';
|
||||||
import * as msg from '../messages.js';
|
import * as msg from '../messages.js';
|
||||||
import { apply as applyPolyfill } from '../polyfill.js';
|
import { apply as applyPolyfill } from '../polyfill.js';
|
||||||
import { getResolvedHostForVite } from '../util.js';
|
import { getResolvedHostForVite } from '../util.js';
|
||||||
|
@ -19,7 +20,7 @@ export interface DevServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** `astro dev` */
|
/** `astro dev` */
|
||||||
export default async function dev(config: AstroConfig, options: DevOptions = { logging: defaultLogOptions }): Promise<DevServer> {
|
export default async function dev(config: AstroConfig, options: DevOptions = { logging: nodeLogOptions }): Promise<DevServer> {
|
||||||
const devStart = performance.now();
|
const devStart = performance.now();
|
||||||
applyPolyfill();
|
applyPolyfill();
|
||||||
config = await runHookConfigSetup({ config, command: 'dev' });
|
config = await runHookConfigSetup({ config, command: 'dev' });
|
||||||
|
|
|
@ -1,229 +0,0 @@
|
||||||
import type { AstroConfig } from '../@types/astro';
|
|
||||||
import { bold, cyan, dim, red, yellow, reset } from 'kleur/colors';
|
|
||||||
import { performance } from 'perf_hooks';
|
|
||||||
import { Writable } from 'stream';
|
|
||||||
import stringWidth from 'string-width';
|
|
||||||
import * as readline from 'readline';
|
|
||||||
import debugPackage from 'debug';
|
|
||||||
import { format as utilFormat } from 'util';
|
|
||||||
import { isBuildingToSSR } from './util.js';
|
|
||||||
|
|
||||||
type ConsoleStream = Writable & {
|
|
||||||
fd: 1 | 2;
|
|
||||||
};
|
|
||||||
|
|
||||||
function getLoggerLocale(): string {
|
|
||||||
const defaultLocale = 'en-US';
|
|
||||||
if (process.env.LANG) {
|
|
||||||
const extractedLocale = process.env.LANG.split('.')[0].replace(/_/g, '-');
|
|
||||||
// Check if language code is atleast two characters long (ie. en, es).
|
|
||||||
// NOTE: if "c" locale is encountered, the default locale will be returned.
|
|
||||||
if (extractedLocale.length < 2) return defaultLocale;
|
|
||||||
else return extractedLocale.substring(0, 5);
|
|
||||||
} else return defaultLocale;
|
|
||||||
}
|
|
||||||
|
|
||||||
const dt = new Intl.DateTimeFormat(getLoggerLocale(), {
|
|
||||||
hour: '2-digit',
|
|
||||||
minute: '2-digit',
|
|
||||||
second: '2-digit',
|
|
||||||
});
|
|
||||||
|
|
||||||
let lastMessage: string;
|
|
||||||
let lastMessageCount = 1;
|
|
||||||
export const defaultLogDestination = new Writable({
|
|
||||||
objectMode: true,
|
|
||||||
write(event: LogMessage, _, callback) {
|
|
||||||
let dest: ConsoleStream = process.stderr;
|
|
||||||
if (levels[event.level] < levels['error']) {
|
|
||||||
dest = process.stdout;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getPrefix() {
|
|
||||||
let prefix = '';
|
|
||||||
let type = event.type;
|
|
||||||
if (type) {
|
|
||||||
// hide timestamp when type is undefined
|
|
||||||
prefix += dim(dt.format(new Date()) + ' ');
|
|
||||||
if (event.level === 'info') {
|
|
||||||
type = bold(cyan(`[${type}]`));
|
|
||||||
} else if (event.level === 'warn') {
|
|
||||||
type = bold(yellow(`[${type}]`));
|
|
||||||
} else if (event.level === 'error') {
|
|
||||||
type = bold(red(`[${type}]`));
|
|
||||||
}
|
|
||||||
|
|
||||||
prefix += `${type} `;
|
|
||||||
}
|
|
||||||
return reset(prefix);
|
|
||||||
}
|
|
||||||
|
|
||||||
let message = utilFormat(...event.args);
|
|
||||||
// For repeat messages, only update the message counter
|
|
||||||
if (message === lastMessage) {
|
|
||||||
lastMessageCount++;
|
|
||||||
if (levels[event.level] < levels['error']) {
|
|
||||||
let lines = 1;
|
|
||||||
let len = stringWidth(`${getPrefix()}${message}`);
|
|
||||||
let cols = (dest as typeof process.stdout).columns;
|
|
||||||
if (len > cols) {
|
|
||||||
lines = Math.ceil(len / cols);
|
|
||||||
}
|
|
||||||
for (let i = 0; i < lines; i++) {
|
|
||||||
readline.clearLine(dest, 0);
|
|
||||||
readline.cursorTo(dest, 0);
|
|
||||||
readline.moveCursor(dest, 0, -1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
message = `${message} ${yellow(`(x${lastMessageCount})`)}`;
|
|
||||||
} else {
|
|
||||||
lastMessage = message;
|
|
||||||
lastMessageCount = 1;
|
|
||||||
}
|
|
||||||
dest.write(getPrefix());
|
|
||||||
dest.write(message);
|
|
||||||
dest.write('\n');
|
|
||||||
|
|
||||||
callback();
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
interface LogWritable<T> extends Writable {
|
|
||||||
write: (chunk: T) => boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type LoggerLevel = 'debug' | 'info' | 'warn' | 'error' | 'silent'; // same as Pino
|
|
||||||
export type LoggerEvent = 'info' | 'warn' | 'error';
|
|
||||||
|
|
||||||
export interface LogOptions {
|
|
||||||
dest?: LogWritable<LogMessage>;
|
|
||||||
level?: LoggerLevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const defaultLogOptions: Required<LogOptions> = {
|
|
||||||
dest: defaultLogDestination,
|
|
||||||
level: 'info',
|
|
||||||
};
|
|
||||||
|
|
||||||
export interface LogMessage {
|
|
||||||
type: string | null;
|
|
||||||
level: LoggerLevel;
|
|
||||||
message: string;
|
|
||||||
args: Array<any>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const levels: Record<LoggerLevel, number> = {
|
|
||||||
debug: 20,
|
|
||||||
info: 30,
|
|
||||||
warn: 40,
|
|
||||||
error: 50,
|
|
||||||
silent: 90,
|
|
||||||
};
|
|
||||||
|
|
||||||
export function enableVerboseLogging() {
|
|
||||||
debugPackage.enable('*,-babel');
|
|
||||||
debug('cli', '--verbose flag enabled! Enabling: DEBUG="*,-babel"');
|
|
||||||
debug('cli', 'Tip: Set the DEBUG env variable directly for more control. Example: "DEBUG=astro:*,vite:* astro build".');
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Full logging API */
|
|
||||||
export function log(opts: LogOptions = {}, level: LoggerLevel, type: string | null, ...args: Array<any>) {
|
|
||||||
const logLevel = opts.level ?? defaultLogOptions.level;
|
|
||||||
const dest = opts.dest ?? defaultLogOptions.dest;
|
|
||||||
const event: LogMessage = {
|
|
||||||
type,
|
|
||||||
level,
|
|
||||||
args,
|
|
||||||
message: '',
|
|
||||||
};
|
|
||||||
|
|
||||||
// test if this level is enabled or not
|
|
||||||
if (levels[logLevel] > levels[level]) {
|
|
||||||
return; // do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
dest.write(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
const debuggers: Record<string, debugPackage.Debugger['log']> = {};
|
|
||||||
/**
|
|
||||||
* Emit a message only shown in debug mode.
|
|
||||||
* Astro (along with many of its dependencies) uses the `debug` package for debug logging.
|
|
||||||
* You can enable these logs with the `DEBUG=astro:*` environment variable.
|
|
||||||
* More info https://github.com/debug-js/debug#environment-variables
|
|
||||||
*/
|
|
||||||
export function debug(type: string, ...messages: Array<any>) {
|
|
||||||
const namespace = `astro:${type}`;
|
|
||||||
debuggers[namespace] = debuggers[namespace] || debugPackage(namespace);
|
|
||||||
return debuggers[namespace](...messages);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Emit a user-facing message. Useful for UI and other console messages. */
|
|
||||||
export function info(opts: LogOptions, type: string | null, ...messages: Array<any>) {
|
|
||||||
return log(opts, 'info', type, ...messages);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Emit a warning message. Useful for high-priority messages that aren't necessarily errors. */
|
|
||||||
export function warn(opts: LogOptions, type: string | null, ...messages: Array<any>) {
|
|
||||||
return log(opts, 'warn', type, ...messages);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Emit a error message, Useful when Astro can't recover from some error. */
|
|
||||||
export function error(opts: LogOptions, type: string | null, ...messages: Array<any>) {
|
|
||||||
return log(opts, 'error', type, ...messages);
|
|
||||||
}
|
|
||||||
|
|
||||||
type LogFn = typeof info | typeof warn | typeof error;
|
|
||||||
|
|
||||||
export function table(opts: LogOptions, columns: number[]) {
|
|
||||||
return function logTable(logFn: LogFn, ...input: Array<any>) {
|
|
||||||
const messages = columns.map((len, i) => padStr(input[i].toString(), len));
|
|
||||||
logFn(opts, null, ...messages);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// A default logger for when too lazy to pass LogOptions around.
|
|
||||||
export const logger = {
|
|
||||||
info: info.bind(null, defaultLogOptions),
|
|
||||||
warn: warn.bind(null, defaultLogOptions),
|
|
||||||
error: error.bind(null, defaultLogOptions),
|
|
||||||
};
|
|
||||||
|
|
||||||
function padStr(str: string, len: number) {
|
|
||||||
const strLen = stringWidth(str);
|
|
||||||
if (strLen > len) {
|
|
||||||
return str.substring(0, len - 3) + '...';
|
|
||||||
}
|
|
||||||
const spaces = Array.from({ length: len - strLen }, () => ' ').join('');
|
|
||||||
return str + spaces;
|
|
||||||
}
|
|
||||||
|
|
||||||
export let defaultLogLevel: LoggerLevel;
|
|
||||||
if (process.argv.includes('--verbose')) {
|
|
||||||
defaultLogLevel = 'debug';
|
|
||||||
} else if (process.argv.includes('--silent')) {
|
|
||||||
defaultLogLevel = 'silent';
|
|
||||||
} else {
|
|
||||||
defaultLogLevel = 'info';
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Print out a timer message for debug() */
|
|
||||||
export function timerMessage(message: string, startTime: number = performance.now()) {
|
|
||||||
let timeDiff = performance.now() - startTime;
|
|
||||||
let timeDisplay = timeDiff < 750 ? `${Math.round(timeDiff)}ms` : `${(timeDiff / 1000).toFixed(1)}s`;
|
|
||||||
return `${message} ${dim(timeDisplay)}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A warning that SSR is experimental. Remove when we can.
|
|
||||||
*/
|
|
||||||
export function warnIfUsingExperimentalSSR(opts: LogOptions, config: AstroConfig) {
|
|
||||||
if (isBuildingToSSR(config)) {
|
|
||||||
warn(
|
|
||||||
opts,
|
|
||||||
'warning',
|
|
||||||
bold(`Warning:`),
|
|
||||||
` SSR support is still experimental and subject to API changes. If using in production pin your dependencies to prevent accidental breakage.`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
51
packages/astro/src/core/logger/console.ts
Normal file
51
packages/astro/src/core/logger/console.ts
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
import type { AstroConfig } from '../../@types/astro';
|
||||||
|
import type { LogMessage } from './core.js';
|
||||||
|
import { bold, cyan, dim, red, yellow, reset } from 'kleur/colors';
|
||||||
|
import stringWidth from 'string-width';
|
||||||
|
import { format as utilFormat } from 'util';
|
||||||
|
import { levels, dateTimeFormat } from './core.js';
|
||||||
|
|
||||||
|
let lastMessage: string;
|
||||||
|
let lastMessageCount = 1;
|
||||||
|
export const consoleLogDestination = {
|
||||||
|
write(event: LogMessage) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
let dest = console.error;
|
||||||
|
if (levels[event.level] < levels['error']) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
dest = console.log;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getPrefix() {
|
||||||
|
let prefix = '';
|
||||||
|
let type = event.type;
|
||||||
|
if (type) {
|
||||||
|
// hide timestamp when type is undefined
|
||||||
|
prefix += dim(dateTimeFormat.format(new Date()) + ' ');
|
||||||
|
if (event.level === 'info') {
|
||||||
|
type = bold(cyan(`[${type}]`));
|
||||||
|
} else if (event.level === 'warn') {
|
||||||
|
type = bold(yellow(`[${type}]`));
|
||||||
|
} else if (event.level === 'error') {
|
||||||
|
type = bold(red(`[${type}]`));
|
||||||
|
}
|
||||||
|
|
||||||
|
prefix += `${type} `;
|
||||||
|
}
|
||||||
|
return reset(prefix);
|
||||||
|
}
|
||||||
|
|
||||||
|
let message = utilFormat(...event.args);
|
||||||
|
// For repeat messages, only update the message counter
|
||||||
|
if (message === lastMessage) {
|
||||||
|
lastMessageCount++;
|
||||||
|
message = `${message} ${yellow(`(x${lastMessageCount})`)}`;
|
||||||
|
} else {
|
||||||
|
lastMessage = message;
|
||||||
|
lastMessageCount = 1;
|
||||||
|
}
|
||||||
|
const outMessage = getPrefix() + message;
|
||||||
|
dest(outMessage);
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
};
|
139
packages/astro/src/core/logger/core.ts
Normal file
139
packages/astro/src/core/logger/core.ts
Normal file
|
@ -0,0 +1,139 @@
|
||||||
|
import type { AstroConfig } from '../../@types/astro';
|
||||||
|
import { bold, dim } from 'kleur/colors';
|
||||||
|
import stringWidth from 'string-width';
|
||||||
|
|
||||||
|
interface LogWritable<T> {
|
||||||
|
write: (chunk: T) => boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type LoggerLevel = 'debug' | 'info' | 'warn' | 'error' | 'silent'; // same as Pino
|
||||||
|
export type LoggerEvent = 'info' | 'warn' | 'error';
|
||||||
|
|
||||||
|
export interface LogOptions {
|
||||||
|
dest: LogWritable<LogMessage>;
|
||||||
|
level: LoggerLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getLoggerLocale(): string {
|
||||||
|
const defaultLocale = 'en-US';
|
||||||
|
if (process.env.LANG) {
|
||||||
|
const extractedLocale = process.env.LANG.split('.')[0].replace(/_/g, '-');
|
||||||
|
// Check if language code is atleast two characters long (ie. en, es).
|
||||||
|
// NOTE: if "c" locale is encountered, the default locale will be returned.
|
||||||
|
if (extractedLocale.length < 2) return defaultLocale;
|
||||||
|
else return extractedLocale.substring(0, 5);
|
||||||
|
} else return defaultLocale;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const dateTimeFormat = new Intl.DateTimeFormat(getLoggerLocale(), {
|
||||||
|
hour: '2-digit',
|
||||||
|
minute: '2-digit',
|
||||||
|
second: '2-digit',
|
||||||
|
});
|
||||||
|
|
||||||
|
export interface LogMessage {
|
||||||
|
type: string | null;
|
||||||
|
level: LoggerLevel;
|
||||||
|
message: string;
|
||||||
|
args: Array<any>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const levels: Record<LoggerLevel, number> = {
|
||||||
|
debug: 20,
|
||||||
|
info: 30,
|
||||||
|
warn: 40,
|
||||||
|
error: 50,
|
||||||
|
silent: 90,
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Full logging API */
|
||||||
|
export function log(opts: LogOptions, level: LoggerLevel, type: string | null, ...args: Array<any>) {
|
||||||
|
const logLevel = opts.level;
|
||||||
|
const dest = opts.dest;
|
||||||
|
const event: LogMessage = {
|
||||||
|
type,
|
||||||
|
level,
|
||||||
|
args,
|
||||||
|
message: '',
|
||||||
|
};
|
||||||
|
|
||||||
|
// test if this level is enabled or not
|
||||||
|
if (levels[logLevel] > levels[level]) {
|
||||||
|
return; // do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
dest.write(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Emit a user-facing message. Useful for UI and other console messages. */
|
||||||
|
export function info(opts: LogOptions, type: string | null, ...messages: Array<any>) {
|
||||||
|
return log(opts, 'info', type, ...messages);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Emit a warning message. Useful for high-priority messages that aren't necessarily errors. */
|
||||||
|
export function warn(opts: LogOptions, type: string | null, ...messages: Array<any>) {
|
||||||
|
return log(opts, 'warn', type, ...messages);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Emit a error message, Useful when Astro can't recover from some error. */
|
||||||
|
export function error(opts: LogOptions, type: string | null, ...messages: Array<any>) {
|
||||||
|
return log(opts, 'error', type, ...messages);
|
||||||
|
}
|
||||||
|
|
||||||
|
type LogFn = typeof info | typeof warn | typeof error;
|
||||||
|
|
||||||
|
export function table(opts: LogOptions, columns: number[]) {
|
||||||
|
return function logTable(logFn: LogFn, ...input: Array<any>) {
|
||||||
|
const messages = columns.map((len, i) => padStr(input[i].toString(), len));
|
||||||
|
logFn(opts, null, ...messages);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function debug(...args: any[]) {
|
||||||
|
if('_astroGlobalDebug' in globalThis) {
|
||||||
|
(globalThis as any)._astroGlobalDebug(...args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function padStr(str: string, len: number) {
|
||||||
|
const strLen = stringWidth(str);
|
||||||
|
if (strLen > len) {
|
||||||
|
return str.substring(0, len - 3) + '...';
|
||||||
|
}
|
||||||
|
const spaces = Array.from({ length: len - strLen }, () => ' ').join('');
|
||||||
|
return str + spaces;
|
||||||
|
}
|
||||||
|
|
||||||
|
export let defaultLogLevel: LoggerLevel;
|
||||||
|
if(typeof process !== 'undefined') {
|
||||||
|
if (process.argv.includes('--verbose')) {
|
||||||
|
defaultLogLevel = 'debug';
|
||||||
|
} else if (process.argv.includes('--silent')) {
|
||||||
|
defaultLogLevel = 'silent';
|
||||||
|
} else {
|
||||||
|
defaultLogLevel = 'info';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
defaultLogLevel = 'info';
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Print out a timer message for debug() */
|
||||||
|
export function timerMessage(message: string, startTime: number = Date.now()) {
|
||||||
|
let timeDiff = Date.now() - startTime;
|
||||||
|
let timeDisplay = timeDiff < 750 ? `${Math.round(timeDiff)}ms` : `${(timeDiff / 1000).toFixed(1)}s`;
|
||||||
|
return `${message} ${dim(timeDisplay)}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A warning that SSR is experimental. Remove when we can.
|
||||||
|
*/
|
||||||
|
export function warnIfUsingExperimentalSSR(opts: LogOptions, config: AstroConfig) {
|
||||||
|
if (config._ctx.adapter?.serverEntrypoint) {
|
||||||
|
warn(
|
||||||
|
opts,
|
||||||
|
'warning',
|
||||||
|
bold(`Warning:`),
|
||||||
|
` SSR support is still experimental and subject to API changes. If using in production pin your dependencies to prevent accidental breakage.`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
133
packages/astro/src/core/logger/node.ts
Normal file
133
packages/astro/src/core/logger/node.ts
Normal file
|
@ -0,0 +1,133 @@
|
||||||
|
import { bold, cyan, dim, red, yellow, reset } from 'kleur/colors';
|
||||||
|
import stringWidth from 'string-width';
|
||||||
|
import debugPackage from 'debug';
|
||||||
|
import { format as utilFormat } from 'util';
|
||||||
|
import * as readline from 'readline';
|
||||||
|
import { Writable } from 'stream';
|
||||||
|
import { info, warn, error, dateTimeFormat } from './core.js';
|
||||||
|
|
||||||
|
type ConsoleStream = Writable & {
|
||||||
|
fd: 1 | 2;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
let lastMessage: string;
|
||||||
|
let lastMessageCount = 1;
|
||||||
|
export const nodeLogDestination = new Writable({
|
||||||
|
objectMode: true,
|
||||||
|
write(event: LogMessage, _, callback) {
|
||||||
|
let dest: ConsoleStream = process.stderr;
|
||||||
|
if (levels[event.level] < levels['error']) {
|
||||||
|
dest = process.stdout;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getPrefix() {
|
||||||
|
let prefix = '';
|
||||||
|
let type = event.type;
|
||||||
|
if (type) {
|
||||||
|
// hide timestamp when type is undefined
|
||||||
|
prefix += dim(dateTimeFormat.format(new Date()) + ' ');
|
||||||
|
if (event.level === 'info') {
|
||||||
|
type = bold(cyan(`[${type}]`));
|
||||||
|
} else if (event.level === 'warn') {
|
||||||
|
type = bold(yellow(`[${type}]`));
|
||||||
|
} else if (event.level === 'error') {
|
||||||
|
type = bold(red(`[${type}]`));
|
||||||
|
}
|
||||||
|
|
||||||
|
prefix += `${type} `;
|
||||||
|
}
|
||||||
|
return reset(prefix);
|
||||||
|
}
|
||||||
|
|
||||||
|
let message = utilFormat(...event.args);
|
||||||
|
// For repeat messages, only update the message counter
|
||||||
|
if (message === lastMessage) {
|
||||||
|
lastMessageCount++;
|
||||||
|
if (levels[event.level] < levels['error']) {
|
||||||
|
let lines = 1;
|
||||||
|
let len = stringWidth(`${getPrefix()}${message}`);
|
||||||
|
let cols = (dest as unknown as typeof process.stdout).columns;
|
||||||
|
if (len > cols) {
|
||||||
|
lines = Math.ceil(len / cols);
|
||||||
|
}
|
||||||
|
for (let i = 0; i < lines; i++) {
|
||||||
|
readline.clearLine(dest, 0);
|
||||||
|
readline.cursorTo(dest, 0);
|
||||||
|
readline.moveCursor(dest, 0, -1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
message = `${message} ${yellow(`(x${lastMessageCount})`)}`;
|
||||||
|
} else {
|
||||||
|
lastMessage = message;
|
||||||
|
lastMessageCount = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
dest.write(getPrefix());
|
||||||
|
dest.write(message);
|
||||||
|
dest.write('\n');
|
||||||
|
callback();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
interface LogWritable<T> {
|
||||||
|
write: (chunk: T) => boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type LoggerLevel = 'debug' | 'info' | 'warn' | 'error' | 'silent'; // same as Pino
|
||||||
|
export type LoggerEvent = 'info' | 'warn' | 'error';
|
||||||
|
|
||||||
|
export interface LogOptions {
|
||||||
|
dest?: LogWritable<LogMessage>;
|
||||||
|
level?: LoggerLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const nodeLogOptions: Required<LogOptions> = {
|
||||||
|
dest: nodeLogDestination,
|
||||||
|
level: 'info',
|
||||||
|
};
|
||||||
|
|
||||||
|
export interface LogMessage {
|
||||||
|
type: string | null;
|
||||||
|
level: LoggerLevel;
|
||||||
|
message: string;
|
||||||
|
args: Array<any>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const levels: Record<LoggerLevel, number> = {
|
||||||
|
debug: 20,
|
||||||
|
info: 30,
|
||||||
|
warn: 40,
|
||||||
|
error: 50,
|
||||||
|
silent: 90,
|
||||||
|
};
|
||||||
|
|
||||||
|
const debuggers: Record<string, debugPackage.Debugger['log']> = {};
|
||||||
|
/**
|
||||||
|
* Emit a message only shown in debug mode.
|
||||||
|
* Astro (along with many of its dependencies) uses the `debug` package for debug logging.
|
||||||
|
* You can enable these logs with the `DEBUG=astro:*` environment variable.
|
||||||
|
* More info https://github.com/debug-js/debug#environment-variables
|
||||||
|
*/
|
||||||
|
export function debug(type: string, ...messages: Array<any>) {
|
||||||
|
const namespace = `astro:${type}`;
|
||||||
|
debuggers[namespace] = debuggers[namespace] || debugPackage(namespace);
|
||||||
|
return debuggers[namespace](...messages);
|
||||||
|
}
|
||||||
|
|
||||||
|
// This is gross, but necessary since we are depending on globals.
|
||||||
|
(globalThis as any)._astroGlobalDebug = debug;
|
||||||
|
|
||||||
|
// A default logger for when too lazy to pass LogOptions around.
|
||||||
|
export const logger = {
|
||||||
|
info: info.bind(null, nodeLogOptions),
|
||||||
|
warn: warn.bind(null, nodeLogOptions),
|
||||||
|
error: error.bind(null, nodeLogOptions),
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
export function enableVerboseLogging() {
|
||||||
|
//debugPackage.enable('*,-babel');
|
||||||
|
debug('cli', '--verbose flag enabled! Enabling: DEBUG="*,-babel"');
|
||||||
|
debug('cli', 'Tip: Set the DEBUG env variable directly for more control. Example: "DEBUG=astro:*,vite:* astro build".');
|
||||||
|
}
|
|
@ -1,12 +1,12 @@
|
||||||
import type { AstroConfig } from '../../@types/astro';
|
import type { AstroConfig } from '../../@types/astro';
|
||||||
import type { LogOptions } from '../logger';
|
import type { LogOptions } from '../logger/core';
|
||||||
import type { AddressInfo } from 'net';
|
import type { AddressInfo } from 'net';
|
||||||
import http from 'http';
|
import http from 'http';
|
||||||
import sirv from 'sirv';
|
import sirv from 'sirv';
|
||||||
import { performance } from 'perf_hooks';
|
import { performance } from 'perf_hooks';
|
||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
import * as msg from '../messages.js';
|
import * as msg from '../messages.js';
|
||||||
import { error, info } from '../logger.js';
|
import { error, info } from '../logger/core.js';
|
||||||
import { subpathNotUsedTemplate, notFoundTemplate } from '../../template/4xx.js';
|
import { subpathNotUsedTemplate, notFoundTemplate } from '../../template/4xx.js';
|
||||||
import { getResolvedHostForHttpServer } from './util.js';
|
import { getResolvedHostForHttpServer } from './util.js';
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import type { ComponentInstance, EndpointHandler, MarkdownRenderOptions, Params, Props, SSRLoadedRenderer, RouteData, SSRElement } from '../../@types/astro';
|
import type { ComponentInstance, EndpointHandler, MarkdownRenderOptions, Params, Props, SSRLoadedRenderer, RouteData, SSRElement } from '../../@types/astro';
|
||||||
import type { LogOptions } from '../logger.js';
|
import type { LogOptions } from '../logger/core.js';
|
||||||
|
|
||||||
import { renderHead, renderPage } from '../../runtime/server/index.js';
|
import { renderHead, renderPage } from '../../runtime/server/index.js';
|
||||||
import { getParams } from '../routing/index.js';
|
import { getParams } from '../routing/params.js';
|
||||||
import { createResult } from './result.js';
|
import { createResult } from './result.js';
|
||||||
import { findPathItemByKey, RouteCache, callGetStaticPaths } from './route-cache.js';
|
import { findPathItemByKey, RouteCache, callGetStaticPaths } from './route-cache.js';
|
||||||
|
|
||||||
|
|
|
@ -2,16 +2,7 @@ import type * as vite from 'vite';
|
||||||
|
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { unwrapId, viteID } from '../../util.js';
|
import { unwrapId, viteID } from '../../util.js';
|
||||||
|
import { STYLE_EXTENSIONS } from '../util.js';
|
||||||
// https://vitejs.dev/guide/features.html#css-pre-processors
|
|
||||||
export const STYLE_EXTENSIONS = new Set(['.css', '.pcss', '.postcss', '.scss', '.sass', '.styl', '.stylus', '.less']);
|
|
||||||
|
|
||||||
const cssRe = new RegExp(
|
|
||||||
`\\.(${Array.from(STYLE_EXTENSIONS)
|
|
||||||
.map((s) => s.slice(1))
|
|
||||||
.join('|')})($|\\?)`
|
|
||||||
);
|
|
||||||
export const isCSSRequest = (request: string): boolean => cssRe.test(request);
|
|
||||||
|
|
||||||
/** Given a filePath URL, crawl Vite’s module graph to find all style imports. */
|
/** Given a filePath URL, crawl Vite’s module graph to find all style imports. */
|
||||||
export function getStylesForURL(filePath: URL, viteServer: vite.ViteDevServer): Set<string> {
|
export function getStylesForURL(filePath: URL, viteServer: vite.ViteDevServer): Set<string> {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
import type * as vite from 'vite';
|
import type * as vite from 'vite';
|
||||||
import type { AstroConfig, AstroRenderer, ComponentInstance, RouteData, RuntimeMode, SSRElement, SSRLoadedRenderer } from '../../../@types/astro';
|
import type { AstroConfig, AstroRenderer, ComponentInstance, RouteData, RuntimeMode, SSRElement, SSRLoadedRenderer } from '../../../@types/astro';
|
||||||
import { LogOptions } from '../../logger.js';
|
import { LogOptions } from '../../logger/core.js';
|
||||||
import { render as coreRender } from '../core.js';
|
import { render as coreRender } from '../core.js';
|
||||||
import { prependForwardSlash } from '../../../core/path.js';
|
import { prependForwardSlash } from '../../../core/path.js';
|
||||||
import { RouteCache } from '../route-cache.js';
|
import { RouteCache } from '../route-cache.js';
|
||||||
|
|
103
packages/astro/src/core/render/pretty-feed.ts
Normal file
103
packages/astro/src/core/render/pretty-feed.ts
Normal file
File diff suppressed because one or more lines are too long
|
@ -1,9 +1,8 @@
|
||||||
import { bold } from 'kleur/colors';
|
import { bold } from 'kleur/colors';
|
||||||
import type { AstroGlobal, AstroGlobalPartial, MarkdownParser, MarkdownRenderOptions, Params, SSRElement, SSRLoadedRenderer, SSRResult } from '../../@types/astro';
|
import type { AstroGlobal, AstroGlobalPartial, MarkdownParser, MarkdownRenderOptions, Params, SSRElement, SSRLoadedRenderer, SSRResult } from '../../@types/astro';
|
||||||
import { renderSlot } from '../../runtime/server/index.js';
|
import { renderSlot } from '../../runtime/server/index.js';
|
||||||
import { LogOptions, warn } from '../logger.js';
|
import { LogOptions, warn } from '../logger/core.js';
|
||||||
import { isCSSRequest } from './dev/css.js';
|
import { createCanonicalURL, isCSSRequest } from './util.js';
|
||||||
import { canonicalURL as utilCanonicalURL } from '../util.js';
|
|
||||||
import { isScriptRequest } from './script.js';
|
import { isScriptRequest } from './script.js';
|
||||||
|
|
||||||
function onlyAvailableInSSR(name: string) {
|
function onlyAvailableInSSR(name: string) {
|
||||||
|
@ -71,10 +70,10 @@ class Slots {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createResult(args: CreateResultArgs): SSRResult {
|
export function createResult(args: CreateResultArgs): SSRResult {
|
||||||
const { legacyBuild, markdownRender, origin, params, pathname, renderers, request, resolve, site } = args;
|
const { legacyBuild, markdownRender, params, pathname, renderers, request, resolve, site } = args;
|
||||||
|
|
||||||
const url = new URL(request.url);
|
const url = new URL(request.url);
|
||||||
const canonicalURL = utilCanonicalURL('.' + pathname, site ?? url.origin);
|
const canonicalURL = createCanonicalURL('.' + pathname, site ?? url.origin);
|
||||||
|
|
||||||
// Create the result object that will be passed into the render function.
|
// Create the result object that will be passed into the render function.
|
||||||
// This object starts here as an empty shell (not yet the result) but then
|
// This object starts here as an empty shell (not yet the result) but then
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import type { ComponentInstance, GetStaticPathsItem, GetStaticPathsResult, GetStaticPathsResultKeyed, Params, RouteData, RSS } from '../../@types/astro';
|
import type { ComponentInstance, GetStaticPathsItem, GetStaticPathsResult, GetStaticPathsResultKeyed, Params, RouteData, RSS } from '../../@types/astro';
|
||||||
import { LogOptions, warn, debug } from '../logger.js';
|
import { LogOptions, warn, debug } from '../logger/core.js';
|
||||||
|
|
||||||
import { generatePaginateFunction } from './paginate.js';
|
import { generatePaginateFunction } from './paginate.js';
|
||||||
import { validateGetStaticPathsModule, validateGetStaticPathsResult } from '../routing/index.js';
|
import { validateGetStaticPathsModule, validateGetStaticPathsResult } from '../routing/validation.js';
|
||||||
|
|
||||||
type RSSFn = (...args: any[]) => any;
|
type RSSFn = (...args: any[]) => any;
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
import type { RSSFunction, RSS, RSSResult, RouteData } from '../../@types/astro';
|
import type { RSSFunction, RSS, RSSResult, RouteData } from '../../@types/astro';
|
||||||
|
|
||||||
import { XMLValidator } from 'fast-xml-parser';
|
import { XMLValidator } from 'fast-xml-parser';
|
||||||
import { canonicalURL, isValidURL, PRETTY_FEED_V3 } from '../util.js';
|
import { PRETTY_FEED_V3 } from './pretty-feed.js';
|
||||||
|
import { createCanonicalURL, isValidURL } from './util.js';
|
||||||
|
|
||||||
/** Validates getStaticPaths.rss */
|
/** Validates getStaticPaths.rss */
|
||||||
export function validateRSS(args: GenerateRSSArgs): void {
|
export function validateRSS(args: GenerateRSSArgs): void {
|
||||||
|
@ -38,7 +39,7 @@ export function generateRSS(args: GenerateRSSArgs): string {
|
||||||
// title, description, customData
|
// title, description, customData
|
||||||
xml += `<title><![CDATA[${rssData.title}]]></title>`;
|
xml += `<title><![CDATA[${rssData.title}]]></title>`;
|
||||||
xml += `<description><![CDATA[${rssData.description}]]></description>`;
|
xml += `<description><![CDATA[${rssData.description}]]></description>`;
|
||||||
xml += `<link>${canonicalURL(site).href}</link>`;
|
xml += `<link>${createCanonicalURL(site).href}</link>`;
|
||||||
if (typeof rssData.customData === 'string') xml += rssData.customData;
|
if (typeof rssData.customData === 'string') xml += rssData.customData;
|
||||||
// items
|
// items
|
||||||
for (const result of rssData.items) {
|
for (const result of rssData.items) {
|
||||||
|
@ -49,7 +50,7 @@ export function generateRSS(args: GenerateRSSArgs): string {
|
||||||
if (!result.link) throw new Error(`[${srcFile}] rss.items required "link" property is missing. got: "${JSON.stringify(result)}"`);
|
if (!result.link) throw new Error(`[${srcFile}] rss.items required "link" property is missing. got: "${JSON.stringify(result)}"`);
|
||||||
xml += `<title><![CDATA[${result.title}]]></title>`;
|
xml += `<title><![CDATA[${result.title}]]></title>`;
|
||||||
// If the item's link is already a valid URL, don't mess with it.
|
// If the item's link is already a valid URL, don't mess with it.
|
||||||
const itemLink = isValidURL(result.link) ? result.link : canonicalURL(result.link, site).href;
|
const itemLink = isValidURL(result.link) ? result.link : createCanonicalURL(result.link, site).href;
|
||||||
xml += `<link>${itemLink}</link>`;
|
xml += `<link>${itemLink}</link>`;
|
||||||
xml += `<guid>${itemLink}</guid>`;
|
xml += `<guid>${itemLink}</guid>`;
|
||||||
if (result.description) xml += `<description><![CDATA[${result.description}]]></description>`;
|
if (result.description) xml += `<description><![CDATA[${result.description}]]></description>`;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import type { SSRElement } from '../../@types/astro';
|
import type { SSRElement } from '../../@types/astro';
|
||||||
|
|
||||||
import npath from 'path';
|
import npath from 'path-browserify';
|
||||||
import { appendForwardSlash } from '../../core/path.js';
|
import { appendForwardSlash } from '../../core/path.js';
|
||||||
|
|
||||||
function getRootPath(site?: string): string {
|
function getRootPath(site?: string): string {
|
||||||
|
|
29
packages/astro/src/core/render/util.ts
Normal file
29
packages/astro/src/core/render/util.ts
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
import npath from 'path-browserify';
|
||||||
|
|
||||||
|
/** Normalize URL to its canonical form */
|
||||||
|
export function createCanonicalURL(url: string, base?: string): URL {
|
||||||
|
let pathname = url.replace(/\/index.html$/, ''); // index.html is not canonical
|
||||||
|
pathname = pathname.replace(/\/1\/?$/, ''); // neither is a trailing /1/ (impl. detail of collections)
|
||||||
|
if (!npath.extname(pathname)) pathname = pathname.replace(/(\/+)?$/, '/'); // add trailing slash if there’s no extension
|
||||||
|
pathname = pathname.replace(/\/+/g, '/'); // remove duplicate slashes (URL() won’t)
|
||||||
|
return new URL(pathname, base);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Check if a URL is already valid */
|
||||||
|
export function isValidURL(url: string): boolean {
|
||||||
|
try {
|
||||||
|
new URL(url);
|
||||||
|
return true;
|
||||||
|
} catch (e) {}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://vitejs.dev/guide/features.html#css-pre-processors
|
||||||
|
export const STYLE_EXTENSIONS = new Set(['.css', '.pcss', '.postcss', '.scss', '.sass', '.styl', '.stylus', '.less']);
|
||||||
|
|
||||||
|
const cssRe = new RegExp(
|
||||||
|
`\\.(${Array.from(STYLE_EXTENSIONS)
|
||||||
|
.map((s) => s.slice(1))
|
||||||
|
.join('|')})($|\\?)`
|
||||||
|
);
|
||||||
|
export const isCSSRequest = (request: string): boolean => cssRe.test(request);
|
|
@ -1,6 +1,6 @@
|
||||||
import type { IncomingHttpHeaders } from 'http';
|
import type { IncomingHttpHeaders } from 'http';
|
||||||
import type { LogOptions } from './logger';
|
import type { LogOptions } from './logger/core';
|
||||||
import { warn } from './logger.js';
|
import { warn } from './logger/core.js';
|
||||||
|
|
||||||
type HeaderType = Headers | Record<string, any> | IncomingHttpHeaders;
|
type HeaderType = Headers | Record<string, any> | IncomingHttpHeaders;
|
||||||
type RequestBody = ArrayBuffer | Blob | ReadableStream | URLSearchParams | FormData;
|
type RequestBody = ArrayBuffer | Blob | ReadableStream | URLSearchParams | FormData;
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import type { AstroConfig, ManifestData, RouteData } from '../../../@types/astro';
|
import type { AstroConfig, ManifestData, RouteData } from '../../../@types/astro';
|
||||||
import type { LogOptions } from '../../logger';
|
import type { LogOptions } from '../../logger/core';
|
||||||
|
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { compile } from 'path-to-regexp';
|
import { compile } from 'path-to-regexp';
|
||||||
import slash from 'slash';
|
import slash from 'slash';
|
||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
import { warn } from '../../logger.js';
|
import { warn } from '../../logger/core.js';
|
||||||
|
|
||||||
interface Part {
|
interface Part {
|
||||||
content: string;
|
content: string;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import type { ComponentInstance, GetStaticPathsResult } from '../../@types/astro';
|
import type { ComponentInstance, GetStaticPathsResult } from '../../@types/astro';
|
||||||
import type { LogOptions } from '../logger';
|
import type { LogOptions } from '../logger/core';
|
||||||
import { warn } from '../logger.js';
|
import { warn } from '../logger/core.js';
|
||||||
|
|
||||||
interface ValidationOptions {
|
interface ValidationOptions {
|
||||||
ssr: boolean;
|
ssr: boolean;
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -3,6 +3,7 @@ import type { ViteDevServer } from 'vite';
|
||||||
import { AstroConfig, AstroRenderer, BuildConfig, RouteData } from '../@types/astro.js';
|
import { AstroConfig, AstroRenderer, BuildConfig, RouteData } from '../@types/astro.js';
|
||||||
import { mergeConfig } from '../core/config.js';
|
import { mergeConfig } from '../core/config.js';
|
||||||
import ssgAdapter from '../adapter-ssg/index.js';
|
import ssgAdapter from '../adapter-ssg/index.js';
|
||||||
|
import type { ViteConfigWithSSR } from '../core/create-vite.js';
|
||||||
|
|
||||||
export async function runHookConfigSetup({ config: _config, command }: { config: AstroConfig; command: 'dev' | 'build' }): Promise<AstroConfig> {
|
export async function runHookConfigSetup({ config: _config, command }: { config: AstroConfig; command: 'dev' | 'build' }): Promise<AstroConfig> {
|
||||||
if (_config.adapter) {
|
if (_config.adapter) {
|
||||||
|
@ -91,6 +92,14 @@ export async function runHookBuildStart({ config, buildConfig }: { config: Astro
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function runHookBuildSetup({ config, vite, target }: { config: AstroConfig, vite: ViteConfigWithSSR, target: 'server' | 'client' }) {
|
||||||
|
for (const integration of config.integrations) {
|
||||||
|
if (integration.hooks['astro:build:setup']) {
|
||||||
|
await integration.hooks['astro:build:setup']({ vite, target });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export async function runHookBuildDone({ config, pages, routes }: { config: AstroConfig; pages: string[]; routes: RouteData[] }) {
|
export async function runHookBuildDone({ config, pages, routes }: { config: AstroConfig; pages: string[]; routes: RouteData[] }) {
|
||||||
for (const integration of config.integrations) {
|
for (const integration of config.integrations) {
|
||||||
if (integration.hooks['astro:build:done']) {
|
if (integration.hooks['astro:build:done']) {
|
||||||
|
|
|
@ -2,7 +2,7 @@ import type * as vite from 'vite';
|
||||||
import type http from 'http';
|
import type http from 'http';
|
||||||
import type { AstroConfig, ManifestData } from '../@types/astro';
|
import type { AstroConfig, ManifestData } from '../@types/astro';
|
||||||
import type { RenderResponse, SSROptions } from '../core/render/dev/index';
|
import type { RenderResponse, SSROptions } from '../core/render/dev/index';
|
||||||
import { debug, info, warn, error, LogOptions } from '../core/logger.js';
|
import { debug, info, warn, error, LogOptions } from '../core/logger/core.js';
|
||||||
import { getParamsAndProps, GetParamsAndPropsError } from '../core/render/core.js';
|
import { getParamsAndProps, GetParamsAndPropsError } from '../core/render/core.js';
|
||||||
import { createRouteManifest, matchRoute } from '../core/routing/index.js';
|
import { createRouteManifest, matchRoute } from '../core/routing/index.js';
|
||||||
import stripAnsi from 'strip-ansi';
|
import stripAnsi from 'strip-ansi';
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import type { AstroConfig } from '../@types/astro';
|
import type { AstroConfig } from '../@types/astro';
|
||||||
import type { LogOptions } from '../core/logger.js';
|
import type { LogOptions } from '../core/logger/core.js';
|
||||||
import type { ViteDevServer, ModuleNode, HmrContext } from 'vite';
|
import type { ViteDevServer, ModuleNode, HmrContext } from 'vite';
|
||||||
import type { PluginContext as RollupPluginContext, ResolvedId } from 'rollup';
|
import type { PluginContext as RollupPluginContext, ResolvedId } from 'rollup';
|
||||||
import { invalidateCompilation, isCached } from './compile.js';
|
import { invalidateCompilation, isCached } from './compile.js';
|
||||||
import { info } from '../core/logger.js';
|
import { info } from '../core/logger/core.js';
|
||||||
import * as msg from '../core/messages.js';
|
import * as msg from '../core/messages.js';
|
||||||
|
|
||||||
interface TrackCSSDependenciesOptions {
|
interface TrackCSSDependenciesOptions {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import type * as vite from 'vite';
|
import type * as vite from 'vite';
|
||||||
import type { PluginContext } from 'rollup';
|
import type { PluginContext } from 'rollup';
|
||||||
import type { AstroConfig } from '../@types/astro';
|
import type { AstroConfig } from '../@types/astro';
|
||||||
import type { LogOptions } from '../core/logger.js';
|
import type { LogOptions } from '../core/logger/core.js';
|
||||||
|
|
||||||
import esbuild from 'esbuild';
|
import esbuild from 'esbuild';
|
||||||
import { fileURLToPath } from 'url';
|
import { fileURLToPath } from 'url';
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import type * as vite from 'vite';
|
import type * as vite from 'vite';
|
||||||
|
|
||||||
import { STYLE_EXTENSIONS } from '../core/render/dev/css.js';
|
import { STYLE_EXTENSIONS } from '../core/render/util.js';
|
||||||
|
|
||||||
export type TransformHook = (code: string, id: string, ssr?: boolean) => Promise<vite.TransformResult>;
|
export type TransformHook = (code: string, id: string, ssr?: boolean) => Promise<vite.TransformResult>;
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,8 @@ import type { ModuleInfo, PluginContext } from 'rollup';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import esbuild from 'esbuild';
|
import esbuild from 'esbuild';
|
||||||
import { Plugin as VitePlugin } from 'vite';
|
import { Plugin as VitePlugin } from 'vite';
|
||||||
import { isCSSRequest } from '../core/render/dev/css.js';
|
import { isCSSRequest } from '../core/render/util.js';
|
||||||
import { getPageDatasByChunk, getPageDataByViteID, hasPageDataByViteID } from '../core/build/internal.js';
|
import { getPageDatasByChunk, getPageDataByViteID, hasPageDataByViteID } from '../core/build/internal.js';
|
||||||
import { resolvedVirtualModuleId as virtualPagesModuleId } from '../core/build/vite-plugin-pages.js';
|
|
||||||
|
|
||||||
const PLUGIN_NAME = '@astrojs/rollup-plugin-build-css';
|
const PLUGIN_NAME = '@astrojs/rollup-plugin-build-css';
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ import type { Plugin as VitePlugin, ViteDevServer } from 'vite';
|
||||||
import type { AstroConfig } from '../@types/astro';
|
import type { AstroConfig } from '../@types/astro';
|
||||||
import type { BuildInternals } from '../core/build/internal';
|
import type { BuildInternals } from '../core/build/internal';
|
||||||
import type { AllPagesData } from '../core/build/types';
|
import type { AllPagesData } from '../core/build/types';
|
||||||
import type { LogOptions } from '../core/logger.js';
|
import type { LogOptions } from '../core/logger/core.js';
|
||||||
import { prependDotSlash } from '../core/path.js';
|
import { prependDotSlash } from '../core/path.js';
|
||||||
import { render as ssrRender } from '../core/render/dev/index.js';
|
import { render as ssrRender } from '../core/render/dev/index.js';
|
||||||
import { RouteCache } from '../core/render/route-cache.js';
|
import { RouteCache } from '../core/render/route-cache.js';
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
import type { TransformResult } from 'rollup';
|
import type { TransformResult } from 'rollup';
|
||||||
import type { Plugin, ResolvedConfig } from 'vite';
|
import type { Plugin, ResolvedConfig } from 'vite';
|
||||||
import type { AstroConfig, AstroRenderer } from '../@types/astro';
|
import type { AstroConfig, AstroRenderer } from '../@types/astro';
|
||||||
import type { LogOptions } from '../core/logger.js';
|
import type { LogOptions } from '../core/logger/core.js';
|
||||||
|
|
||||||
import babel from '@babel/core';
|
import babel from '@babel/core';
|
||||||
import esbuild from 'esbuild';
|
import esbuild from 'esbuild';
|
||||||
import * as colors from 'kleur/colors';
|
import * as colors from 'kleur/colors';
|
||||||
import * as eslexer from 'es-module-lexer';
|
import * as eslexer from 'es-module-lexer';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { error } from '../core/logger.js';
|
import { error } from '../core/logger/core.js';
|
||||||
import { parseNpmName } from '../core/util.js';
|
import { parseNpmName } from '../core/util.js';
|
||||||
|
|
||||||
const JSX_RENDERER_CACHE = new WeakMap<AstroConfig, Map<string, AstroRenderer>>();
|
const JSX_RENDERER_CACHE = new WeakMap<AstroConfig, Map<string, AstroRenderer>>();
|
||||||
|
|
|
@ -6,7 +6,7 @@ import { resolveConfig, loadConfig } from '../dist/core/config.js';
|
||||||
import dev from '../dist/core/dev/index.js';
|
import dev from '../dist/core/dev/index.js';
|
||||||
import build from '../dist/core/build/index.js';
|
import build from '../dist/core/build/index.js';
|
||||||
import preview from '../dist/core/preview/index.js';
|
import preview from '../dist/core/preview/index.js';
|
||||||
import { loadApp } from '../dist/core/app/node.js';
|
import { nodeLogDestination } from '../dist/core/logger/node.js';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import stripAnsi from 'strip-ansi';
|
import stripAnsi from 'strip-ansi';
|
||||||
|
|
||||||
|
@ -71,17 +71,23 @@ export async function loadFixture(inlineConfig) {
|
||||||
let config = await loadConfig({ cwd: fileURLToPath(cwd) });
|
let config = await loadConfig({ cwd: fileURLToPath(cwd) });
|
||||||
config = merge(config, { ...inlineConfig, projectRoot: cwd });
|
config = merge(config, { ...inlineConfig, projectRoot: cwd });
|
||||||
|
|
||||||
|
/** @type {import('../src/core/logger/core').LogOptions} */
|
||||||
|
const logging = {
|
||||||
|
dest: nodeLogDestination,
|
||||||
|
level: 'error'
|
||||||
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
build: (opts = {}) => build(config, { mode: 'development', logging: 'error', ...opts }),
|
build: (opts = {}) => build(config, { mode: 'development', logging, ...opts }),
|
||||||
startDevServer: async (opts = {}) => {
|
startDevServer: async (opts = {}) => {
|
||||||
const devResult = await dev(config, { logging: 'error', ...opts });
|
const devResult = await dev(config, { logging, ...opts });
|
||||||
config.devOptions.port = devResult.address.port; // update port
|
config.devOptions.port = devResult.address.port; // update port
|
||||||
return devResult;
|
return devResult;
|
||||||
},
|
},
|
||||||
config,
|
config,
|
||||||
fetch: (url, init) => fetch(`http://${'127.0.0.1'}:${config.devOptions.port}${url.replace(/^\/?/, '/')}`, init),
|
fetch: (url, init) => fetch(`http://${'127.0.0.1'}:${config.devOptions.port}${url.replace(/^\/?/, '/')}`, init),
|
||||||
preview: async (opts = {}) => {
|
preview: async (opts = {}) => {
|
||||||
const previewServer = await preview(config, { logging: 'error', ...opts });
|
const previewServer = await preview(config, { logging, ...opts });
|
||||||
return previewServer;
|
return previewServer;
|
||||||
},
|
},
|
||||||
readFile: (filePath) => fs.promises.readFile(new URL(filePath.replace(/^\//, ''), config.dist), 'utf8'),
|
readFile: (filePath) => fs.promises.readFile(new URL(filePath.replace(/^\//, ''), config.dist), 'utf8'),
|
||||||
|
|
7
packages/integrations/deno/CHANGELOG.md
Normal file
7
packages/integrations/deno/CHANGELOG.md
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
# @astrojs/node
|
||||||
|
|
||||||
|
## 0.0.2-next.0
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- [#2873](https://github.com/withastro/astro/pull/2873) [`e4025d1f`](https://github.com/withastro/astro/commit/e4025d1f530310d6ab951109f4f53878a307471a) Thanks [@matthewp](https://github.com/matthewp)! - Improves the build by building to a single file for rendering
|
30
packages/integrations/deno/package.json
Normal file
30
packages/integrations/deno/package.json
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
{
|
||||||
|
"name": "@astrojs/deno",
|
||||||
|
"description": "Deploy your site to a Deno server",
|
||||||
|
"version": "0.0.2-next.0",
|
||||||
|
"type": "module",
|
||||||
|
"types": "./dist/index.d.ts",
|
||||||
|
"author": "withastro",
|
||||||
|
"license": "MIT",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/withastro/astro.git",
|
||||||
|
"directory": "packages/integrations/deno"
|
||||||
|
},
|
||||||
|
"bugs": "https://github.com/withastro/astro/issues",
|
||||||
|
"homepage": "https://astro.build",
|
||||||
|
"exports": {
|
||||||
|
".": "./dist/index.js",
|
||||||
|
"./server.js": "./dist/server.js",
|
||||||
|
"./package.json": "./package.json"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"build": "astro-scripts build \"src/**/*.ts\" && tsc",
|
||||||
|
"dev": "astro-scripts dev \"src/**/*.ts\"",
|
||||||
|
"test": "deno test --allow-run --allow-read --allow-net ./test/"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"astro": "workspace:*",
|
||||||
|
"astro-scripts": "workspace:*"
|
||||||
|
}
|
||||||
|
}
|
66
packages/integrations/deno/readme.md
Normal file
66
packages/integrations/deno/readme.md
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
# @astrojs/deno
|
||||||
|
|
||||||
|
A server-side rendering adapter for use with Deno targets. Write your code in Astro/Node and deploy to Deno servers.
|
||||||
|
|
||||||
|
In your astro.config.mjs use:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import { defineConfig } from 'astro/config';
|
||||||
|
import deno from '@astrojs/deno';
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
adapter: deno()
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
After performing a build there will be a `dist/server/entry.mjs` module. You can start a server simply by importing this module:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import './dist/entry.mjs';
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
### Adapter options
|
||||||
|
|
||||||
|
This adapter automatically starts a server when it is imported. You can configure this through options:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import { defineConfig } from 'astro/config';
|
||||||
|
import deno from '@astrojs/deno';
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
adapter: deno({
|
||||||
|
start: false
|
||||||
|
})
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
If disabling start you need to write your own web server and use `handle` to render requests:
|
||||||
|
|
||||||
|
```ts
|
||||||
|
import { serve } from "https://deno.land/std@0.132.0/http/server.ts";
|
||||||
|
import { handle } from './dist/entry.mjs';
|
||||||
|
|
||||||
|
serve((req: Request) => {
|
||||||
|
// Check the request, maybe do static file handling here.
|
||||||
|
|
||||||
|
return handle(req);
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
|
You an also pass in a port/hostname to use:
|
||||||
|
|
||||||
|
```js
|
||||||
|
import { defineConfig } from 'astro/config';
|
||||||
|
import deno from '@astrojs/deno';
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
adapter: deno({
|
||||||
|
port: 8081,
|
||||||
|
hostname: 'myhost'
|
||||||
|
})
|
||||||
|
});
|
||||||
|
```
|
33
packages/integrations/deno/src/index.ts
Normal file
33
packages/integrations/deno/src/index.ts
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
import type { AstroAdapter, AstroIntegration } from 'astro';
|
||||||
|
|
||||||
|
interface Options {
|
||||||
|
port?: number;
|
||||||
|
hostname?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getAdapter(args?: Options): AstroAdapter {
|
||||||
|
return {
|
||||||
|
name: '@astrojs/deno',
|
||||||
|
serverEntrypoint: '@astrojs/deno/server.js',
|
||||||
|
args: args ?? {},
|
||||||
|
exports: ['stop', 'handle']
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function createIntegration(args?: Options): AstroIntegration {
|
||||||
|
return {
|
||||||
|
name: '@astrojs/deno',
|
||||||
|
hooks: {
|
||||||
|
'astro:config:done': ({ setAdapter }) => {
|
||||||
|
setAdapter(getAdapter(args));
|
||||||
|
},
|
||||||
|
'astro:build:setup': ({ vite, target }) => {
|
||||||
|
if(target === 'server') {
|
||||||
|
vite.ssr = {
|
||||||
|
noExternal: true
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
51
packages/integrations/deno/src/server.ts
Normal file
51
packages/integrations/deno/src/server.ts
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
import './shim.js';
|
||||||
|
import type { SSRManifest } from 'astro';
|
||||||
|
import { App } from 'astro/app';
|
||||||
|
// @ts-ignore
|
||||||
|
import { Server } from "https://deno.land/std@0.132.0/http/server.ts";
|
||||||
|
|
||||||
|
interface Options {
|
||||||
|
port?: number;
|
||||||
|
hostname?: string;
|
||||||
|
start?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
let _server: Server | undefined = undefined;
|
||||||
|
let _startPromise: Promise<void> | undefined = undefined;
|
||||||
|
|
||||||
|
export function start(manifest: SSRManifest, options: Options) {
|
||||||
|
if(options.start === false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const app = new App(manifest);
|
||||||
|
|
||||||
|
const handler = async (request: Request) => {
|
||||||
|
const response = await app.render(request);
|
||||||
|
return response;
|
||||||
|
};
|
||||||
|
|
||||||
|
_server = new Server({
|
||||||
|
port: options.port ?? 8085,
|
||||||
|
hostname: options.hostname ?? "0.0.0.0",
|
||||||
|
handler,
|
||||||
|
//onError: options.onError,
|
||||||
|
});
|
||||||
|
|
||||||
|
_startPromise = _server.listenAndServe();
|
||||||
|
}
|
||||||
|
|
||||||
|
export function createExports(manifest: SSRManifest) {
|
||||||
|
const app = new App(manifest);
|
||||||
|
return {
|
||||||
|
async stop() {
|
||||||
|
if(_server) {
|
||||||
|
_server.close();
|
||||||
|
}
|
||||||
|
await Promise.resolve(_startPromise);
|
||||||
|
},
|
||||||
|
async handle(request: Request) {
|
||||||
|
return app.render(request);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
5
packages/integrations/deno/src/shim.ts
Normal file
5
packages/integrations/deno/src/shim.ts
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
|
||||||
|
(globalThis as any).process = {
|
||||||
|
argv: [],
|
||||||
|
env: {}
|
||||||
|
};
|
14
packages/integrations/deno/test/basics.test.js
Normal file
14
packages/integrations/deno/test/basics.test.js
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
import { runBuildAndStartApp } from './helpers.js';
|
||||||
|
import { assertEquals, assert } from './deps.js';
|
||||||
|
|
||||||
|
Deno.test({
|
||||||
|
name: 'Basics',
|
||||||
|
async fn() {
|
||||||
|
await runBuildAndStartApp('./fixtures/basics/', async () => {
|
||||||
|
const resp = await fetch('http://127.0.0.1:8085/');
|
||||||
|
assertEquals(resp.status, 200);
|
||||||
|
const html = await resp.text();
|
||||||
|
assert(html);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
2
packages/integrations/deno/test/deps.js
Normal file
2
packages/integrations/deno/test/deps.js
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
export * from 'https://deno.land/std@0.110.0/path/mod.ts';
|
||||||
|
export * from 'https://deno.land/std@0.132.0/testing/asserts.ts';
|
6
packages/integrations/deno/test/fixtures/basics/astro.config.mjs
vendored
Normal file
6
packages/integrations/deno/test/fixtures/basics/astro.config.mjs
vendored
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
import { defineConfig } from 'astro/config';
|
||||||
|
import deno from '@astrojs/deno';
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
adapter: deno()
|
||||||
|
})
|
9
packages/integrations/deno/test/fixtures/basics/package.json
vendored
Normal file
9
packages/integrations/deno/test/fixtures/basics/package.json
vendored
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
{
|
||||||
|
"name": "@test/deno-astro-basic",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"private": true,
|
||||||
|
"dependencies": {
|
||||||
|
"astro": "workspace:*",
|
||||||
|
"@astrojs/deno": "workspace:*"
|
||||||
|
}
|
||||||
|
}
|
11
packages/integrations/deno/test/fixtures/basics/src/pages/index.astro
vendored
Normal file
11
packages/integrations/deno/test/fixtures/basics/src/pages/index.astro
vendored
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
---
|
||||||
|
|
||||||
|
---
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Basic App on Deno</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Basic App on Deno</h1>
|
||||||
|
</body>
|
||||||
|
</html>
|
20
packages/integrations/deno/test/helpers.js
Normal file
20
packages/integrations/deno/test/helpers.js
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
import { fromFileUrl } from './deps.js';
|
||||||
|
const dir = new URL('./', import.meta.url);
|
||||||
|
|
||||||
|
export async function runBuild(fixturePath) {
|
||||||
|
let proc = Deno.run({
|
||||||
|
cmd: ['node', '../../../../../astro/astro.js', 'build', '--silent'],
|
||||||
|
cwd: fromFileUrl(new URL(fixturePath, dir))
|
||||||
|
});
|
||||||
|
await proc.status();
|
||||||
|
return async () => await proc.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function runBuildAndStartApp(fixturePath, cb) {
|
||||||
|
const url = new URL(fixturePath, dir);
|
||||||
|
const close = await runBuild(fixturePath);
|
||||||
|
const mod = await import(new URL('./dist/entry.mjs', url));
|
||||||
|
await cb();
|
||||||
|
await mod.stop();
|
||||||
|
await close();
|
||||||
|
}
|
10
packages/integrations/deno/tsconfig.json
Normal file
10
packages/integrations/deno/tsconfig.json
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"extends": "../../../tsconfig.base.json",
|
||||||
|
"include": ["src"],
|
||||||
|
"compilerOptions": {
|
||||||
|
"allowJs": true,
|
||||||
|
"module": "ES2020",
|
||||||
|
"outDir": "./dist",
|
||||||
|
"target": "ES2020"
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
# @astrojs/node
|
# @astrojs/node
|
||||||
|
|
||||||
An experimental static-side rendering adapter for use with Node.js servers.
|
An experimental server-side rendering adapter for use with Node.js servers.
|
||||||
|
|
||||||
In your astro.config.mjs use:
|
In your astro.config.mjs use:
|
||||||
|
|
||||||
|
|
28
pnpm-lock.yaml
generated
28
pnpm-lock.yaml
generated
|
@ -467,6 +467,7 @@ importers:
|
||||||
'@types/mime': ^2.0.3
|
'@types/mime': ^2.0.3
|
||||||
'@types/mocha': ^9.1.0
|
'@types/mocha': ^9.1.0
|
||||||
'@types/parse5': ^6.0.3
|
'@types/parse5': ^6.0.3
|
||||||
|
'@types/path-browserify': ^1.0.0
|
||||||
'@types/prettier': ^2.4.4
|
'@types/prettier': ^2.4.4
|
||||||
'@types/resolve': ^1.20.1
|
'@types/resolve': ^1.20.1
|
||||||
'@types/rimraf': ^3.0.2
|
'@types/rimraf': ^3.0.2
|
||||||
|
@ -499,6 +500,7 @@ importers:
|
||||||
mocha: ^9.2.2
|
mocha: ^9.2.2
|
||||||
ora: ^6.1.0
|
ora: ^6.1.0
|
||||||
parse5: ^6.0.1
|
parse5: ^6.0.1
|
||||||
|
path-browserify: ^1.0.1
|
||||||
path-to-regexp: ^6.2.0
|
path-to-regexp: ^6.2.0
|
||||||
postcss: ^8.4.12
|
postcss: ^8.4.12
|
||||||
postcss-load-config: ^3.1.4
|
postcss-load-config: ^3.1.4
|
||||||
|
@ -560,6 +562,7 @@ importers:
|
||||||
mime: 3.0.0
|
mime: 3.0.0
|
||||||
ora: 6.1.0
|
ora: 6.1.0
|
||||||
parse5: 6.0.1
|
parse5: 6.0.1
|
||||||
|
path-browserify: 1.0.1
|
||||||
path-to-regexp: 6.2.0
|
path-to-regexp: 6.2.0
|
||||||
postcss: 8.4.12
|
postcss: 8.4.12
|
||||||
postcss-load-config: 3.1.4_postcss@8.4.12
|
postcss-load-config: 3.1.4_postcss@8.4.12
|
||||||
|
@ -600,6 +603,7 @@ importers:
|
||||||
'@types/mime': 2.0.3
|
'@types/mime': 2.0.3
|
||||||
'@types/mocha': 9.1.0
|
'@types/mocha': 9.1.0
|
||||||
'@types/parse5': 6.0.3
|
'@types/parse5': 6.0.3
|
||||||
|
'@types/path-browserify': 1.0.0
|
||||||
'@types/prettier': 2.4.4
|
'@types/prettier': 2.4.4
|
||||||
'@types/resolve': 1.20.1
|
'@types/resolve': 1.20.1
|
||||||
'@types/rimraf': 3.0.2
|
'@types/rimraf': 3.0.2
|
||||||
|
@ -1190,6 +1194,22 @@ importers:
|
||||||
astro-scripts: link:../../scripts
|
astro-scripts: link:../../scripts
|
||||||
uvu: 0.5.3
|
uvu: 0.5.3
|
||||||
|
|
||||||
|
packages/integrations/deno:
|
||||||
|
specifiers:
|
||||||
|
astro: workspace:*
|
||||||
|
astro-scripts: workspace:*
|
||||||
|
devDependencies:
|
||||||
|
astro: link:../../astro
|
||||||
|
astro-scripts: link:../../../scripts
|
||||||
|
|
||||||
|
packages/integrations/deno/test/fixtures/basics:
|
||||||
|
specifiers:
|
||||||
|
'@astrojs/deno': workspace:*
|
||||||
|
astro: workspace:*
|
||||||
|
dependencies:
|
||||||
|
'@astrojs/deno': link:../../..
|
||||||
|
astro: link:../../../../../astro
|
||||||
|
|
||||||
packages/integrations/lit:
|
packages/integrations/lit:
|
||||||
specifiers:
|
specifiers:
|
||||||
'@lit-labs/ssr': ^2.0.4
|
'@lit-labs/ssr': ^2.0.4
|
||||||
|
@ -3969,6 +3989,10 @@ packages:
|
||||||
/@types/parse5/6.0.3:
|
/@types/parse5/6.0.3:
|
||||||
resolution: {integrity: sha512-SuT16Q1K51EAVPz1K29DJ/sXjhSQ0zjvsypYJ6tlwVsRV9jwW5Adq2ch8Dq8kDBCkYnELS7N7VNCSB5nC56t/g==}
|
resolution: {integrity: sha512-SuT16Q1K51EAVPz1K29DJ/sXjhSQ0zjvsypYJ6tlwVsRV9jwW5Adq2ch8Dq8kDBCkYnELS7N7VNCSB5nC56t/g==}
|
||||||
|
|
||||||
|
/@types/path-browserify/1.0.0:
|
||||||
|
resolution: {integrity: sha512-XMCcyhSvxcch8b7rZAtFAaierBYdeHXVvg2iYnxOV0MCQHmPuRRmGZPFDRzPayxcGiiSL1Te9UIO+f3cuj0tfw==}
|
||||||
|
dev: true
|
||||||
|
|
||||||
/@types/prettier/2.4.4:
|
/@types/prettier/2.4.4:
|
||||||
resolution: {integrity: sha512-ReVR2rLTV1kvtlWFyuot+d1pkpG2Fw/XKE3PDAdj57rbM97ttSp9JZ2UsP+2EHTylra9cUf6JA7tGwW1INzUrA==}
|
resolution: {integrity: sha512-ReVR2rLTV1kvtlWFyuot+d1pkpG2Fw/XKE3PDAdj57rbM97ttSp9JZ2UsP+2EHTylra9cUf6JA7tGwW1INzUrA==}
|
||||||
dev: true
|
dev: true
|
||||||
|
@ -8461,6 +8485,10 @@ packages:
|
||||||
tslib: 2.3.1
|
tslib: 2.3.1
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
|
/path-browserify/1.0.1:
|
||||||
|
resolution: {integrity: sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==}
|
||||||
|
dev: false
|
||||||
|
|
||||||
/path-exists/4.0.0:
|
/path-exists/4.0.0:
|
||||||
resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==}
|
resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==}
|
||||||
engines: {node: '>=8'}
|
engines: {node: '>=8'}
|
||||||
|
|
Loading…
Add table
Reference in a new issue