Skip to content

Commit

Permalink
config: use moduleResolution node16
Browse files Browse the repository at this point in the history
  • Loading branch information
Princesseuh committed Jul 24, 2023
1 parent cb973ee commit 9959899
Show file tree
Hide file tree
Showing 197 changed files with 326 additions and 313 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"typescript.preferences.importModuleSpecifierEnding": "js"
}
2 changes: 1 addition & 1 deletion packages/astro-rss/src/util.ts
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
8 changes: 4 additions & 4 deletions packages/astro/client-base.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
>;

Expand All @@ -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'];
Expand Down Expand Up @@ -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'];
Expand All @@ -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`)
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
22 changes: 11 additions & 11 deletions packages/astro/src/@types/astro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -34,7 +34,7 @@ export type {
ExternalImageService,
ImageService,
LocalImageService,
} from '../assets/services/service';
} from '../assets/services/service.js';
export type {
GetImageResult,
ImageInputFormat,
Expand All @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions packages/astro/src/assets/services/vendor/squoosh/codecs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,23 @@ 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'

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'

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'

Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/assets/vendor/image-size/types/bmp.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { IImage } from './interface'
import type { IImage } from './interface.js'

export const BMP: IImage = {
validate(buffer) {
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/assets/vendor/image-size/types/cur.ts
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/assets/vendor/image-size/types/dds.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { IImage } from './interface'
import type { IImage } from './interface.js'

export const DDS: IImage = {
validate(buffer) {
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/assets/vendor/image-size/types/gif.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { IImage } from './interface'
import type { IImage } from './interface.js'

const gifRegexp = /^GIF8[79]a/
export const GIF: IImage = {
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/assets/vendor/image-size/types/icns.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { IImage, ISize } from './interface'
import type { IImage, ISize } from './interface.js'

/**
* ICNS Header
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/assets/vendor/image-size/types/ico.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { IImage, ISize, ISizeCalculationResult } from './interface'
import type { IImage, ISize, ISizeCalculationResult } from './interface.js'

const TYPE_ICON = 1

Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/assets/vendor/image-size/types/j2c.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { IImage } from './interface'
import type { IImage } from './interface.js'

export const J2C: IImage = {
validate(buffer) {
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/assets/vendor/image-size/types/jp2.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { IImage, ISize } from './interface'
import type { IImage, ISize } from './interface.js'

const BoxTypes = {
ftyp: '66747970',
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/assets/vendor/image-size/types/jpg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/assets/vendor/image-size/types/ktx.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { IImage } from './interface'
import type { IImage } from './interface.js'

const SIGNATURE = 'KTX 11'

Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/assets/vendor/image-size/types/png.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/assets/vendor/image-size/types/pnm.ts
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/assets/vendor/image-size/types/psd.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { IImage } from './interface'
import type { IImage } from './interface.js'

export const PSD: IImage = {
validate(buffer) {
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/assets/vendor/image-size/types/svg.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { IImage, ISize } from './interface'
import type { IImage, ISize } from './interface.js'

interface IAttributes {
width: number | null
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/assets/vendor/image-size/types/tiff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/assets/vendor/image-size/types/webp.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/assets/vite-plugin-assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 2 additions & 4 deletions packages/astro/src/cli/add/babel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/astro/src/cli/check/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
4 changes: 2 additions & 2 deletions packages/astro/src/config/index.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/config/vite-plugin-content-listen.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/content/vite-plugin-content-assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/core/app/common.ts
Original file line number Diff line number Diff line change
@@ -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[] = [];
Expand Down
8 changes: 4 additions & 4 deletions packages/astro/src/core/app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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');
Expand Down
4 changes: 2 additions & 2 deletions packages/astro/src/core/app/node.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
4 changes: 2 additions & 2 deletions packages/astro/src/core/app/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/core/build/common.ts
Original file line number Diff line number Diff line change
@@ -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']);
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/core/build/css-asset-name.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
4 changes: 2 additions & 2 deletions packages/astro/src/core/build/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import type {
SSRError,
SSRLoadedRenderer,
SSRManifest,
} from '../../@types/astro';
} from '../../@types/astro.js';
import {
generateImage as generateImageInternal,
getStaticImageList,
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/core/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading

0 comments on commit 9959899

Please sign in to comment.