From a2128f8e478cec8f60292206d3d22760c46f4aa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Mart=C3=ADn=20Seery?= Date: Wed, 23 Feb 2022 20:14:39 -0300 Subject: [PATCH] Fixed incorrect types and imports (#2630) * Fixed incorrect types and imports * Changeset --- .changeset/grumpy-tigers-melt.md | 5 +++++ packages/astro/package.json | 2 +- packages/astro/src/@types/astro.ts | 4 ++-- packages/astro/src/core/build/index.ts | 4 ++-- packages/astro/src/core/build/page-data.ts | 2 +- packages/astro/src/core/build/scan-based-build.ts | 4 ++-- packages/astro/src/core/build/static-build.ts | 6 +++--- .../astro/src/core/build/vite-plugin-hoisted-scripts.ts | 2 +- packages/astro/src/core/create-vite.ts | 2 +- packages/astro/src/core/dev/index.ts | 2 +- packages/astro/src/core/render/dev/css.ts | 2 +- packages/astro/src/core/render/dev/error.ts | 2 +- packages/astro/src/core/render/dev/html.ts | 2 +- packages/astro/src/core/render/dev/index.ts | 2 +- packages/astro/src/core/render/dev/renderers.ts | 2 +- packages/astro/src/core/vite.ts | 2 -- packages/astro/src/vite-plugin-astro-postprocess/index.ts | 2 +- packages/astro/src/vite-plugin-astro-server/index.ts | 2 +- packages/astro/src/vite-plugin-astro/hmr.ts | 4 ++-- packages/astro/src/vite-plugin-astro/index.ts | 5 ++--- packages/astro/src/vite-plugin-astro/styles.ts | 2 +- packages/astro/src/vite-plugin-build-css/index.ts | 2 +- packages/astro/src/vite-plugin-build-css/resolve.ts | 2 +- packages/astro/src/vite-plugin-build-html/index.ts | 2 +- packages/astro/src/vite-plugin-config-alias/index.ts | 2 +- packages/astro/src/vite-plugin-jsx/index.ts | 2 +- packages/astro/src/vite-plugin-markdown/index.ts | 2 +- 27 files changed, 37 insertions(+), 35 deletions(-) create mode 100644 .changeset/grumpy-tigers-melt.md delete mode 100644 packages/astro/src/core/vite.ts diff --git a/.changeset/grumpy-tigers-melt.md b/.changeset/grumpy-tigers-melt.md new file mode 100644 index 000000000..7a5c1e3f8 --- /dev/null +++ b/.changeset/grumpy-tigers-melt.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fixed incorrect types and imports diff --git a/packages/astro/package.json b/packages/astro/package.json index d87eec1a5..a1f114ba8 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -71,6 +71,7 @@ "@proload/plugin-tsm": "^0.1.0", "@types/babel__core": "^7.1.15", "@types/debug": "^4.1.7", + "@types/yargs-parser": "^20.2.1", "@web/parse5-utils": "^1.3.0", "ci-info": "^3.2.0", "common-ancestor-path": "^1.0.1", @@ -121,7 +122,6 @@ "@types/resolve": "^1.20.1", "@types/rimraf": "^3.0.2", "@types/send": "^0.17.1", - "@types/yargs-parser": "^20.2.1", "chai": "^4.3.4", "cheerio": "^1.0.0-rc.10", "execa": "^6.0.0", diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index c2708ab1e..ce6678e92 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -1,8 +1,8 @@ -import type babel from '@babel/core'; +import type * as babel from '@babel/core'; import type { z } from 'zod'; import type { AstroConfigSchema } from '../core/config'; import type { AstroComponentFactory, Metadata } from '../runtime/server'; -import type vite from '../core/vite'; +import type * as vite from 'vite'; export interface AstroBuiltinProps { 'client:load'?: boolean; diff --git a/packages/astro/src/core/build/index.ts b/packages/astro/src/core/build/index.ts index 68b12603d..1b7c99625 100644 --- a/packages/astro/src/core/build/index.ts +++ b/packages/astro/src/core/build/index.ts @@ -5,7 +5,7 @@ import fs from 'fs'; import * as colors from 'kleur/colors'; import { polyfill } from '@astropub/webapi'; import { performance } from 'perf_hooks'; -import vite, { ViteDevServer } from '../vite.js'; +import * as vite from 'vite'; import { createVite, ViteConfigWithSSR } from '../create-vite.js'; import { debug, defaultLogOptions, info, levels, timerMessage, warn } from '../logger.js'; import { createRouteManifest } from '../routing/index.js'; @@ -38,7 +38,7 @@ class AstroBuilder { private origin: string; private routeCache: RouteCache; private manifest: ManifestData; - private viteServer?: ViteDevServer; + private viteServer?: vite.ViteDevServer; private viteConfig?: ViteConfigWithSSR; constructor(config: AstroConfig, options: BuildOptions) { diff --git a/packages/astro/src/core/build/page-data.ts b/packages/astro/src/core/build/page-data.ts index 945423080..b3919c22a 100644 --- a/packages/astro/src/core/build/page-data.ts +++ b/packages/astro/src/core/build/page-data.ts @@ -1,7 +1,7 @@ import type { AstroConfig, ComponentInstance, ManifestData, RouteData } from '../../@types/astro'; import type { AllPagesData } from './types'; import type { LogOptions } from '../logger'; -import type { ViteDevServer } from '../vite.js'; +import type { ViteDevServer } from 'vite'; import { fileURLToPath } from 'url'; import * as colors from 'kleur/colors'; diff --git a/packages/astro/src/core/build/scan-based-build.ts b/packages/astro/src/core/build/scan-based-build.ts index d761e0bdb..632d5489d 100644 --- a/packages/astro/src/core/build/scan-based-build.ts +++ b/packages/astro/src/core/build/scan-based-build.ts @@ -1,11 +1,11 @@ -import type { ViteDevServer } from '../vite.js'; +import type { ViteDevServer } from 'vite'; import type { AstroConfig, RouteType } from '../../@types/astro'; import type { AllPagesData, PageBuildData } from './types'; import type { LogOptions } from '../logger'; import type { ViteConfigWithSSR } from '../create-vite.js'; import { fileURLToPath } from 'url'; -import vite from '../vite.js'; +import * as vite from 'vite'; import { createBuildInternals } from '../../core/build/internal.js'; import { rollupPluginAstroBuildHTML } from '../../vite-plugin-build-html/index.js'; import { rollupPluginAstroBuildCSS } from '../../vite-plugin-build-css/index.js'; diff --git a/packages/astro/src/core/build/static-build.ts b/packages/astro/src/core/build/static-build.ts index e4af1f0d9..d3e80ba3b 100644 --- a/packages/astro/src/core/build/static-build.ts +++ b/packages/astro/src/core/build/static-build.ts @@ -1,6 +1,6 @@ import type { OutputChunk, OutputAsset, RollupOutput } from 'rollup'; -import type { Plugin as VitePlugin, UserConfig, Manifest as ViteManifest } from '../vite'; -import type { AstroConfig, EndpointHandler, ComponentInstance, ManifestData, Renderer, RouteType } from '../../@types/astro'; +import type { Plugin as VitePlugin, UserConfig, Manifest as ViteManifest } from 'vite'; +import type { AstroConfig, ComponentInstance, ManifestData, Renderer, RouteType } from '../../@types/astro'; import type { AllPagesData } from './types'; import type { LogOptions } from '../logger'; import type { ViteConfigWithSSR } from '../create-vite'; @@ -12,7 +12,7 @@ import fs from 'fs'; import npath from 'path'; import { fileURLToPath } from 'url'; import glob from 'fast-glob'; -import vite from '../vite.js'; +import * as vite from 'vite'; import { debug, error } from '../../core/logger.js'; import { prependForwardSlash, appendForwardSlash } from '../../core/path.js'; import { createBuildInternals } from '../../core/build/internal.js'; diff --git a/packages/astro/src/core/build/vite-plugin-hoisted-scripts.ts b/packages/astro/src/core/build/vite-plugin-hoisted-scripts.ts index 84fd43b8a..13adf93f3 100644 --- a/packages/astro/src/core/build/vite-plugin-hoisted-scripts.ts +++ b/packages/astro/src/core/build/vite-plugin-hoisted-scripts.ts @@ -1,5 +1,5 @@ import type { AstroConfig } from '../../@types/astro'; -import type { Plugin as VitePlugin } from '../vite'; +import type { Plugin as VitePlugin } from 'vite'; import type { BuildInternals } from '../../core/build/internal.js'; import { fileURLToPath } from 'url'; diff --git a/packages/astro/src/core/create-vite.ts b/packages/astro/src/core/create-vite.ts index 044e4852e..e7cc6b9eb 100644 --- a/packages/astro/src/core/create-vite.ts +++ b/packages/astro/src/core/create-vite.ts @@ -3,7 +3,7 @@ import type { LogOptions } from './logger'; import { builtinModules } from 'module'; import { fileURLToPath } from 'url'; -import vite from './vite.js'; +import * as vite from 'vite'; import astroVitePlugin from '../vite-plugin-astro/index.js'; import astroViteServerPlugin from '../vite-plugin-astro-server/index.js'; import astroPostprocessVitePlugin from '../vite-plugin-astro-postprocess/index.js'; diff --git a/packages/astro/src/core/dev/index.ts b/packages/astro/src/core/dev/index.ts index 37fc767fc..d699879f3 100644 --- a/packages/astro/src/core/dev/index.ts +++ b/packages/astro/src/core/dev/index.ts @@ -4,7 +4,7 @@ import { performance } from 'perf_hooks'; import type { AstroConfig } from '../../@types/astro'; import { createVite } from '../create-vite.js'; import { defaultLogOptions, info, LogOptions } from '../logger.js'; -import vite from '../vite.js'; +import * as vite from 'vite'; import * as msg from '../messages.js'; export interface DevOptions { diff --git a/packages/astro/src/core/render/dev/css.ts b/packages/astro/src/core/render/dev/css.ts index 196fdafd4..631721c7b 100644 --- a/packages/astro/src/core/render/dev/css.ts +++ b/packages/astro/src/core/render/dev/css.ts @@ -1,4 +1,4 @@ -import type vite from '../../vite'; +import type * as vite from 'vite'; import path from 'path'; import { viteID } from '../../util.js'; diff --git a/packages/astro/src/core/render/dev/error.ts b/packages/astro/src/core/render/dev/error.ts index aa5a18083..352211b1f 100644 --- a/packages/astro/src/core/render/dev/error.ts +++ b/packages/astro/src/core/render/dev/error.ts @@ -1,5 +1,5 @@ import type { BuildResult } from 'esbuild'; -import type vite from '../../vite'; +import type * as vite from 'vite'; import type { SSRError } from '../../../@types/astro'; import eol from 'eol'; diff --git a/packages/astro/src/core/render/dev/html.ts b/packages/astro/src/core/render/dev/html.ts index 2ae147ade..d7596fb6d 100644 --- a/packages/astro/src/core/render/dev/html.ts +++ b/packages/astro/src/core/render/dev/html.ts @@ -1,4 +1,4 @@ -import type vite from '../../vite'; +import type * as vite from 'vite'; import htmlparser2 from 'htmlparser2'; diff --git a/packages/astro/src/core/render/dev/index.ts b/packages/astro/src/core/render/dev/index.ts index 43fafeb3b..c4c769059 100644 --- a/packages/astro/src/core/render/dev/index.ts +++ b/packages/astro/src/core/render/dev/index.ts @@ -1,4 +1,4 @@ -import type vite from '../../vite'; +import type * as vite from 'vite'; import type { AstroConfig, ComponentInstance, Renderer, RouteData, RuntimeMode } from '../../../@types/astro'; import { LogOptions } from '../../logger.js'; import { fileURLToPath } from 'url'; diff --git a/packages/astro/src/core/render/dev/renderers.ts b/packages/astro/src/core/render/dev/renderers.ts index 05f9e6158..f76294ba6 100644 --- a/packages/astro/src/core/render/dev/renderers.ts +++ b/packages/astro/src/core/render/dev/renderers.ts @@ -1,4 +1,4 @@ -import type vite from '../../vite'; +import type * as vite from 'vite'; import type { AstroConfig, Renderer } from '../../../@types/astro'; import { resolveDependency } from '../../util.js'; diff --git a/packages/astro/src/core/vite.ts b/packages/astro/src/core/vite.ts deleted file mode 100644 index dee46a368..000000000 --- a/packages/astro/src/core/vite.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from 'vite'; -export { default } from 'vite'; diff --git a/packages/astro/src/vite-plugin-astro-postprocess/index.ts b/packages/astro/src/vite-plugin-astro-postprocess/index.ts index 807e68c70..fc40f9891 100644 --- a/packages/astro/src/vite-plugin-astro-postprocess/index.ts +++ b/packages/astro/src/vite-plugin-astro-postprocess/index.ts @@ -1,5 +1,5 @@ import type * as t from '@babel/types'; -import type { Plugin } from '../core/vite'; +import type { Plugin } from 'vite'; import type { AstroConfig } from '../@types/astro'; import * as babelTraverse from '@babel/traverse'; diff --git a/packages/astro/src/vite-plugin-astro-server/index.ts b/packages/astro/src/vite-plugin-astro-server/index.ts index eb08ac8a0..bf1ae7f11 100644 --- a/packages/astro/src/vite-plugin-astro-server/index.ts +++ b/packages/astro/src/vite-plugin-astro-server/index.ts @@ -1,4 +1,4 @@ -import type vite from '../core/vite'; +import type * as vite from 'vite'; import type http from 'http'; import type { AstroConfig, ManifestData, RouteData } from '../@types/astro'; import { info, LogOptions } from '../core/logger.js'; diff --git a/packages/astro/src/vite-plugin-astro/hmr.ts b/packages/astro/src/vite-plugin-astro/hmr.ts index 12bf274d0..9c753da3e 100644 --- a/packages/astro/src/vite-plugin-astro/hmr.ts +++ b/packages/astro/src/vite-plugin-astro/hmr.ts @@ -1,7 +1,7 @@ import type { AstroConfig } from '../@types/astro'; -import type { ViteDevServer, ModuleNode, HmrContext } from '../core/vite'; +import type { ViteDevServer, ModuleNode, HmrContext } from 'vite'; import type { PluginContext as RollupPluginContext, ResolvedId } from 'rollup'; -import { cachedCompilation, invalidateCompilation, isCached } from './compile.js'; +import { invalidateCompilation, isCached } from './compile.js'; interface TrackCSSDependenciesOptions { viteDevServer: ViteDevServer | null; diff --git a/packages/astro/src/vite-plugin-astro/index.ts b/packages/astro/src/vite-plugin-astro/index.ts index c6818c5ee..77381eb9c 100644 --- a/packages/astro/src/vite-plugin-astro/index.ts +++ b/packages/astro/src/vite-plugin-astro/index.ts @@ -1,10 +1,9 @@ -import type vite from '../core/vite'; +import type * as vite from 'vite'; import type { AstroConfig } from '../@types/astro'; import type { LogOptions } from '../core/logger.js'; import esbuild from 'esbuild'; -import npath from 'path'; -import { fileURLToPath, pathToFileURL } from 'url'; +import { fileURLToPath } from 'url'; import slash from 'slash'; import { getViteTransform, TransformHook } from './styles.js'; import { parseAstroRequest } from './query.js'; diff --git a/packages/astro/src/vite-plugin-astro/styles.ts b/packages/astro/src/vite-plugin-astro/styles.ts index b49ce6e9b..d344298ea 100644 --- a/packages/astro/src/vite-plugin-astro/styles.ts +++ b/packages/astro/src/vite-plugin-astro/styles.ts @@ -1,4 +1,4 @@ -import type vite from '../core/vite'; +import type * as vite from 'vite'; import { STYLE_EXTENSIONS } from '../core/render/dev/css.js'; diff --git a/packages/astro/src/vite-plugin-build-css/index.ts b/packages/astro/src/vite-plugin-build-css/index.ts index de7933f7d..2ddd74f3d 100644 --- a/packages/astro/src/vite-plugin-build-css/index.ts +++ b/packages/astro/src/vite-plugin-build-css/index.ts @@ -2,7 +2,7 @@ import type { BuildInternals } from '../core/build/internal'; import * as path from 'path'; import esbuild from 'esbuild'; -import { Plugin as VitePlugin } from '../core/vite'; +import { Plugin as VitePlugin } from 'vite'; import { isCSSRequest } from '../core/render/dev/css.js'; const PLUGIN_NAME = '@astrojs/rollup-plugin-build-css'; diff --git a/packages/astro/src/vite-plugin-build-css/resolve.ts b/packages/astro/src/vite-plugin-build-css/resolve.ts index 6880f364e..eb00a6c8f 100644 --- a/packages/astro/src/vite-plugin-build-css/resolve.ts +++ b/packages/astro/src/vite-plugin-build-css/resolve.ts @@ -1,5 +1,5 @@ import type { ResolveIdHook, LoadHook } from 'rollup'; -import type { ResolvedConfig, Plugin as VitePlugin } from '../core/vite'; +import type { ResolvedConfig, Plugin as VitePlugin } from 'vite'; export function getVitePluginByName(viteConfig: ResolvedConfig, pluginName: string): VitePlugin { const plugin = viteConfig.plugins.find(({ name }) => name === pluginName); diff --git a/packages/astro/src/vite-plugin-build-html/index.ts b/packages/astro/src/vite-plugin-build-html/index.ts index 87cc46779..8319970cc 100644 --- a/packages/astro/src/vite-plugin-build-html/index.ts +++ b/packages/astro/src/vite-plugin-build-html/index.ts @@ -1,6 +1,6 @@ import type { AstroConfig } from '../@types/astro'; import type { LogOptions } from '../core/logger.js'; -import type { ViteDevServer, Plugin as VitePlugin } from '../core/vite'; +import type { ViteDevServer, Plugin as VitePlugin } from 'vite'; import type { OutputChunk, PreRenderedChunk } from 'rollup'; import type { AllPagesData } from '../core/build/types'; import type { BuildInternals } from '../core/build/internal'; diff --git a/packages/astro/src/vite-plugin-config-alias/index.ts b/packages/astro/src/vite-plugin-config-alias/index.ts index c6fa6fd81..022165a03 100644 --- a/packages/astro/src/vite-plugin-config-alias/index.ts +++ b/packages/astro/src/vite-plugin-config-alias/index.ts @@ -2,7 +2,7 @@ import * as tsr from 'tsconfig-resolver'; import * as path from 'path'; import * as url from 'url'; -import type * as vite from '../core/vite'; +import type * as vite from 'vite'; /** Result of successfully parsed tsconfig.json or jsconfig.json. */ export declare interface Alias { diff --git a/packages/astro/src/vite-plugin-jsx/index.ts b/packages/astro/src/vite-plugin-jsx/index.ts index 46d92fef9..460b3f1fb 100644 --- a/packages/astro/src/vite-plugin-jsx/index.ts +++ b/packages/astro/src/vite-plugin-jsx/index.ts @@ -1,5 +1,5 @@ import type { TransformResult } from 'rollup'; -import type { Plugin, ResolvedConfig } from '../core/vite'; +import type { Plugin, ResolvedConfig } from 'vite'; import type { AstroConfig, Renderer } from '../@types/astro'; import type { LogOptions } from '../core/logger.js'; diff --git a/packages/astro/src/vite-plugin-markdown/index.ts b/packages/astro/src/vite-plugin-markdown/index.ts index 99888e8b9..77c254781 100644 --- a/packages/astro/src/vite-plugin-markdown/index.ts +++ b/packages/astro/src/vite-plugin-markdown/index.ts @@ -1,4 +1,4 @@ -import type { Plugin } from '../core/vite'; +import type { Plugin } from 'vite'; import type { AstroConfig } from '../@types/astro'; import esbuild from 'esbuild';