config: use moduleResolution node16

This commit is contained in:
Princesseuh 2023-07-24 20:48:40 +02:00
parent cb973ee1e2
commit 9959899b5e
No known key found for this signature in database
GPG key ID: 105BBD6D57F2B0C0
197 changed files with 326 additions and 313 deletions

3
.vscode/settings.json vendored Normal file
View file

@ -0,0 +1,3 @@
{
"typescript.preferences.importModuleSpecifierEnding": "js"
}

View file

@ -1,5 +1,5 @@
import type { z } from 'astro/zod';
import type { RSSOptions } from './index';
import type { RSSOptions } from './index.js';
/** Normalize URL to its canonical form */
export function createCanonicalURL(

View file

@ -57,7 +57,7 @@ declare module 'astro:assets' {
type WithRequired<T, K extends keyof T> = T & { [P in K]-?: T[P] };
type Simplify<T> = { [KeyType in keyof T]: T[KeyType] };
type ImgAttributes = WithRequired<
Omit<import('./types').HTMLAttributes<'img'>, 'src' | 'width' | 'height'>,
Omit<import('./types.js').HTMLAttributes<'img'>, 'src' | 'width' | 'height'>,
'alt'
>;
@ -79,7 +79,7 @@ declare module 'astro:transitions' {
export const ViewTransitions: ViewTransitionsModule['default'];
}
type MD = import('./dist/@types/astro').MarkdownInstance<Record<string, any>>;
type MD = import('./dist/@types/astro.js').MarkdownInstance<Record<string, any>>;
interface ExportedMarkdownModuleEntities {
frontmatter: MD['frontmatter'];
file: MD['file'];
@ -184,7 +184,7 @@ declare module '*.mdown' {
}
declare module '*.mdx' {
type MDX = import('./dist/@types/astro').MDXInstance<Record<string, any>>;
type MDX = import('./dist/@types/astro.js').MDXInstance<Record<string, any>>;
export const frontmatter: MDX['frontmatter'];
export const file: MDX['file'];
@ -197,7 +197,7 @@ declare module '*.mdx' {
}
declare module 'astro:ssr-manifest' {
export const manifest: import('./dist/@types/astro').SSRManifest;
export const manifest: import('./dist/@types/astro.js').SSRManifest;
}
// Everything below are Vite's types (apart from image types, which are in `client.d.ts`)

View file

@ -150,7 +150,7 @@
"html-escaper": "^3.0.3",
"js-yaml": "^4.1.0",
"kleur": "^4.1.4",
"magic-string": "^0.27.0",
"magic-string": "^0.30.1",
"mime": "^3.0.0",
"network-information-types": "^0.1.1",
"ora": "^6.3.1",

View file

@ -14,13 +14,13 @@ import type * as rollup from 'rollup';
import type { TsConfigJson } from 'tsconfig-resolver';
import type * as vite from 'vite';
import type { z } from 'zod';
import type { SerializedSSRManifest } from '../core/app/types';
import type { PageBuildData } from '../core/build/types';
import type { AstroConfigSchema } from '../core/config';
import type { AstroTimer } from '../core/config/timer';
import type { AstroCookies } from '../core/cookies';
import type { LogOptions } from '../core/logger/core';
import type { AstroComponentFactory, AstroComponentInstance } from '../runtime/server';
import type { SerializedSSRManifest } from '../core/app/types.js';
import type { PageBuildData } from '../core/build/types.js';
import type { AstroConfigSchema } from '../core/config/index.js';
import type { AstroTimer } from '../core/config/timer.js';
import type { AstroCookies } from '../core/cookies/index.js';
import type { LogOptions } from '../core/logger/core.js';
import type { AstroComponentFactory, AstroComponentInstance } from '../runtime/server/index.js';
import type { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from './../core/constants.js';
export type {
MarkdownHeading,
@ -34,7 +34,7 @@ export type {
ExternalImageService,
ImageService,
LocalImageService,
} from '../assets/services/service';
} from '../assets/services/service.js';
export type {
GetImageResult,
ImageInputFormat,
@ -43,9 +43,9 @@ export type {
ImageQuality,
ImageQualityPreset,
ImageTransform,
} from '../assets/types';
export type { SSRManifest } from '../core/app/types';
export type { AstroCookies } from '../core/cookies';
} from '../assets/types.js';
export type { SSRManifest } from '../core/app/types.js';
export type { AstroCookies } from '../core/cookies/index.js';
export interface AstroBuiltinProps {
'client:load'?: boolean;

View file

@ -33,7 +33,7 @@ export interface RotateOptions {
}
// MozJPEG
import type { MozJPEGModule as MozJPEGEncodeModule } from './mozjpeg/mozjpeg_enc'
import type { MozJPEGModule as MozJPEGEncodeModule } from './mozjpeg/mozjpeg_enc.js'
import mozDec from './mozjpeg/mozjpeg_node_dec.js'
import mozDecWasm from './mozjpeg/mozjpeg_node_dec.wasm.js'
@ -41,7 +41,7 @@ import mozEnc from './mozjpeg/mozjpeg_node_enc.js'
import mozEncWasm from './mozjpeg/mozjpeg_node_enc.wasm.js'
// WebP
import type { WebPModule as WebPEncodeModule } from './webp/webp_enc'
import type { WebPModule as WebPEncodeModule } from './webp/webp_enc.js'
import webpDec from './webp/webp_node_dec.js'
import webpDecWasm from './webp/webp_node_dec.wasm.js'
@ -49,7 +49,7 @@ import webpEnc from './webp/webp_node_enc.js'
import webpEncWasm from './webp/webp_node_enc.wasm.js'
// AVIF
import type { AVIFModule as AVIFEncodeModule } from './avif/avif_enc'
import type { AVIFModule as AVIFEncodeModule } from './avif/avif_enc.js'
import avifDec from './avif/avif_node_dec.js'
import avifDecWasm from './avif/avif_node_dec.wasm.js'

View file

@ -1,4 +1,4 @@
import type { IImage } from './interface'
import type { IImage } from './interface.js'
export const BMP: IImage = {
validate(buffer) {

View file

@ -1,5 +1,5 @@
import { ICO } from './ico.js'
import type { IImage } from './interface'
import type { IImage } from './interface.js'
const TYPE_CURSOR = 2
export const CUR: IImage = {

View file

@ -1,4 +1,4 @@
import type { IImage } from './interface'
import type { IImage } from './interface.js'
export const DDS: IImage = {
validate(buffer) {

View file

@ -1,4 +1,4 @@
import type { IImage } from './interface'
import type { IImage } from './interface.js'
const gifRegexp = /^GIF8[79]a/
export const GIF: IImage = {

View file

@ -1,4 +1,4 @@
import type { IImage, ISize } from './interface'
import type { IImage, ISize } from './interface.js'
/**
* ICNS Header

View file

@ -1,4 +1,4 @@
import type { IImage, ISize, ISizeCalculationResult } from './interface'
import type { IImage, ISize, ISizeCalculationResult } from './interface.js'
const TYPE_ICON = 1

View file

@ -1,4 +1,4 @@
import type { IImage } from './interface'
import type { IImage } from './interface.js'
export const J2C: IImage = {
validate(buffer) {

View file

@ -1,4 +1,4 @@
import type { IImage, ISize } from './interface'
import type { IImage, ISize } from './interface.js'
const BoxTypes = {
ftyp: '66747970',

View file

@ -4,7 +4,7 @@
// if this range we can't detect the file size correctly.
import { readUInt } from '../readUInt.js'
import type { IImage, ISize } from './interface'
import type { IImage, ISize } from './interface.js'
const EXIF_MARKER = '45786966'
const APP1_DATA_SIZE_BYTES = 2

View file

@ -1,4 +1,4 @@
import type { IImage } from './interface'
import type { IImage } from './interface.js'
const SIGNATURE = 'KTX 11'

View file

@ -1,4 +1,4 @@
import type { IImage } from './interface'
import type { IImage } from './interface.js'
const pngSignature = 'PNG\r\n\x1a\n'
const pngImageHeaderChunkName = 'IHDR'

View file

@ -1,4 +1,4 @@
import type { IImage, ISize } from './interface'
import type { IImage, ISize } from './interface.js'
const PNMTypes: { [signature: string]: string } = {
P1: 'pbm/ascii',

View file

@ -1,4 +1,4 @@
import type { IImage } from './interface'
import type { IImage } from './interface.js'
export const PSD: IImage = {
validate(buffer) {

View file

@ -1,4 +1,4 @@
import type { IImage, ISize } from './interface'
import type { IImage, ISize } from './interface.js'
interface IAttributes {
width: number | null

View file

@ -2,7 +2,7 @@
// TO-DO: support big-endian as well
import * as fs from 'node:fs'
import { readUInt } from '../readUInt.js'
import type { IImage } from './interface'
import type { IImage } from './interface.js'
// Read IFD (image-file-directory) into a buffer
function readIFD(buffer: Buffer, filepath: string, isBigEndian: boolean) {

View file

@ -1,5 +1,5 @@
// based on https://developers.google.com/speed/webp/docs/riff_container
import type { IImage, ISize } from './interface'
import type { IImage, ISize } from './interface.js'
function calculateExtended(buffer: Buffer): ISize {
return {

View file

@ -3,7 +3,7 @@ import MagicString from 'magic-string';
import { fileURLToPath } from 'node:url';
import type * as vite from 'vite';
import { normalizePath } from 'vite';
import type { AstroPluginOptions, ImageTransform } from '../@types/astro';
import type { AstroPluginOptions, ImageTransform } from '../@types/astro.js';
import { error } from '../core/logger/core.js';
import {
appendForwardSlash,

View file

@ -3,13 +3,11 @@ import parser from '@babel/parser';
import traverse from '@babel/traverse';
import * as t from '@babel/types';
// @ts-expect-error @babel/traverse isn't ESM and needs this trick
export const visit = traverse.default as typeof traverse;
export const visit = traverse.default;
export { t };
export async function generate(ast: t.File) {
// @ts-expect-error @babel/generator isn't ESM and needs this trick
const astToText = generator.default as typeof generator;
const astToText = generator.default;
const { code } = astToText(ast);
return code;
}

View file

@ -12,11 +12,11 @@ import { join } from 'node:path';
import { fileURLToPath, pathToFileURL } from 'node:url';
import ora from 'ora';
import type { Arguments as Flags } from 'yargs-parser';
import type { AstroSettings } from '../../@types/astro';
import type { AstroSettings } from '../../@types/astro.js';
import type { LogOptions } from '../../core/logger/core.js';
import { debug, info } from '../../core/logger/core.js';
import { printHelp } from '../../core/messages.js';
import type { ProcessExit, SyncOptions } from '../../core/sync';
import type { ProcessExit, SyncOptions } from '../../core/sync/index.js';
import { loadSettings } from '../load-settings.js';
import { printDiagnostic } from './print.js';

View file

@ -1,6 +1,6 @@
import type { UserConfig } from 'vite';
import type { AstroUserConfig } from '../@types/astro';
import type { LogOptions } from '../core/logger/core';
import type { AstroUserConfig } from '../@types/astro.js';
import type { LogOptions } from '../core/logger/core.js';
export function defineConfig(config: AstroUserConfig) {
return config;

View file

@ -1,6 +1,6 @@
import type fsMod from 'node:fs';
import type { Plugin, ViteDevServer } from 'vite';
import type { AstroSettings } from '../@types/astro';
import type { AstroSettings } from '../@types/astro.js';
import { attachContentServerListeners } from '../content/server-listeners.js';
import type { LogOptions } from '../core/logger/core.js';

View file

@ -5,7 +5,7 @@ import type { AstroSettings } from '../@types/astro.js';
import { moduleIsTopLevelPage, walkParentInfos } from '../core/build/graph.js';
import { getPageDataByViteID, type BuildInternals } from '../core/build/internal.js';
import type { AstroBuildPlugin } from '../core/build/plugin.js';
import type { StaticBuildOptions } from '../core/build/types';
import type { StaticBuildOptions } from '../core/build/types.js';
import type { ModuleLoader } from '../core/module-loader/loader.js';
import { createViteLoader } from '../core/module-loader/vite.js';
import { joinPaths, prependForwardSlash } from '../core/path.js';

View file

@ -1,5 +1,5 @@
import { deserializeRouteData } from '../routing/manifest/serialization.js';
import type { RouteInfo, SerializedSSRManifest, SSRManifest } from './types';
import type { RouteInfo, SerializedSSRManifest, SSRManifest } from './types.js';
export function deserializeManifest(serializedManifest: SerializedSSRManifest): SSRManifest {
const routes: RouteInfo[] = [];

View file

@ -5,14 +5,14 @@ import type {
RouteData,
SSRElement,
SSRManifest,
} from '../../@types/astro';
import type { SinglePageBuiltModule } from '../build/types';
} from '../../@types/astro.js';
import type { SinglePageBuiltModule } from '../build/types.js';
import { attachToResponse, getSetCookiesFromResponse } from '../cookies/index.js';
import { consoleLogDestination } from '../logger/console.js';
import { error, type LogOptions } from '../logger/core.js';
import { prependForwardSlash, removeTrailingForwardSlash } from '../path.js';
import { RedirectSinglePageBuiltModule } from '../redirects/index.js';
import { isResponse } from '../render/core';
import { isResponse } from '../render/core.js';
import {
createEnvironment,
createRenderContext,
@ -27,7 +27,7 @@ import {
createStylesheetElementSet,
} from '../render/ssr-element.js';
import { matchRoute } from '../routing/match.js';
import type { RouteInfo } from './types';
import type { RouteInfo } from './types.js';
export { deserializeManifest } from './common.js';
const clientLocalsSymbol = Symbol.for('astro.locals');

View file

@ -1,5 +1,5 @@
import type { RouteData } from '../../@types/astro';
import type { SerializedSSRManifest, SSRManifest } from './types';
import type { RouteData } from '../../@types/astro.js';
import type { SerializedSSRManifest, SSRManifest } from './types.js';
import * as fs from 'node:fs';
import { IncomingMessage } from 'node:http';

View file

@ -5,8 +5,8 @@ import type {
SSRComponentMetadata,
SSRLoadedRenderer,
SSRResult,
} from '../../@types/astro';
import type { SinglePageBuiltModule } from '../build/types';
} from '../../@types/astro.js';
import type { SinglePageBuiltModule } from '../build/types.js';
export type ComponentPath = string;

View file

@ -1,6 +1,6 @@
import npath from 'node:path';
import { fileURLToPath, pathToFileURL } from 'node:url';
import type { AstroConfig, RouteType } from '../../@types/astro';
import type { AstroConfig, RouteType } from '../../@types/astro.js';
import { appendForwardSlash } from '../../core/path.js';
const STATUS_CODE_PAGES = new Set(['/404', '/500']);

View file

@ -2,7 +2,7 @@ import type { GetModuleInfo } from 'rollup';
import crypto from 'node:crypto';
import npath from 'node:path';
import type { AstroSettings } from '../../@types/astro';
import type { AstroSettings } from '../../@types/astro.js';
import { viteID } from '../util.js';
import { getTopLevelPages } from './graph.js';

View file

@ -15,7 +15,7 @@ import type {
SSRError,
SSRLoadedRenderer,
SSRManifest,
} from '../../@types/astro';
} from '../../@types/astro.js';
import {
generateImage as generateImageInternal,
getStaticImageList,
@ -61,7 +61,7 @@ import type {
SinglePageBuiltModule,
StaticBuildOptions,
StylesheetAsset,
} from './types';
} from './types.js';
import { getTimeStat } from './util.js';
function createEntryURL(filePath: string, outFolder: URL) {

View file

@ -3,7 +3,7 @@ import fs from 'node:fs';
import { performance } from 'node:perf_hooks';
import type * as vite from 'vite';
import type yargs from 'yargs-parser';
import type { AstroConfig, AstroSettings, ManifestData, RuntimeMode } from '../../@types/astro';
import type { AstroConfig, AstroSettings, ManifestData, RuntimeMode } from '../../@types/astro.js';
import {
runHookBuildDone,
runHookBuildStart,

View file

@ -1,6 +1,6 @@
import type { Rollup } from 'vite';
import type { RouteData, SSRResult } from '../../@types/astro';
import type { PageOptions } from '../../vite-plugin-astro/types';
import type { RouteData, SSRResult } from '../../@types/astro.js';
import type { PageOptions } from '../../vite-plugin-astro/types.js';
import { prependForwardSlash, removeFileExtension } from '../path.js';
import { viteID } from '../util.js';
import {
@ -9,7 +9,7 @@ import {
} from './plugins/plugin-pages.js';
import { RESOLVED_SPLIT_MODULE_ID } from './plugins/plugin-ssr.js';
import { ASTRO_PAGE_EXTENSION_POST_PATTERN } from './plugins/util.js';
import type { PageBuildData, StylesheetAsset, ViteID } from './types';
import type { PageBuildData, StylesheetAsset, ViteID } from './types.js';
export interface BuildInternals {
/**

View file

@ -1,7 +1,7 @@
import type { AstroSettings, ManifestData } from '../../@types/astro';
import type { LogOptions } from '../logger/core';
import type { AstroSettings, ManifestData } from '../../@types/astro.js';
import type { LogOptions } from '../logger/core.js';
import { info } from '../logger/core.js';
import type { AllPagesData } from './types';
import type { AllPagesData } from './types.js';
import * as colors from 'kleur/colors';
import { debug } from '../logger/core.js';

View file

@ -1,6 +1,6 @@
import type { Plugin as VitePlugin } from 'vite';
import type { BuildInternals } from './internal';
import type { StaticBuildOptions, ViteBuildReturn } from './types';
import type { BuildInternals } from './internal.js';
import type { StaticBuildOptions, ViteBuildReturn } from './types.js';
type RollupOutputArray = Extract<ViteBuildReturn, Array<any>>;
type OutputChunkorAsset = RollupOutputArray[number]['output'][number];

View file

@ -1,6 +1,6 @@
import { astroConfigBuildPlugin } from '../../../content/vite-plugin-content-assets.js';
import { astroHeadBuildPlugin } from '../../../vite-plugin-head/index.js';
import type { AstroBuildPluginContainer } from '../plugin';
import type { AstroBuildPluginContainer } from '../plugin.js';
import { pluginAliasResolve } from './plugin-alias-resolve.js';
import { pluginAnalyzer } from './plugin-analyzer.js';
import { pluginComponentEntry } from './plugin-component-entry.js';

View file

@ -1,7 +1,7 @@
import type { Node as ESTreeNode } from 'estree-walker';
import type { ModuleInfo, PluginContext } from 'rollup';
import type { Plugin as VitePlugin } from 'vite';
import type { PluginMetadata as AstroPluginMetadata } from '../../../vite-plugin-astro/types';
import type { PluginMetadata as AstroPluginMetadata } from '../../../vite-plugin-astro/types.js';
import type { BuildInternals } from '../internal.js';
import type { AstroBuildPlugin } from '../plugin.js';

View file

@ -3,9 +3,9 @@ import * as npath from 'node:path';
import type { GetModuleInfo } from 'rollup';
import { type ResolvedConfig, type Plugin as VitePlugin } from 'vite';
import { isBuildableCSSRequest } from '../../../vite-plugin-astro-server/util.js';
import type { BuildInternals } from '../internal';
import type { AstroBuildPlugin } from '../plugin';
import type { PageBuildData, StaticBuildOptions, StylesheetAsset } from '../types';
import type { BuildInternals } from '../internal.js';
import type { AstroBuildPlugin } from '../plugin.js';
import type { OutputChunk, PageBuildData, StaticBuildOptions, StylesheetAsset } from '../types.js';
import { PROPAGATED_ASSET_FLAG } from '../../../content/consts.js';
import * as assetName from '../css-asset-name.js';
@ -110,7 +110,7 @@ function rollupPluginAstroBuildCSS(options: PluginOptions): VitePlugin[] {
for (const [, chunk] of Object.entries(bundle)) {
if (chunk.type !== 'chunk') continue;
if ('viteMetadata' in chunk === false) continue;
const meta = chunk.viteMetadata as ViteMetadata;
const meta = (chunk as OutputChunk & { viteMetadata: ViteMetadata }).viteMetadata;
// Skip if the chunk has no CSS, we want to handle CSS chunks only
if (meta.importedCss.size < 1) continue;

View file

@ -1,10 +1,10 @@
import type { Plugin as VitePlugin } from 'vite';
import type { AstroSettings } from '../../../@types/astro';
import type { AstroSettings } from '../../../@types/astro.js';
import { viteID } from '../../util.js';
import type { BuildInternals } from '../internal.js';
import { getPageDataByViteID } from '../internal.js';
import type { AstroBuildPlugin } from '../plugin';
import type { OutputChunk, StaticBuildOptions } from '../types';
import type { AstroBuildPlugin } from '../plugin.js';
import type { OutputChunk, StaticBuildOptions } from '../types.js';
function virtualHoistedEntry(id: string) {
return id.startsWith('/astro/hoisted.js?q=');

View file

@ -1,6 +1,6 @@
import type { UserConfig, Plugin as VitePlugin } from 'vite';
import type { BuildInternals } from '../internal.js';
import type { AstroBuildPlugin } from '../plugin';
import type { AstroBuildPlugin } from '../plugin.js';
import { normalizeEntryId } from './plugin-component-entry.js';
export function vitePluginInternals(input: Set<string>, internals: BuildInternals): VitePlugin {

View file

@ -1,9 +1,9 @@
import type { Plugin as VitePlugin } from 'vite';
import { MIDDLEWARE_PATH_SEGMENT_NAME } from '../../constants.js';
import { addRollupInput } from '../add-rollup-input.js';
import type { BuildInternals } from '../internal';
import type { AstroBuildPlugin } from '../plugin';
import type { StaticBuildOptions } from '../types';
import type { BuildInternals } from '../internal.js';
import type { AstroBuildPlugin } from '../plugin.js';
import type { StaticBuildOptions } from '../types.js';
export const MIDDLEWARE_MODULE_ID = '@astro-middleware';

View file

@ -3,8 +3,8 @@ import type { Plugin as VitePlugin } from 'vite';
import { routeIsRedirect } from '../../redirects/index.js';
import { addRollupInput } from '../add-rollup-input.js';
import { type BuildInternals } from '../internal.js';
import type { AstroBuildPlugin } from '../plugin';
import type { StaticBuildOptions } from '../types';
import type { AstroBuildPlugin } from '../plugin.js';
import type { StaticBuildOptions } from '../types.js';
import { MIDDLEWARE_MODULE_ID } from './plugin-middleware.js';
import { RENDERERS_MODULE_ID } from './plugin-renderers.js';
import { ASTRO_PAGE_EXTENSION_POST_PATTERN, getPathFromVirtualModulePageName } from './util.js';

View file

@ -3,7 +3,7 @@ import type { Plugin as VitePlugin } from 'vite';
import { getPrerenderMetadata } from '../../../prerender/metadata.js';
import type { BuildInternals } from '../internal.js';
import type { AstroBuildPlugin } from '../plugin.js';
import type { StaticBuildOptions } from '../types';
import type { StaticBuildOptions } from '../types.js';
import { extendManualChunks } from './util.js';
function vitePluginPrerender(opts: StaticBuildOptions, internals: BuildInternals): VitePlugin {

View file

@ -1,7 +1,7 @@
import type { Plugin as VitePlugin } from 'vite';
import { addRollupInput } from '../add-rollup-input.js';
import type { AstroBuildPlugin } from '../plugin';
import type { StaticBuildOptions } from '../types';
import type { AstroBuildPlugin } from '../plugin.js';
import type { StaticBuildOptions } from '../types.js';
export const RENDERERS_MODULE_ID = '@astro-renderers';
export const RESOLVED_RENDERERS_MODULE_ID = `\0${RENDERERS_MODULE_ID}`;

View file

@ -2,19 +2,19 @@ import glob from 'fast-glob';
import { join } from 'node:path';
import { fileURLToPath, pathToFileURL } from 'node:url';
import type { Plugin as VitePlugin } from 'vite';
import type { AstroAdapter, AstroConfig } from '../../../@types/astro';
import type { AstroAdapter, AstroConfig } from '../../../@types/astro.js';
import { runHookBuildSsr } from '../../../integrations/index.js';
import { isServerLikeOutput } from '../../../prerender/utils.js';
import { BEFORE_HYDRATION_SCRIPT_ID, PAGE_SCRIPT_ID } from '../../../vite-plugin-scripts/index.js';
import type { SerializedRouteInfo, SerializedSSRManifest } from '../../app/types';
import type { SerializedRouteInfo, SerializedSSRManifest } from '../../app/types.js';
import { joinPaths, prependForwardSlash } from '../../path.js';
import { routeIsRedirect } from '../../redirects/index.js';
import { serializeRouteData } from '../../routing/index.js';
import { addRollupInput } from '../add-rollup-input.js';
import { getOutFile, getOutFolder } from '../common.js';
import { cssOrder, mergeInlineCss, type BuildInternals } from '../internal.js';
import type { AstroBuildPlugin } from '../plugin';
import type { OutputChunk, StaticBuildOptions } from '../types';
import type { AstroBuildPlugin } from '../plugin.js';
import type { OutputChunk, StaticBuildOptions } from '../types.js';
import { ASTRO_PAGE_MODULE_ID } from './plugin-pages.js';
import { RENDERERS_MODULE_ID } from './plugin-renderers.js';
import { getPathFromVirtualModulePageName, getVirtualModulePageNameFromPath } from './util.js';
@ -283,7 +283,7 @@ function generateSSRCode(config: AstroConfig, adapter: AstroAdapter) {
}
contents.push(`import * as adapter from '${adapter.serverEntrypoint}';
import { renderers } from '${RENDERERS_MODULE_ID}';
import { renderers } from '${RENDERERS_MODULE_ID}';
import { deserializeManifest as _deserializeManifest } from 'astro/app';
import { _privateSetManifestDontUseThis } from 'astro:ssr-manifest';
const _manifest = Object.assign(_deserializeManifest('${manifestReplace}'), {

View file

@ -6,7 +6,7 @@ import fs from 'node:fs';
import path, { extname } from 'node:path';
import { fileURLToPath } from 'node:url';
import * as vite from 'vite';
import type { RouteData } from '../../@types/astro';
import type { RouteData } from '../../@types/astro.js';
import {
createBuildInternals,
eachPageData,
@ -30,7 +30,7 @@ import { ASTRO_PAGE_RESOLVED_MODULE_ID } from './plugins/plugin-pages.js';
import { RESOLVED_RENDERERS_MODULE_ID } from './plugins/plugin-renderers.js';
import { RESOLVED_SPLIT_MODULE_ID, SSR_VIRTUAL_MODULE_ID } from './plugins/plugin-ssr.js';
import { ASTRO_PAGE_EXTENSION_POST_PATTERN } from './plugins/util.js';
import type { PageBuildData, StaticBuildOptions } from './types';
import type { PageBuildData, StaticBuildOptions } from './types.js';
import { getTimeStat } from './util.js';
export async function viteBuild(opts: StaticBuildOptions) {

View file

@ -1,4 +1,5 @@
import type { InlineConfig, default as vite } from 'vite';
import type * as vite from 'vite';
import type { InlineConfig } from 'vite';
import type {
AstroConfig,
AstroSettings,
@ -8,9 +9,9 @@ import type {
RouteData,
RuntimeMode,
SSRLoadedRenderer,
} from '../../@types/astro';
import type { LogOptions } from '../logger/core';
import type { RouteCache } from '../render/route-cache';
} from '../../@types/astro.js';
import type { LogOptions } from '../logger/core.js';
import type { RouteCache } from '../render/route-cache.js';
export type ComponentPath = string;
export type ViteID = string;

View file

@ -1,4 +1,4 @@
import type { AstroConfig } from '../../@types/astro';
import type { AstroConfig } from '../../@types/astro.js';
import { compile, type CompileProps, type CompileResult } from './compile.js';
type CompilationCache = Map<string, CompileResult>;

View file

@ -1,6 +1,6 @@
import type { TransformResult } from '@astrojs/compiler';
import type { ResolvedConfig } from 'vite';
import type { AstroConfig } from '../../@types/astro';
import type { AstroConfig } from '../../@types/astro.js';
import { transform } from '@astrojs/compiler';
import { fileURLToPath } from 'node:url';

View file

@ -4,5 +4,5 @@ export {
invalidateCompilation,
isCached,
} from './cache.js';
export type { CompileProps, CompileResult } from './compile';
export type { TransformStyle } from './types';
export type { CompileProps, CompileResult } from './compile.js';
export type { TransformStyle } from './types.js';

View file

@ -1,5 +1,5 @@
import type { Arguments as Flags } from 'yargs-parser';
import type { AstroConfig, AstroUserConfig, CLIFlags } from '../../@types/astro';
import type { AstroConfig, AstroUserConfig, CLIFlags } from '../../@types/astro.js';
import * as colors from 'kleur/colors';
import fs from 'node:fs';

View file

@ -7,6 +7,6 @@ export {
validateConfig,
} from './config.js';
export { mergeConfig } from './merge.js';
export type { AstroConfigSchema } from './schema';
export type { AstroConfigSchema } from './schema.js';
export { createDefaultDevSettings, createSettings } from './settings.js';
export { loadTSConfig, updateTSConfigForFramework } from './tsconfig.js';

View file

@ -1,7 +1,7 @@
import type { RehypePlugin, RemarkPlugin, RemarkRehype } from '@astrojs/markdown-remark';
import { markdownConfigDefaults } from '@astrojs/markdown-remark';
import type { ILanguageRegistration, IThemeRegistration, Theme } from 'shiki';
import type { AstroUserConfig, ViteUserConfig } from '../../@types/astro';
import type { AstroUserConfig, ViteUserConfig } from '../../@types/astro.js';
import type { OutgoingHttpHeaders } from 'node:http';
import path from 'node:path';

View file

@ -1,7 +1,7 @@
import yaml from 'js-yaml';
import path from 'node:path';
import { fileURLToPath, pathToFileURL } from 'node:url';
import type { AstroConfig, AstroSettings, AstroUserConfig } from '../../@types/astro';
import type { AstroConfig, AstroSettings, AstroUserConfig } from '../../@types/astro.js';
import { getContentPaths } from '../../content/index.js';
import jsxRenderer from '../../jsx/renderer.js';
import { isServerLikeOutput } from '../../prerender/utils.js';

View file

@ -1,4 +1,4 @@
import type { AstroCookies } from './cookies';
import type { AstroCookies } from './cookies.js';
const astroCookiesSymbol = Symbol.for('astro.cookies');

View file

@ -1,5 +1,5 @@
import type { AstroSettings } from '../@types/astro';
import type { LogOptions } from './logger/core';
import type { AstroSettings } from '../@types/astro.js';
import type { LogOptions } from './logger/core.js';
import nodeFs from 'node:fs';
import { fileURLToPath } from 'node:url';
@ -168,7 +168,7 @@ export async function createVite(
{
// Typings are imported from 'astro' (e.g. import { Type } from 'astro')
find: /^astro$/,
replacement: fileURLToPath(new URL('../@types/astro', import.meta.url)),
replacement: fileURLToPath(new URL('../@types/astro.js', import.meta.url)),
},
],
conditions: ['astro'],

View file

@ -1,6 +1,6 @@
import type * as http from 'node:http';
import type { AddressInfo } from 'node:net';
import type { AstroSettings, AstroUserConfig } from '../../@types/astro';
import type { AstroSettings, AstroUserConfig } from '../../@types/astro.js';
import nodeFs from 'node:fs';
import * as vite from 'vite';

View file

@ -4,7 +4,7 @@ import type { AddressInfo } from 'node:net';
import { performance } from 'perf_hooks';
import type * as vite from 'vite';
import type yargs from 'yargs-parser';
import type { AstroSettings } from '../../@types/astro';
import type { AstroSettings } from '../../@types/astro.js';
import { attachContentServerListeners } from '../../content/index.js';
import { telemetry } from '../../events/index.js';
import { info, warn, type LogOptions } from '../logger/core.js';

View file

@ -1,9 +1,9 @@
import * as vite from 'vite';
import type { AstroSettings } from '../../@types/astro';
import type { AstroSettings } from '../../@types/astro.js';
import { createSettings, openConfig } from '../config/index.js';
import { createSafeError } from '../errors/index.js';
import { info } from '../logger/core.js';
import type { Container, CreateContainerParams } from './container';
import type { Container, CreateContainerParams } from './container.js';
import { createContainer, isStarted, startContainer } from './container.js';
async function createRestartedContainer(

View file

@ -1,4 +1,4 @@
import type { EndpointHandler } from '../../../@types/astro';
import type { EndpointHandler } from '../../../@types/astro.js';
import { createRenderContext, type SSROptions } from '../../render/index.js';
import { callEndpoint } from '../index.js';

View file

@ -5,8 +5,8 @@ import type {
MiddlewareEndpointHandler,
MiddlewareHandler,
Params,
} from '../../@types/astro';
import type { Environment, RenderContext } from '../render/index';
} from '../../@types/astro.js';
import type { Environment, RenderContext } from '../render/index.js';
import { renderEndpoint } from '../../runtime/server/index.js';
import { ASTRO_VERSION } from '../constants.js';

View file

@ -1,4 +1,3 @@
export type { ErrorLocation, ErrorWithMetadata } from './errors';
export { AstroErrorData } from './errors-data.js';
export {
AggregateError,
@ -8,5 +7,6 @@ export {
MarkdownError,
isAstroError,
} from './errors.js';
export type { ErrorLocation, ErrorWithMetadata } from './errors.js';
export { codeFrame } from './printer.js';
export { createSafeError, positionAt } from './utils.js';

View file

@ -1,4 +1,4 @@
import type { AstroErrorPayload } from './dev/vite';
import type { AstroErrorPayload } from './dev/vite.js';
const style = /* css */ `
* {

View file

@ -4,10 +4,10 @@ import type {
EndpointOutput,
MiddlewareHandler,
MiddlewareNext,
} from '../../@types/astro';
} from '../../@types/astro.js';
import { AstroError, AstroErrorData } from '../errors/index.js';
import { warn } from '../logger/core.js';
import type { Environment } from '../render';
import type { Environment } from '../render/index.js';
/**
* Utility function that is in charge of calling the middleware.

View file

@ -1,4 +1,4 @@
import type { MiddlewareResponseHandler, Params } from '../../@types/astro';
import type { MiddlewareResponseHandler, Params } from '../../@types/astro.js';
import { createAPIContext } from '../endpoint/index.js';
import { sequence } from './sequence.js';

View file

@ -1,6 +1,6 @@
import type { AstroSettings } from '../../@types/astro';
import type { AstroSettings } from '../../@types/astro.js';
import { MIDDLEWARE_PATH_SEGMENT_NAME } from '../constants.js';
import type { ModuleLoader } from '../module-loader';
import type { ModuleLoader } from '../module-loader/index.js';
/**
* It accepts a module loader and the astro settings, and it attempts to load the middlewares defined in the configuration.

View file

@ -1,4 +1,4 @@
import type { APIContext, MiddlewareResponseHandler } from '../../@types/astro';
import type { APIContext, MiddlewareResponseHandler } from '../../@types/astro.js';
import { defineMiddleware } from './index.js';
// From SvelteKit: https://github.com/sveltejs/kit/blob/master/packages/kit/src/exports/hooks/sequence.js

View file

@ -1,6 +1,6 @@
import { EventEmitter } from 'node:events';
import type * as fs from 'node:fs';
import type { TypedEventEmitter } from '../../@types/typed-emitter';
import type { TypedEventEmitter } from '../../@types/typed-emitter.js';
// This is a generic interface for a module loader. In the astro cli this is
// fulfilled by Vite, see vite.ts

View file

@ -1,6 +1,6 @@
import { EventEmitter } from 'node:events';
import type * as vite from 'vite';
import type { ModuleLoader, ModuleLoaderEventEmitter } from './loader';
import type { ModuleLoader, ModuleLoaderEventEmitter } from './loader.js';
export function createViteLoader(viteServer: vite.ViteDevServer): ModuleLoader {
const events = new EventEmitter() as ModuleLoaderEventEmitter;

View file

@ -2,9 +2,9 @@ import { cyan } from 'kleur/colors';
import { createRequire } from 'module';
import { pathToFileURL } from 'node:url';
import type { Arguments } from 'yargs-parser';
import type { AstroSettings, PreviewModule, PreviewServer } from '../../@types/astro';
import type { AstroSettings, PreviewModule, PreviewServer } from '../../@types/astro.js';
import { runHookConfigDone, runHookConfigSetup } from '../../integrations/index.js';
import type { LogOptions } from '../logger/core';
import type { LogOptions } from '../logger/core.js';
import { printHelp } from '../messages.js';
import createStaticPreviewServer from './static-preview-server.js';
import { getResolvedHostForHttpServer } from './util.js';

View file

@ -3,8 +3,8 @@ import { fileURLToPath } from 'node:url';
import { performance } from 'perf_hooks';
import enableDestroy from 'server-destroy';
import { preview, type PreviewServer as VitePreviewServer } from 'vite';
import type { AstroSettings } from '../../@types/astro';
import type { LogOptions } from '../logger/core';
import type { AstroSettings } from '../../@types/astro.js';
import type { LogOptions } from '../logger/core.js';
import { error, info } from '../logger/core.js';
import * as msg from '../messages.js';
import { getResolvedHostForHttpServer } from './util.js';

View file

@ -1,5 +1,5 @@
import type { ComponentInstance } from '../../@types/astro';
import type { SinglePageBuiltModule } from '../build/types';
import type { ComponentInstance } from '../../@types/astro.js';
import type { SinglePageBuiltModule } from '../build/types.js';
// A stub of a component instance for a given route
export const RedirectComponentInstance: ComponentInstance = {

View file

@ -1,4 +1,9 @@
import type { Params, RedirectRouteData, RouteData, ValidRedirectStatus } from '../../@types/astro';
import type {
Params,
RedirectRouteData,
RouteData,
ValidRedirectStatus,
} from '../../@types/astro.js';
export function routeIsRedirect(route: RouteData | undefined): route is RedirectRouteData {
return route?.type === 'redirect';

View file

@ -5,9 +5,9 @@ import type {
RouteData,
SSRElement,
SSRResult,
} from '../../@types/astro';
} from '../../@types/astro.js';
import { AstroError, AstroErrorData } from '../errors/index.js';
import type { Environment } from './environment';
import type { Environment } from './environment.js';
import { getParamsAndProps } from './params-and-props.js';
const clientLocalsSymbol = Symbol.for('astro.locals');

View file

@ -5,7 +5,7 @@ import type {
MiddlewareHandler,
MiddlewareResponseHandler,
RouteType,
} from '../../@types/astro';
} from '../../@types/astro.js';
import { renderPage as runtimeRenderPage } from '../../runtime/server/index.js';
import { attachToResponse } from '../cookies/index.js';
import { callEndpoint, createAPIContext, type EndpointCallResult } from '../endpoint/index.js';

View file

@ -1,7 +1,7 @@
import type { MarkdownRenderingOptions } from '@astrojs/markdown-remark';
import type { AstroSettings, RuntimeMode, SSRLoadedRenderer } from '../../@types/astro';
import type { AstroSettings, RuntimeMode, SSRLoadedRenderer } from '../../@types/astro.js';
import type { LogOptions } from '../logger/core.js';
import type { ModuleLoader } from '../module-loader';
import type { ModuleLoader } from '../module-loader/index.js';
import type { RouteCache } from './route-cache.js';
/**

View file

@ -1,11 +1,11 @@
import type { AstroMiddlewareInstance, ComponentInstance, RouteData } from '../../@types/astro';
import type { DevelopmentEnvironment } from './environment';
import type { AstroMiddlewareInstance, ComponentInstance, RouteData } from '../../@types/astro.js';
import type { DevelopmentEnvironment } from './environment.js';
export { createRenderContext } from './context.js';
export type { RenderContext } from './context.js';
export { tryRenderRoute } from './core.js';
export type { Environment } from './environment';
export { createEnvironment } from './environment.js';
export type { Environment } from './environment.js';
export { getParamsAndProps } from './params-and-props.js';
export { loadRenderer, loadRenderers } from './renderer.js';
export type { DevelopmentEnvironment };

View file

@ -5,7 +5,7 @@ import type {
Params,
Props,
RouteData,
} from '../../@types/astro';
} from '../../@types/astro.js';
import { AstroError, AstroErrorData } from '../errors/index.js';
export function generatePaginateFunction(routeMatch: RouteData): PaginateFunction {

View file

@ -1,4 +1,4 @@
import type { ComponentInstance, Params, Props, RouteData } from '../../@types/astro';
import type { ComponentInstance, Params, Props, RouteData } from '../../@types/astro.js';
import { AstroError, AstroErrorData } from '../errors/index.js';
import type { LogOptions } from '../logger/core.js';
import { getParams } from '../routing/params.js';

View file

@ -1,4 +1,4 @@
import type { AstroRenderer, AstroSettings, SSRLoadedRenderer } from '../../@types/astro';
import type { AstroRenderer, AstroSettings, SSRLoadedRenderer } from '../../@types/astro.js';
import type { ModuleLoader } from '../module-loader/index.js';
export async function loadRenderers(

View file

@ -6,7 +6,7 @@ import type {
SSRElement,
SSRLoadedRenderer,
SSRResult,
} from '../../@types/astro';
} from '../../@types/astro.js';
import { isHTMLString } from '../../runtime/server/escape.js';
import {
renderSlotToString,

View file

@ -6,7 +6,7 @@ import type {
Params,
RouteData,
RuntimeMode,
} from '../../@types/astro';
} from '../../@types/astro.js';
import { AstroError, AstroErrorData } from '../errors/index.js';
import { debug, warn, type LogOptions } from '../logger/core.js';

View file

@ -1,6 +1,6 @@
import type { SSRElement } from '../../@types/astro';
import type { SSRElement } from '../../@types/astro.js';
import { joinPaths, prependForwardSlash, slash } from '../../core/path.js';
import type { StylesheetAsset } from '../app/types';
import type { StylesheetAsset } from '../app/types.js';
export function createAssetLink(href: string, base?: string, assetsPrefix?: string): string {
if (assetsPrefix) {

View file

@ -1,5 +1,5 @@
import type { IncomingHttpHeaders } from 'node:http';
import type { LogOptions } from './logger/core';
import type { LogOptions } from './logger/core.js';
import { warn } from './logger/core.js';
type HeaderType = Headers | Record<string, any> | IncomingHttpHeaders;

View file

@ -5,8 +5,8 @@ import type {
ManifestData,
RouteData,
RoutePart,
} from '../../../@types/astro';
import type { LogOptions } from '../../logger/core';
} from '../../../@types/astro.js';
import type { LogOptions } from '../../logger/core.js';
import { createRequire } from 'module';
import nodeFs from 'node:fs';

View file

@ -1,4 +1,4 @@
import type { AstroConfig, RoutePart } from '../../../@types/astro';
import type { AstroConfig, RoutePart } from '../../../@types/astro.js';
import { compile } from 'path-to-regexp';

View file

@ -1,4 +1,4 @@
import type { AstroConfig, RouteData, SerializedRouteData } from '../../../@types/astro';
import type { AstroConfig, RouteData, SerializedRouteData } from '../../../@types/astro.js';
import { getRouteGenerator } from './generator.js';

View file

@ -1,4 +1,4 @@
import type { ManifestData, RouteData } from '../../@types/astro';
import type { ManifestData, RouteData } from '../../@types/astro.js';
/** Find matching route from pathname */
export function matchRoute(pathname: string, manifest: ManifestData): RouteData | undefined {

View file

@ -1,4 +1,4 @@
import type { GetStaticPathsItem, Params, RouteData } from '../../@types/astro';
import type { GetStaticPathsItem, Params, RouteData } from '../../@types/astro.js';
import { validateGetStaticPathsParameter } from './validation.js';
/**

View file

@ -1,6 +1,6 @@
import type { ComponentInstance, GetStaticPathsResult, RouteData } from '../../@types/astro';
import type { ComponentInstance, GetStaticPathsResult, RouteData } from '../../@types/astro.js';
import { AstroError, AstroErrorData } from '../errors/index.js';
import type { LogOptions } from '../logger/core';
import type { LogOptions } from '../logger/core.js';
import { warn } from '../logger/core.js';
const VALID_PARAM_TYPES = ['string', 'number', 'undefined'];

View file

@ -3,7 +3,7 @@ import type fsMod from 'node:fs';
import { performance } from 'node:perf_hooks';
import { createServer, type HMRPayload } from 'vite';
import type { Arguments } from 'yargs-parser';
import type { AstroSettings } from '../../@types/astro';
import type { AstroSettings } from '../../@types/astro.js';
import { createContentTypesGenerator } from '../../content/index.js';
import { globalContentConfigObserver } from '../../content/utils.js';
import { runHookConfigSetup } from '../../integrations/index.js';

View file

@ -2,10 +2,10 @@ import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { normalizePath } from 'vite';
import type { AstroConfig, AstroSettings, RouteType } from '../@types/astro';
import type { AstroConfig, AstroSettings, RouteType } from '../@types/astro.js';
import { isServerLikeOutput } from '../prerender/utils.js';
import { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from './constants.js';
import type { ModuleLoader } from './module-loader';
import type { ModuleLoader } from './module-loader/index.js';
import { prependForwardSlash, removeTrailingForwardSlash, slash } from './path.js';
/** Returns true if argument is an object of any prototype/class (but not null). */

View file

@ -1,4 +1,4 @@
import type { AstroUserConfig } from '../@types/astro';
import type { AstroUserConfig } from '../@types/astro.js';
const EVENT_SESSION = 'ASTRO_CLI_SESSION_STARTED';

View file

@ -12,8 +12,8 @@ import type {
HookParameters,
RouteData,
} from '../@types/astro.js';
import type { SerializedSSRManifest } from '../core/app/types';
import type { PageBuildData } from '../core/build/types';
import type { SerializedSSRManifest } from '../core/app/types.js';
import type { PageBuildData } from '../core/build/types.js';
import { buildClientDirectiveEntrypoint } from '../core/client-directive/index.js';
import { mergeConfig } from '../core/config/index.js';
import { info, type LogOptions } from '../core/logger/core.js';

View file

@ -3,7 +3,7 @@ import * as t from '@babel/types';
import { AstroErrorData } from '../core/errors/errors-data.js';
import { AstroError } from '../core/errors/errors.js';
import { resolvePath } from '../core/util.js';
import type { PluginMetadata } from '../vite-plugin-astro/types';
import type { PluginMetadata } from '../vite-plugin-astro/types.js';
const ClientOnlyPlaceholder = 'astro-client-only';

View file

@ -1,4 +1,4 @@
import type { ModuleInfo, ModuleLoader } from '../core/module-loader';
import type { ModuleInfo, ModuleLoader } from '../core/module-loader/index.js';
import { viteID } from '../core/util.js';
type GetPrerenderStatusParams = {

Some files were not shown because too many files have changed in this diff Show more