fix: Enforce the usage of type imports when possible (#6502)

This commit is contained in:
Erika 2023-03-10 16:19:57 +01:00 committed by GitHub
parent d37dc7c71a
commit c44aa15534
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
65 changed files with 90 additions and 85 deletions

View file

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

View file

@ -20,7 +20,7 @@ import type { AstroTimer } from '../core/config/timer';
import type { AstroCookies } from '../core/cookies'; import type { AstroCookies } from '../core/cookies';
import type { LogOptions } from '../core/logger/core'; import type { LogOptions } from '../core/logger/core';
import type { AstroComponentFactory, AstroComponentInstance } from '../runtime/server'; import type { AstroComponentFactory, AstroComponentInstance } from '../runtime/server';
import { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from './../core/constants.js'; import type { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from './../core/constants.js';
export type { export type {
MarkdownHeading, MarkdownHeading,
MarkdownMetadata, MarkdownMetadata,

View file

@ -1,8 +1,8 @@
import fs from 'node:fs'; import fs from 'node:fs';
import path from 'node:path'; import path from 'node:path';
import { pathToFileURL } from 'node:url'; import { pathToFileURL } from 'node:url';
import { AstroSettings } from '../@types/astro.js'; import type { AstroSettings } from '../@types/astro.js';
import { StaticBuildOptions } from '../core/build/types.js'; import type { StaticBuildOptions } from '../core/build/types.js';
import { AstroError, AstroErrorData } from '../core/errors/index.js'; import { AstroError, AstroErrorData } from '../core/errors/index.js';
import { rootRelativePath } from '../core/util.js'; import { rootRelativePath } from '../core/util.js';
import { ImageService, isLocalService, LocalImageService } from './services/service.js'; import { ImageService, isLocalService, LocalImageService } from './services/service.js';

View file

@ -2,7 +2,7 @@ import { AstroError, AstroErrorData } from '../../core/errors/index.js';
import { isRemotePath } from '../../core/path.js'; import { isRemotePath } from '../../core/path.js';
import { VALID_INPUT_FORMATS } from '../consts.js'; import { VALID_INPUT_FORMATS } from '../consts.js';
import { isESMImportedImage } from '../internal.js'; import { isESMImportedImage } from '../internal.js';
import { ImageTransform, OutputFormat } from '../types.js'; import type { ImageTransform, OutputFormat } from '../types.js';
export type ImageService = LocalImageService | ExternalImageService; export type ImageService = LocalImageService | ExternalImageService;

View file

@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/ban-types */ /* eslint-disable @typescript-eslint/ban-types */
import { VALID_INPUT_FORMATS, VALID_OUTPUT_FORMATS } from './consts.js'; import type { VALID_INPUT_FORMATS, VALID_OUTPUT_FORMATS } from './consts.js';
import { ImageService } from './services/service.js'; import type { ImageService } from './services/service.js';
export type ImageQualityPreset = 'low' | 'mid' | 'high' | 'max' | (string & {}); export type ImageQualityPreset = 'low' | 'mid' | 'high' | 'max' | (string & {});
export type ImageQuality = ImageQualityPreset | number; export type ImageQuality = ImageQualityPreset | number;

View file

@ -1,6 +1,6 @@
import fs from 'node:fs/promises'; import fs from 'node:fs/promises';
import { fileURLToPath } from 'node:url'; import { fileURLToPath } from 'node:url';
import { ImageMetadata, InputFormat } from '../types.js'; import type { ImageMetadata, InputFormat } from '../types.js';
export interface Metadata extends ImageMetadata { export interface Metadata extends ImageMetadata {
orientation?: number; orientation?: number;

View file

@ -1,4 +1,4 @@
import { ImageMetadata, InputFormat } from '../types.js'; import type { ImageMetadata, InputFormat } from '../types.js';
export function getOrigQueryParams( export function getOrigQueryParams(
params: URLSearchParams params: URLSearchParams

View file

@ -2,7 +2,7 @@ import { basename, extname } from 'path';
import { removeQueryString } from '../../core/path.js'; import { removeQueryString } from '../../core/path.js';
import { shorthash } from '../../runtime/server/shorthash.js'; import { shorthash } from '../../runtime/server/shorthash.js';
import { isESMImportedImage } from '../internal.js'; import { isESMImportedImage } from '../internal.js';
import { ImageTransform } from '../types.js'; import type { ImageTransform } from '../types.js';
export function propsToFilename(transform: ImageTransform) { export function propsToFilename(transform: ImageTransform) {
if (!isESMImportedImage(transform.src)) { if (!isESMImportedImage(transform.src)) {

View file

@ -5,7 +5,7 @@ import { Readable } from 'node:stream';
import { fileURLToPath } from 'node:url'; import { fileURLToPath } from 'node:url';
import type * as vite from 'vite'; import type * as vite from 'vite';
import { normalizePath } from 'vite'; import { normalizePath } from 'vite';
import { AstroPluginOptions, ImageTransform } from '../@types/astro'; import type { AstroPluginOptions, ImageTransform } from '../@types/astro';
import { error } from '../core/logger/core.js'; import { error } from '../core/logger/core.js';
import { joinPaths, prependForwardSlash } from '../core/path.js'; import { joinPaths, prependForwardSlash } from '../core/path.js';
import { VIRTUAL_MODULE_ID, VIRTUAL_SERVICE_ID } from './consts.js'; import { VIRTUAL_MODULE_ID, VIRTUAL_SERVICE_ID } from './consts.js';

View file

@ -6,7 +6,7 @@ import { fileURLToPath, pathToFileURL } from 'node:url';
import type { EmitFile } from 'rollup'; import type { EmitFile } from 'rollup';
import { ErrorPayload as ViteErrorPayload, normalizePath, ViteDevServer } from 'vite'; import { ErrorPayload as ViteErrorPayload, normalizePath, ViteDevServer } from 'vite';
import { z } from 'zod'; import { z } from 'zod';
import { AstroConfig, AstroSettings } from '../@types/astro.js'; import type { AstroConfig, AstroSettings } from '../@types/astro.js';
import { emitESMImage } from '../assets/internal.js'; import { emitESMImage } from '../assets/internal.js';
import { AstroError, AstroErrorData } from '../core/errors/index.js'; import { AstroError, AstroErrorData } from '../core/errors/index.js';
import { CONTENT_TYPES_FILE } from './consts.js'; import { CONTENT_TYPES_FILE } from './consts.js';

View file

@ -1,10 +1,10 @@
import npath from 'node:path'; import npath from 'node:path';
import { pathToFileURL } from 'url'; import { pathToFileURL } from 'url';
import type { Plugin } from 'vite'; import type { Plugin } from 'vite';
import { AstroSettings } from '../@types/astro.js'; import type { AstroSettings } from '../@types/astro.js';
import { moduleIsTopLevelPage, walkParentInfos } from '../core/build/graph.js'; import { moduleIsTopLevelPage, walkParentInfos } from '../core/build/graph.js';
import { BuildInternals, getPageDataByViteID } from '../core/build/internal.js'; import { BuildInternals, getPageDataByViteID } from '../core/build/internal.js';
import { AstroBuildPlugin } from '../core/build/plugin.js'; import type { AstroBuildPlugin } from '../core/build/plugin.js';
import type { StaticBuildOptions } from '../core/build/types'; import type { StaticBuildOptions } from '../core/build/types';
import type { ModuleLoader } from '../core/module-loader/loader.js'; import type { ModuleLoader } from '../core/module-loader/loader.js';
import { createViteLoader } from '../core/module-loader/vite.js'; import { createViteLoader } from '../core/module-loader/vite.js';

View file

@ -3,7 +3,7 @@ import type fsMod from 'node:fs';
import { extname } from 'node:path'; import { extname } from 'node:path';
import { pathToFileURL } from 'url'; import { pathToFileURL } from 'url';
import type { Plugin } from 'vite'; import type { Plugin } from 'vite';
import { AstroSettings, ContentEntryType } from '../@types/astro.js'; import type { AstroSettings, ContentEntryType } from '../@types/astro.js';
import { AstroErrorData } from '../core/errors/errors-data.js'; import { AstroErrorData } from '../core/errors/errors-data.js';
import { AstroError } from '../core/errors/errors.js'; import { AstroError } from '../core/errors/errors.js';
import { escapeViteEnvReferences, getFileInfo } from '../vite-plugin-utils/index.js'; import { escapeViteEnvReferences, getFileInfo } from '../vite-plugin-utils/index.js';

View file

@ -2,7 +2,7 @@ import type { RouteData } from '../../@types/astro';
import type { SerializedSSRManifest, SSRManifest } from './types'; import type { SerializedSSRManifest, SSRManifest } from './types';
import * as fs from 'fs'; import * as fs from 'fs';
import { IncomingMessage } from 'http'; import type { IncomingMessage } from 'http';
import { TLSSocket } from 'tls'; import { TLSSocket } from 'tls';
import { deserializeManifest } from './common.js'; import { deserializeManifest } from './common.js';
import { App, MatchOptions } from './index.js'; import { App, MatchOptions } from './index.js';

View file

@ -1,4 +1,4 @@
import { InputOptions } from 'rollup'; import type { InputOptions } from 'rollup';
function fromEntries<V>(entries: [string, V][]) { function fromEntries<V>(entries: [string, V][]) {
const obj: Record<string, V> = {}; const obj: Record<string, V> = {};

View file

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

View file

@ -5,8 +5,8 @@ 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';
import { performance } from 'perf_hooks'; import { performance } from 'perf_hooks';
import * as vite from 'vite'; import type * as vite from 'vite';
import yargs from 'yargs-parser'; import type yargs from 'yargs-parser';
import { import {
runHookBuildDone, runHookBuildDone,
runHookBuildStart, runHookBuildStart,
@ -21,7 +21,7 @@ import { RouteCache } from '../render/route-cache.js';
import { createRouteManifest } from '../routing/index.js'; import { createRouteManifest } from '../routing/index.js';
import { collectPagesData } from './page-data.js'; import { collectPagesData } from './page-data.js';
import { staticBuild, viteBuild } from './static-build.js'; import { staticBuild, viteBuild } from './static-build.js';
import { StaticBuildOptions } from './types.js'; import type { StaticBuildOptions } from './types.js';
import { getTimeStat } from './util.js'; import { getTimeStat } from './util.js';
export interface BuildOptions { export interface BuildOptions {

View file

@ -1,8 +1,8 @@
import type { OutputChunk, RenderedChunk } from 'rollup'; import type { OutputChunk, RenderedChunk } from 'rollup';
import type { PageBuildData, ViteID } from './types'; import type { PageBuildData, ViteID } from './types';
import { SSRResult } from '../../@types/astro'; import type { SSRResult } from '../../@types/astro';
import { PageOptions } from '../../vite-plugin-astro/types'; import type { PageOptions } from '../../vite-plugin-astro/types';
import { prependForwardSlash, removeFileExtension } from '../path.js'; import { prependForwardSlash, removeFileExtension } from '../path.js';
import { viteID } from '../util.js'; import { viteID } from '../util.js';

View file

@ -1,6 +1,6 @@
import type { Alias, Plugin as VitePlugin } from 'vite'; import type { Alias, Plugin as VitePlugin } from 'vite';
import type { BuildInternals } from '../internal.js'; import type { BuildInternals } from '../internal.js';
import { AstroBuildPlugin } from '../plugin.js'; import type { AstroBuildPlugin } from '../plugin.js';
/** /**
* `@rollup/plugin-alias` doesn't resolve aliases in Rollup input by default. This plugin fixes it * `@rollup/plugin-alias` doesn't resolve aliases in Rollup input by default. This plugin fixes it

View file

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

View file

@ -14,7 +14,7 @@ import { serializeRouteData } from '../../routing/index.js';
import { addRollupInput } from '../add-rollup-input.js'; import { addRollupInput } from '../add-rollup-input.js';
import { getOutFile, getOutFolder } from '../common.js'; import { getOutFile, getOutFolder } from '../common.js';
import { eachPrerenderedPageData, eachServerPageData, sortedCSS } from '../internal.js'; import { eachPrerenderedPageData, eachServerPageData, sortedCSS } from '../internal.js';
import { AstroBuildPlugin } from '../plugin'; import type { AstroBuildPlugin } from '../plugin';
export const virtualModuleId = '@astrojs-ssr-virtual-entry'; export const virtualModuleId = '@astrojs-ssr-virtual-entry';
const resolvedVirtualModuleId = '\0' + virtualModuleId; const resolvedVirtualModuleId = '\0' + virtualModuleId;

View file

@ -7,7 +7,7 @@ import path from 'path';
import { fileURLToPath, pathToFileURL } from 'url'; import { fileURLToPath, pathToFileURL } from 'url';
import { mergeConfig as mergeViteConfig } from 'vite'; import { mergeConfig as mergeViteConfig } from 'vite';
import { AstroError, AstroErrorData } from '../errors/index.js'; import { AstroError, AstroErrorData } from '../errors/index.js';
import { LogOptions } from '../logger/core.js'; import type { LogOptions } from '../logger/core.js';
import { arraify, isObject, isURL } from '../util.js'; import { arraify, isObject, isURL } from '../util.js';
import { createRelativeSchema } from './schema.js'; import { createRelativeSchema } from './schema.js';
import { loadConfigWithVite } from './vite-load.js'; import { loadConfigWithVite } from './vite-load.js';

View file

@ -3,7 +3,7 @@ import { markdownConfigDefaults } from '@astrojs/markdown-remark';
import type { ILanguageRegistration, IThemeRegistration, Theme } from 'shiki'; import type { ILanguageRegistration, IThemeRegistration, Theme } from 'shiki';
import type { AstroUserConfig, ViteUserConfig } from '../../@types/astro'; import type { AstroUserConfig, ViteUserConfig } from '../../@types/astro';
import { OutgoingHttpHeaders } from 'http'; import type { OutgoingHttpHeaders } from 'http';
import { BUNDLED_THEMES } from 'shiki'; import { BUNDLED_THEMES } from 'shiki';
import { z } from 'zod'; import { z } from 'zod';
import { appendForwardSlash, prependForwardSlash, trimSlashes } from '../path.js'; import { appendForwardSlash, prependForwardSlash, trimSlashes } from '../path.js';

View file

@ -1,4 +1,4 @@
import * as http from 'http'; import type * as http from 'http';
import type { AddressInfo } from 'net'; import type { AddressInfo } from 'net';
import type { AstroSettings, AstroUserConfig } from '../../@types/astro'; import type { AstroSettings, AstroUserConfig } from '../../@types/astro';
@ -13,7 +13,7 @@ import {
} from '../../integrations/index.js'; } from '../../integrations/index.js';
import { createDefaultDevSettings, resolveRoot } from '../config/index.js'; import { createDefaultDevSettings, resolveRoot } from '../config/index.js';
import { createVite } from '../create-vite.js'; import { createVite } from '../create-vite.js';
import { LogOptions } from '../logger/core.js'; import type { LogOptions } from '../logger/core.js';
import { nodeLogDestination } from '../logger/node.js'; import { nodeLogDestination } from '../logger/node.js';
import { appendForwardSlash } from '../path.js'; import { appendForwardSlash } from '../path.js';
import { apply as applyPolyfill } from '../polyfill.js'; import { apply as applyPolyfill } from '../polyfill.js';

View file

@ -3,8 +3,8 @@ import type http from 'http';
import { cyan } from 'kleur/colors'; import { cyan } from 'kleur/colors';
import type { AddressInfo } from 'net'; import type { AddressInfo } from 'net';
import { performance } from 'perf_hooks'; import { performance } from 'perf_hooks';
import * as vite from 'vite'; import type * as vite from 'vite';
import yargs from 'yargs-parser'; import type yargs from 'yargs-parser';
import type { AstroSettings } from '../../@types/astro'; import type { AstroSettings } from '../../@types/astro';
import { attachContentServerListeners } from '../../content/index.js'; import { attachContentServerListeners } from '../../content/index.js';
import { info, LogOptions, warn } from '../logger/core.js'; import { info, LogOptions, warn } from '../logger/core.js';

View file

@ -1,5 +1,5 @@
import type { DiagnosticCode } from '@astrojs/compiler/shared/diagnostics.js'; import type { DiagnosticCode } from '@astrojs/compiler/shared/diagnostics.js';
import { AstroErrorCodes } from './errors-data.js'; import type { AstroErrorCodes } from './errors-data.js';
import { codeFrame } from './printer.js'; import { codeFrame } from './printer.js';
import { getErrorDataByCode } from './utils.js'; import { getErrorDataByCode } from './utils.js';

View file

@ -1,4 +1,4 @@
import { DiagnosticCode } from '@astrojs/compiler/shared/diagnostics.js'; import type { DiagnosticCode } from '@astrojs/compiler/shared/diagnostics.js';
import type { SSRError } from '../../@types/astro.js'; import type { SSRError } from '../../@types/astro.js';
import { AstroErrorCodes, AstroErrorData, ErrorData } from './errors-data.js'; import { AstroErrorCodes, AstroErrorData, ErrorData } from './errors-data.js';

View file

@ -14,8 +14,8 @@ import {
underline, underline,
yellow, yellow,
} from 'kleur/colors'; } from 'kleur/colors';
import { ResolvedServerUrls } from 'vite'; import type { ResolvedServerUrls } from 'vite';
import { ZodError } from 'zod'; import type { ZodError } from 'zod';
import { renderErrorMarkdown } from './errors/dev/utils.js'; import { renderErrorMarkdown } from './errors/dev/utils.js';
import { AstroError, CompilerError, ErrorWithMetadata } from './errors/index.js'; import { AstroError, CompilerError, ErrorWithMetadata } from './errors/index.js';
import { emoji, padMultilineString } from './util.js'; import { emoji, padMultilineString } from './util.js';

View file

@ -1,4 +1,4 @@
import http from 'http'; import type http from 'http';
import { performance } from 'perf_hooks'; import { performance } from 'perf_hooks';
import enableDestroy from 'server-destroy'; import enableDestroy from 'server-destroy';
import { fileURLToPath } from 'url'; import { fileURLToPath } from 'url';

View file

@ -1,7 +1,7 @@
import fs from 'fs'; import fs from 'fs';
import { fileURLToPath } from 'url'; import { fileURLToPath } from 'url';
import { Plugin } from 'vite'; import type { Plugin } from 'vite';
import { AstroSettings } from '../../@types/astro.js'; import type { AstroSettings } from '../../@types/astro.js';
import { notFoundTemplate, subpathNotUsedTemplate } from '../../template/4xx.js'; import { notFoundTemplate, subpathNotUsedTemplate } from '../../template/4xx.js';
import { stripBase } from './util.js'; import { stripBase } from './util.js';

View file

@ -1,6 +1,6 @@
import type { ModuleLoader } from '../../module-loader/index'; import type { ModuleLoader } from '../../module-loader/index';
import { RuntimeMode } from '../../../@types/astro.js'; import type { RuntimeMode } from '../../../@types/astro.js';
import { viteID } from '../../util.js'; import { viteID } from '../../util.js';
import { isBuildableCSSRequest } from './util.js'; import { isBuildableCSSRequest } from './util.js';
import { crawlGraph } from './vite.js'; import { crawlGraph } from './vite.js';

View file

@ -1,4 +1,4 @@
import { import type {
GetStaticPathsResult, GetStaticPathsResult,
Page, Page,
PaginateFunction, PaginateFunction,

View file

@ -1,4 +1,4 @@
import { ZodError } from 'zod'; import type { ZodError } from 'zod';
import { AstroError, AstroErrorData, ErrorWithMetadata } from '../core/errors/index.js'; import { AstroError, AstroErrorData, ErrorWithMetadata } from '../core/errors/index.js';
import { getErrorDataByCode } from '../core/errors/utils.js'; import { getErrorDataByCode } from '../core/errors/utils.js';

View file

@ -3,7 +3,7 @@ import type { AddressInfo } from 'net';
import fs from 'node:fs'; import fs from 'node:fs';
import { fileURLToPath } from 'node:url'; import { fileURLToPath } from 'node:url';
import type { InlineConfig, ViteDevServer } from 'vite'; import type { InlineConfig, ViteDevServer } from 'vite';
import { import type {
AstroConfig, AstroConfig,
AstroRenderer, AstroRenderer,
AstroSettings, AstroSettings,

View file

@ -1,5 +1,5 @@
/* eslint-disable no-console */ /* eslint-disable no-console */
import { SSRResult } from '../../@types/astro.js'; import type { SSRResult } from '../../@types/astro.js';
import { AstroJSX, AstroVNode, isVNode } from '../../jsx-runtime/index.js'; import { AstroJSX, AstroVNode, isVNode } from '../../jsx-runtime/index.js';
import { import {
escapeHTML, escapeHTML,

View file

@ -1,4 +1,4 @@
import { SSRElement, SSRResult } from '../../../@types/astro'; import type { SSRElement, SSRResult } from '../../../@types/astro';
import { renderElement } from './util.js'; import { renderElement } from './util.js';
const stylesheetRel = 'stylesheet'; const stylesheetRel = 'stylesheet';

View file

@ -3,7 +3,7 @@ import type { AstroSettings, ManifestData } from '../@types/astro';
import type fs from 'fs'; import type fs from 'fs';
import { patchOverlay } from '../core/errors/overlay.js'; import { patchOverlay } from '../core/errors/overlay.js';
import { LogOptions } from '../core/logger/core.js'; import type { LogOptions } from '../core/logger/core.js';
import { createViteLoader } from '../core/module-loader/index.js'; import { createViteLoader } from '../core/module-loader/index.js';
import { createDevelopmentEnvironment } from '../core/render/dev/index.js'; import { createDevelopmentEnvironment } from '../core/render/dev/index.js';
import { createRouteManifest } from '../core/routing/index.js'; import { createRouteManifest } from '../core/routing/index.js';

View file

@ -1,7 +1,11 @@
import type http from 'http'; import type http from 'http';
import mime from 'mime'; import mime from 'mime';
import type { AstroSettings, ComponentInstance, ManifestData, RouteData } from '../@types/astro'; import type { AstroSettings, ComponentInstance, ManifestData, RouteData } from '../@types/astro';
import { ComponentPreload, DevelopmentEnvironment, SSROptions } from '../core/render/dev/index'; import type {
ComponentPreload,
DevelopmentEnvironment,
SSROptions,
} from '../core/render/dev/index';
import { attachToResponse } from '../core/cookies/index.js'; import { attachToResponse } from '../core/cookies/index.js';
import { call as callEndpoint } from '../core/endpoint/dev/index.js'; import { call as callEndpoint } from '../core/endpoint/dev/index.js';

View file

@ -1,7 +1,7 @@
import { ESBuildTransformResult, transformWithEsbuild } from 'vite'; import { ESBuildTransformResult, transformWithEsbuild } from 'vite';
import { AstroConfig } from '../@types/astro'; import type { AstroConfig } from '../@types/astro';
import { cachedCompilation, CompileProps, CompileResult } from '../core/compile/index.js'; import { cachedCompilation, CompileProps, CompileResult } from '../core/compile/index.js';
import { LogOptions } from '../core/logger/core.js'; import type { LogOptions } from '../core/logger/core.js';
import { getFileInfo } from '../vite-plugin-utils/index.js'; import { getFileInfo } from '../vite-plugin-utils/index.js';
interface CachedFullCompilation { interface CachedFullCompilation {

View file

@ -4,7 +4,7 @@ import type { BuildInternals } from '../core/build/internal.js';
import type { AstroBuildPlugin } from '../core/build/plugin.js'; import type { AstroBuildPlugin } from '../core/build/plugin.js';
import type { StaticBuildOptions } from '../core/build/types'; import type { StaticBuildOptions } from '../core/build/types';
import * as vite from 'vite'; import type * as vite from 'vite';
import { walkParentInfos } from '../core/build/graph.js'; import { walkParentInfos } from '../core/build/graph.js';
import { getAstroMetadata } from '../vite-plugin-astro/index.js'; import { getAstroMetadata } from '../vite-plugin-astro/index.js';

View file

@ -1,7 +1,7 @@
import type { Root, RootContent } from 'hast'; import type { Root, RootContent } from 'hast';
import type { Plugin } from 'unified'; import type { Plugin } from 'unified';
import MagicString from 'magic-string'; import type MagicString from 'magic-string';
import { visit } from 'unist-util-visit'; import { visit } from 'unist-util-visit';
import { escape } from './utils.js'; import { escape } from './utils.js';

View file

@ -1,5 +1,5 @@
import type { Element } from 'hast'; import type { Element } from 'hast';
import MagicString from 'magic-string'; import type MagicString from 'magic-string';
const splitAttrsTokenizer = /([\$\{\}\@a-z0-9_\:\-]*)\s*?=\s*?(['"]?)(.*?)\2\s+/gim; const splitAttrsTokenizer = /([\$\{\}\@a-z0-9_\:\-]*)\s*?=\s*?(['"]?)(.*?)\2\s+/gim;

View file

@ -1,6 +1,6 @@
import { Plugin as VitePlugin } from 'vite'; import type { Plugin as VitePlugin } from 'vite';
import { AstroSettings } from '../@types/astro.js'; import type { AstroSettings } from '../@types/astro.js';
import { LogOptions } from '../core/logger/core.js'; import type { LogOptions } from '../core/logger/core.js';
import { runHookServerSetup } from '../integrations/index.js'; import { runHookServerSetup } from '../integrations/index.js';
/** Connect Astro integrations into Vite, as needed. */ /** Connect Astro integrations into Vite, as needed. */

View file

@ -1,5 +1,5 @@
import { TsConfigJson } from 'tsconfig-resolver'; import type { TsConfigJson } from 'tsconfig-resolver';
import { AstroRenderer } from '../@types/astro'; import type { AstroRenderer } from '../@types/astro';
import { parseNpmName } from '../core/util.js'; import { parseNpmName } from '../core/util.js';
export async function detectImportSource( export async function detectImportSource(

View file

@ -1,5 +1,5 @@
import { fileURLToPath } from 'node:url'; import { fileURLToPath } from 'node:url';
import { ContentEntryType } from '../@types/astro.js'; import type { ContentEntryType } from '../@types/astro.js';
import { parseFrontmatter } from '../content/utils.js'; import { parseFrontmatter } from '../content/utils.js';
export const markdownContentEntryType: ContentEntryType = { export const markdownContentEntryType: ContentEntryType = {

View file

@ -1,5 +1,5 @@
import { normalizePath, Plugin as VitePlugin } from 'vite'; import { normalizePath, Plugin as VitePlugin } from 'vite';
import { AstroSettings } from '../@types/astro.js'; import type { AstroSettings } from '../@types/astro.js';
import { isEndpoint, isPage } from '../core/util.js'; import { isEndpoint, isPage } from '../core/util.js';
import { scan } from './scan.js'; import { scan } from './scan.js';

View file

@ -1,6 +1,6 @@
import * as eslexer from 'es-module-lexer'; import * as eslexer from 'es-module-lexer';
import { AstroError, AstroErrorData } from '../core/errors/index.js'; import { AstroError, AstroErrorData } from '../core/errors/index.js';
import { PageOptions } from '../vite-plugin-astro/types.js'; import type { PageOptions } from '../vite-plugin-astro/types.js';
const BOOLEAN_EXPORTS = new Set(['prerender']); const BOOLEAN_EXPORTS = new Set(['prerender']);

View file

@ -1,5 +1,5 @@
import { ConfigEnv, Plugin as VitePlugin } from 'vite'; import type { ConfigEnv, Plugin as VitePlugin } from 'vite';
import { AstroSettings, InjectedScriptStage } from '../@types/astro.js'; import type { AstroSettings, InjectedScriptStage } from '../@types/astro.js';
// NOTE: We can't use the virtual "\0" ID convention because we need to // NOTE: We can't use the virtual "\0" ID convention because we need to
// inject these as ESM imports into actual code, where they would not // inject these as ESM imports into actual code, where they would not

View file

@ -1,6 +1,6 @@
import MagicString from 'magic-string'; import MagicString from 'magic-string';
import { normalizePath, Plugin as VitePlugin } from 'vite'; import { normalizePath, Plugin as VitePlugin } from 'vite';
import { AstroSettings } from '../@types/astro.js'; import type { AstroSettings } from '../@types/astro.js';
import { isPage } from '../core/util.js'; import { isPage } from '../core/util.js';
import { PAGE_SSR_SCRIPT_ID } from './index.js'; import { PAGE_SSR_SCRIPT_ID } from './index.js';

View file

@ -1,4 +1,4 @@
import { type Context } from './context'; import type { Context } from './context';
import { color, label } from '@astrojs/cli-kit'; import { color, label } from '@astrojs/cli-kit';
import { random } from '@astrojs/cli-kit/utils'; import { random } from '@astrojs/cli-kit/utils';

View file

@ -1,5 +1,5 @@
import path from 'node:path'; import path from 'node:path';
import { Context } from './context'; import type { Context } from './context';
import { nextSteps, say } from '../messages.js'; import { nextSteps, say } from '../messages.js';

View file

@ -2,7 +2,7 @@
import mime from 'mime'; import mime from 'mime';
import { OutputFormat, parseAspectRatio, TransformOptions } from '../loaders/index.js'; import { OutputFormat, parseAspectRatio, TransformOptions } from '../loaders/index.js';
import { extname } from '../utils/paths.js'; import { extname } from '../utils/paths.js';
import { ImageMetadata } from '../vite-plugin-astro-image.js'; import type { ImageMetadata } from '../vite-plugin-astro-image.js';
import { getImage } from './get-image.js'; import { getImage } from './get-image.js';
export interface GetPictureParams { export interface GetPictureParams {

View file

@ -1,8 +1,8 @@
import sizeOf from 'image-size'; import sizeOf from 'image-size';
import fs from 'node:fs/promises'; import fs from 'node:fs/promises';
import { fileURLToPath } from 'node:url'; import { fileURLToPath } from 'node:url';
import { InputFormat } from '../loaders/index.js'; import type { InputFormat } from '../loaders/index.js';
import { ImageMetadata } from '../vite-plugin-astro-image.js'; import type { ImageMetadata } from '../vite-plugin-astro-image.js';
export interface Metadata extends ImageMetadata { export interface Metadata extends ImageMetadata {
orientation?: number; orientation?: number;

View file

@ -1,4 +1,4 @@
import { TransformOptions } from '../loaders/index.js'; import type { TransformOptions } from '../loaders/index.js';
import { shorthash } from './shorthash.js'; import { shorthash } from './shorthash.js';
export function isRemoteImage(src: string) { export function isRemoteImage(src: string) {

View file

@ -3,7 +3,7 @@ import Markdoc from '@markdoc/markdoc';
import type { AstroConfig, AstroIntegration, ContentEntryType, HookParameters } from 'astro'; import type { AstroConfig, AstroIntegration, ContentEntryType, HookParameters } from 'astro';
import fs from 'node:fs'; import fs from 'node:fs';
import { fileURLToPath } from 'node:url'; import { fileURLToPath } from 'node:url';
import { InlineConfig } from 'vite'; import type { InlineConfig } from 'vite';
import { import {
getAstroConfigPath, getAstroConfigPath,
MarkdocError, MarkdocError,

View file

@ -1,7 +1,7 @@
import { markdownConfigDefaults } from '@astrojs/markdown-remark'; import { markdownConfigDefaults } from '@astrojs/markdown-remark';
import { toRemarkInitializeAstroData } from '@astrojs/markdown-remark/dist/internal.js'; import { toRemarkInitializeAstroData } from '@astrojs/markdown-remark/dist/internal.js';
import { compile as mdxCompile } from '@mdx-js/mdx'; import { compile as mdxCompile } from '@mdx-js/mdx';
import { PluggableList } from '@mdx-js/mdx/lib/core.js'; import type { PluggableList } from '@mdx-js/mdx/lib/core.js';
import mdxPlugin, { Options as MdxRollupPluginOptions } from '@mdx-js/rollup'; import mdxPlugin, { Options as MdxRollupPluginOptions } from '@mdx-js/rollup';
import type { AstroIntegration, ContentEntryType, HookParameters } from 'astro'; import type { AstroIntegration, ContentEntryType, HookParameters } from 'astro';
import { parse as parseESM } from 'es-module-lexer'; import { parse as parseESM } from 'es-module-lexer';

View file

@ -13,7 +13,7 @@ import rehypeRaw from 'rehype-raw';
import remarkGfm from 'remark-gfm'; import remarkGfm from 'remark-gfm';
import remarkSmartypants from 'remark-smartypants'; import remarkSmartypants from 'remark-smartypants';
import type { VFile } from 'vfile'; import type { VFile } from 'vfile';
import { MdxOptions } from './index.js'; import type { MdxOptions } from './index.js';
import { rehypeInjectHeadingsExport } from './rehype-collect-headings.js'; import { rehypeInjectHeadingsExport } from './rehype-collect-headings.js';
import rehypeMetaString from './rehype-meta-string.js'; import rehypeMetaString from './rehype-meta-string.js';
import remarkPrism from './remark-prism.js'; import remarkPrism from './remark-prism.js';

View file

@ -1,4 +1,4 @@
import { MarkdownHeading, MarkdownVFile } from '@astrojs/markdown-remark'; import type { MarkdownHeading, MarkdownVFile } from '@astrojs/markdown-remark';
import { jsToTreeNode } from './utils.js'; import { jsToTreeNode } from './utils.js';
export function rehypeInjectHeadingsExport() { export function rehypeInjectHeadingsExport() {

View file

@ -1,6 +1,6 @@
import { polyfill } from '@astrojs/webapi'; import { polyfill } from '@astrojs/webapi';
import { builder, Handler } from '@netlify/functions'; import { builder, Handler } from '@netlify/functions';
import { SSRManifest } from 'astro'; import type { SSRManifest } from 'astro';
import { App } from 'astro/app'; import { App } from 'astro/app';
polyfill(globalThis, { polyfill(globalThis, {

View file

@ -1,5 +1,5 @@
import type { CreatePreviewServer } from 'astro'; import type { CreatePreviewServer } from 'astro';
import http from 'http'; import type http from 'http';
import { fileURLToPath } from 'url'; import { fileURLToPath } from 'url';
import { createServer } from './http-server.js'; import { createServer } from './http-server.js';
import type { createExports } from './server'; import type { createExports } from './server';

View file

@ -1,4 +1,4 @@
import { AstroIntegration, AstroRenderer, ViteUserConfig } from 'astro'; import type { AstroIntegration, AstroRenderer, ViteUserConfig } from 'astro';
function getRenderer(development: boolean): AstroRenderer { function getRenderer(development: boolean): AstroRenderer {
return { return {

View file

@ -1,4 +1,4 @@
import { AstroIntegration } from 'astro'; import type { AstroIntegration } from 'astro';
import { version as ReactVersion } from 'react-dom'; import { version as ReactVersion } from 'react-dom';
function getRenderer() { function getRenderer() {

View file

@ -1,4 +1,4 @@
import { EnumChangefreq } from 'sitemap'; import type { EnumChangefreq } from 'sitemap';
import type { SitemapItem, SitemapOptions } from './index.js'; import type { SitemapItem, SitemapOptions } from './index.js';
import { parseUrl } from './utils/parse-url.js'; import { parseUrl } from './utils/parse-url.js';

View file

@ -1,6 +1,6 @@
import { resolve as importMetaResolve } from 'import-meta-resolve'; import { resolve as importMetaResolve } from 'import-meta-resolve';
import path from 'path'; import path from 'path';
import * as unified from 'unified'; import type * as unified from 'unified';
import { pathToFileURL } from 'url'; import { pathToFileURL } from 'url';
const cwdUrlStr = pathToFileURL(path.join(process.cwd(), 'package.json')).toString(); const cwdUrlStr = pathToFileURL(path.join(process.cwd(), 'package.json')).toString();

View file

@ -1,7 +1,7 @@
import { type Expression, type Super } from 'estree'; import type { Expression, Super } from 'estree';
import Slugger from 'github-slugger'; import Slugger from 'github-slugger';
import { type MdxTextExpression } from 'mdast-util-mdx-expression'; import type { MdxTextExpression } from 'mdast-util-mdx-expression';
import { type Node } from 'unist'; import type { Node } from 'unist';
import { visit } from 'unist-util-visit'; import { visit } from 'unist-util-visit';
import { InvalidAstroDataError, safelyGetAstroData } from './frontmatter-injection.js'; import { InvalidAstroDataError, safelyGetAstroData } from './frontmatter-injection.js';

View file

@ -6,6 +6,7 @@
"moduleResolution": "node", "moduleResolution": "node",
"esModuleInterop": true, "esModuleInterop": true,
"skipLibCheck": true, "skipLibCheck": true,
"forceConsistentCasingInFileNames": true "forceConsistentCasingInFileNames": true,
"importsNotUsedAsValues": "error"
} }
} }