Skip to content

Commit

Permalink
config: migrate us to moduleResolution: 'node16' (#8519)
Browse files Browse the repository at this point in the history
  • Loading branch information
Princesseuh authored Sep 13, 2023
1 parent b85c8a7 commit 4e395a6
Show file tree
Hide file tree
Showing 220 changed files with 346 additions and 404 deletions.
5 changes: 1 addition & 4 deletions benchmark/packages/timer/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
"extends": "../../../tsconfig.base.json",
"include": ["src"],
"compilerOptions": {
"allowJs": true,
"module": "ES2022",
"outDir": "./dist",
"target": "ES2022"
"outDir": "./dist"
}
}
3 changes: 0 additions & 3 deletions packages/astro-prism/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
"extends": "../../tsconfig.base.json",
"include": ["src"],
"compilerOptions": {
"allowJs": true,
"target": "ES2022",
"module": "ES2022",
"outDir": "./dist"
}
}
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
6 changes: 1 addition & 5 deletions packages/astro-rss/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
"extends": "../../tsconfig.base.json",
"include": ["src"],
"compilerOptions": {
"allowJs": true,
"module": "ES2022",
"outDir": "./dist",
"target": "ES2022",
"strictNullChecks": true
"outDir": "./dist"
}
}
8 changes: 4 additions & 4 deletions packages/astro/client.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ declare module 'astro:assets' {
| import('./dist/assets/types.js').ImageTransform
| import('./dist/assets/types.js').UnresolvedImageTransform
) => Promise<import('./dist/assets/types.js').GetImageResult>;
imageConfig: import('./dist/@types/astro').AstroConfig['image'];
imageConfig: import('./dist/@types/astro.js').AstroConfig['image'];
getConfiguredImageService: typeof import('./dist/assets/index.js').getConfiguredImageService;
Image: typeof import('./components/Image.astro').default;
};
Expand Down Expand Up @@ -126,7 +126,7 @@ declare module 'astro:components' {
export * from 'astro/components';
}

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 @@ -231,7 +231,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 @@ -244,7 +244,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
28 changes: 14 additions & 14 deletions packages/astro/src/@types/astro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ import type { AddressInfo } from 'node:net';
import type * as rollup from 'rollup';
import type { TsConfigJson } from 'tsconfig-resolver';
import type * as vite from 'vite';
import type { RemotePattern } from '../assets/utils/remotePattern';
import type { SerializedSSRManifest } from '../core/app/types';
import type { PageBuildData } from '../core/build/types';
import type { AstroConfigType } from '../core/config';
import type { AstroTimer } from '../core/config/timer';
import type { AstroCookies } from '../core/cookies';
import type { RemotePattern } from '../assets/utils/remotePattern.js';
import type { SerializedSSRManifest } from '../core/app/types.js';
import type { PageBuildData } from '../core/build/types.js';
import type { AstroConfigType } from '../core/config/index.js';
import type { AstroTimer } from '../core/config/timer.js';
import type { AstroCookies } from '../core/cookies/index.js';
import type { ResponseWithEncoding } from '../core/endpoint/index.js';
import type { AstroIntegrationLogger, Logger, LoggerLevel } from '../core/logger/core';
import type { AstroComponentFactory, AstroComponentInstance } from '../runtime/server';
import type { OmitIndexSignature, Simplify } from '../type-utils';
import type { AstroIntegrationLogger, Logger, LoggerLevel } from '../core/logger/core.js';
import type { AstroComponentFactory, AstroComponentInstance } from '../runtime/server/index.js';
import type { OmitIndexSignature, Simplify } from '../type-utils.js';
import type { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from './../core/constants.js';

export { type AstroIntegrationLogger };
Expand All @@ -39,7 +39,7 @@ export type {
ExternalImageService,
ImageService,
LocalImageService,
} from '../assets/services/service';
} from '../assets/services/service.js';
export type {
GetImageResult,
ImageInputFormat,
Expand All @@ -48,10 +48,10 @@ export type {
ImageQuality,
ImageQualityPreset,
ImageTransform,
} from '../assets/types';
export type { RemotePattern } from '../assets/utils/remotePattern';
export type { SSRManifest } from '../core/app/types';
export type { AstroCookies } from '../core/cookies';
} from '../assets/types.js';
export type { RemotePattern } from '../assets/utils/remotePattern.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
2 changes: 1 addition & 1 deletion packages/astro/src/assets/build/generate.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import fs, { readFileSync } from 'node:fs';
import { basename, join } from 'node:path/posix';
import type { BuildPipeline } from '../../core/build/buildPipeline';
import type { BuildPipeline } from '../../core/build/buildPipeline.js';
import { prependForwardSlash } from '../../core/path.js';
import { isServerLikeOutput } from '../../prerender/utils.js';
import { getConfiguredImageService, isESMImportedImage } from '../internal.js';
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
@@ -1,7 +1,7 @@
import MagicString from 'magic-string';
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 {
appendForwardSlash,
joinPaths,
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
2 changes: 1 addition & 1 deletion packages/astro/src/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { UserConfig } from 'vite';
import type { AstroUserConfig } from '../@types/astro';
import type { AstroUserConfig } from '../@types/astro.js';
import { Logger } from '../core/logger/core.js';

export function defineConfig(config: AstroUserConfig) {
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 { Logger } from '../core/logger/core.js';

Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/content/types-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { normalizePath, type ViteDevServer } from 'vite';
import type { AstroSettings, ContentEntryType } from '../@types/astro.js';
import { AstroError } from '../core/errors/errors.js';
import { AstroErrorData } from '../core/errors/index.js';
import type { Logger } from '../core/logger/core';
import type { Logger } from '../core/logger/core.js';
import { isRelativePath } from '../core/path.js';
import { CONTENT_TYPES_FILE, VIRTUAL_MODULE_ID } from './consts.js';
import {
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
6 changes: 3 additions & 3 deletions packages/astro/src/core/app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ 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 { getSetCookiesFromResponse } from '../cookies/index.js';
import { consoleLogDestination } from '../logger/console.js';
import { AstroIntegrationLogger, Logger } from '../logger/core.js';
Expand All @@ -25,7 +25,7 @@ import {
} from '../render/ssr-element.js';
import { matchRoute } from '../routing/match.js';
import { EndpointNotFoundError, SSRRoutePipeline } from './ssrPipeline.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
2 changes: 1 addition & 1 deletion packages/astro/src/core/app/ssrPipeline.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Pipeline } from '../pipeline.js';
import type { Environment } from '../render';
import type { Environment } from '../render/index.js';

/**
* Thrown when an endpoint contains a response with the header "X-Astro-Response" === 'Not-Found'
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 @@ -4,8 +4,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
8 changes: 4 additions & 4 deletions packages/astro/src/core/build/buildPipeline.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import type { AstroConfig, AstroSettings, SSRLoadedRenderer } from '../../@types/astro';
import type { AstroConfig, AstroSettings, SSRLoadedRenderer } from '../../@types/astro.js';
import { getOutputDirectory, isServerLikeOutput } from '../../prerender/utils.js';
import { BEFORE_HYDRATION_SCRIPT_ID } from '../../vite-plugin-scripts/index.js';
import type { SSRManifest } from '../app/types';
import type { SSRManifest } from '../app/types.js';
import { Logger } from '../logger/core.js';
import { Pipeline } from '../pipeline.js';
import { createEnvironment } from '../render/index.js';
import { createAssetLink } from '../render/ssr-element.js';
import type { BuildInternals } from './internal';
import type { BuildInternals } from './internal.js';
import { ASTRO_PAGE_RESOLVED_MODULE_ID } 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, StaticBuildOptions } from './types';
import type { PageBuildData, StaticBuildOptions } from './types.js';

/**
* This pipeline is responsible to gather the files emitted by the SSR build and generate the pages by executing these files.
Expand Down
Loading

0 comments on commit 4e395a6

Please sign in to comment.