From 04070c0c12c00a3e17842ce48e36edc3f2c890a3 Mon Sep 17 00:00:00 2001 From: Matthew Phillips Date: Tue, 19 Jul 2022 01:19:23 -0400 Subject: [PATCH] =?UTF-8?q?Migrate=20to=20Vite=203=20=E2=9A=A1=EF=B8=8F=20?= =?UTF-8?q?(#3570)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Vite 3 test * deps: bump to Vite beta.1 * refactor: move to use optimizeDeps.force option * refactor: stub out new updateModuleInfo params * nit: remove comment on deprecated Vite feature * nit: remove comment on deprecated vite feature * hail mary: destroy all ssr external / noexternal! * fix: use new middlewareMode config settings * fix: resolve npm package paths for rollup input * wip: revert to unresolved. Issue reported! * sad refactor: use legacy devDepsScanner for component HMR * fix: add astro/components to noExternal for Code component * refactor: use ALWAYS_NOEXTERNAL array * refactor: add package.json to all test runners for noExternal error * deps: bump to latest vite 3 beta * wip: add package.json to smoke * fix: remove accidental "force true" on create-vite * refactor: write smoke package.json programmatically * refactor: add fontsource to noExternal * fix: only add to ssr.noExternal if present in project * wip: what if we just... didn't have a memory test * deps: bump to latest vite beta * Revert "wip: what if we just... didn't have a memory test" This reverts commit 173729dbdc685e52881fc3333487b8f744add55f. * fix: add type check for plugin.name * feat: remove legacy.devDepsScanner. Vite 3 strat is now Vite 2.x strat! * fix: add ssr.noExternal to components ex * wip: ignore with-mdx starter * fix: add serviceEntryPoint to ssr.noExternal * temp: reset NODE_ENV on prod builds * fix: missing async tag * VITE 3 IS STABLE BABY * deps: bump svelte to vite 3 * deps: bump vue to vite 3 * fix: resolve plugins for proper sorting * sad fix: regex "export default" out of CSS ssr * chore: add TODO to understand sad fix * Revert "fix: resolve plugins for proper sorting" This reverts commit e67c194d3a8e11070487ed325947e7c59e8d69cd. * Revert "sad fix: regex "export default" out of CSS ssr" This reverts commit 721d40b62b61440dc9e488787901c915579659db. * fix: sort plugins WITHOUT resolveConfig * Revert "wip: ignore with-mdx starter" This reverts commit 7d4f7338e6a8427934668096dba35e2a06ab961f. * chore: revert memory test changes * chore: add nanostores/preact ot noexternal * chore: changeset * chore: changeset * deps: use Vite ^3.0.0 * fix: add back third party astro pkg scanner Co-authored-by: bholmesdev --- .changeset/thirty-beans-poke.md | 8 + examples/component/demo/astro.config.mjs | 8 +- packages/astro/package.json | 2 +- packages/astro/src/core/build/index.ts | 3 +- packages/astro/src/core/build/page-data.ts | 2 +- packages/astro/src/core/build/static-build.ts | 10 +- packages/astro/src/core/create-vite.ts | 93 ++++++----- packages/astro/src/core/util.ts | 4 +- packages/astro/src/vite-plugin-astro/hmr.ts | 2 +- packages/astro/src/vite-plugin-astro/index.ts | 2 +- .../test/fixtures/api-routes/package.json | 8 + .../test/fixtures/astro-response/package.json | 8 + .../test/fixtures/config-vite/package.json | 8 + .../fontsource-package/astro.config.mjs | 13 ++ .../astro/test/fixtures/hmr-css/package.json | 8 + .../fixtures/import-ts-with-js/package.json | 8 + .../fixtures/page-level-styles/package.json | 8 + .../test/fixtures/ssr-api-route/package.json | 8 + .../test/fixtures/ssr-assets/package.json | 8 + .../test/fixtures/ssr-dynamic/package.json | 8 + .../fixtures/ssr-hoisted-script/package.json | 8 + .../test/fixtures/ssr-request/package.json | 8 + .../test/fixtures/ssr-response/package.json | 8 + .../test/fixtures/status-code/package.json | 8 + .../test/fixtures/type-imports/package.json | 8 + .../test/fixtures/unused-slot/package.json | 8 + packages/integrations/image/src/index.ts | 2 +- packages/integrations/svelte/package.json | 4 +- packages/integrations/vue/package.json | 4 +- pnpm-lock.yaml | 148 +++++++++++++++--- 30 files changed, 339 insertions(+), 86 deletions(-) create mode 100644 .changeset/thirty-beans-poke.md create mode 100644 packages/astro/test/fixtures/api-routes/package.json create mode 100644 packages/astro/test/fixtures/astro-response/package.json create mode 100644 packages/astro/test/fixtures/config-vite/package.json create mode 100644 packages/astro/test/fixtures/fontsource-package/astro.config.mjs create mode 100644 packages/astro/test/fixtures/hmr-css/package.json create mode 100644 packages/astro/test/fixtures/import-ts-with-js/package.json create mode 100644 packages/astro/test/fixtures/page-level-styles/package.json create mode 100644 packages/astro/test/fixtures/ssr-api-route/package.json create mode 100644 packages/astro/test/fixtures/ssr-assets/package.json create mode 100644 packages/astro/test/fixtures/ssr-dynamic/package.json create mode 100644 packages/astro/test/fixtures/ssr-hoisted-script/package.json create mode 100644 packages/astro/test/fixtures/ssr-request/package.json create mode 100644 packages/astro/test/fixtures/ssr-response/package.json create mode 100644 packages/astro/test/fixtures/status-code/package.json create mode 100644 packages/astro/test/fixtures/type-imports/package.json create mode 100644 packages/astro/test/fixtures/unused-slot/package.json diff --git a/.changeset/thirty-beans-poke.md b/.changeset/thirty-beans-poke.md new file mode 100644 index 000000000..2b1ae5c98 --- /dev/null +++ b/.changeset/thirty-beans-poke.md @@ -0,0 +1,8 @@ +--- +'astro': minor +'@astrojs/image': minor +'@astrojs/svelte': minor +'@astrojs/vue': minor +--- + +Bump to Vite 3! diff --git a/examples/component/demo/astro.config.mjs b/examples/component/demo/astro.config.mjs index 882e6515a..d92b7a872 100644 --- a/examples/component/demo/astro.config.mjs +++ b/examples/component/demo/astro.config.mjs @@ -1,4 +1,10 @@ import { defineConfig } from 'astro/config'; // https://astro.build/config -export default defineConfig({}); +export default defineConfig({ + vite: { + ssr: { + noExternal: ['@example/my-component'] + }, + }, +}); diff --git a/packages/astro/package.json b/packages/astro/package.json index d64f4e406..631a12895 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -136,7 +136,7 @@ "strip-ansi": "^7.0.1", "supports-esm": "^1.0.0", "tsconfig-resolver": "^3.0.1", - "vite": "^2.9.14", + "vite": "^3.0.0", "yargs-parser": "^21.0.1", "zod": "^3.17.3" }, diff --git a/packages/astro/src/core/build/index.ts b/packages/astro/src/core/build/index.ts index 137c1e7a9..ce8f485d4 100644 --- a/packages/astro/src/core/build/index.ts +++ b/packages/astro/src/core/build/index.ts @@ -73,8 +73,9 @@ class AstroBuilder { mode: this.mode, server: { hmr: false, - middlewareMode: 'ssr', + middlewareMode: true, }, + appType: 'custom', }, { astroConfig: this.config, logging, mode: 'build' } ); diff --git a/packages/astro/src/core/build/page-data.ts b/packages/astro/src/core/build/page-data.ts index fc8be5eab..23fb0283d 100644 --- a/packages/astro/src/core/build/page-data.ts +++ b/packages/astro/src/core/build/page-data.ts @@ -57,7 +57,7 @@ export async function collectPagesData( 'build', `${colors.bold( route.component - )} is taking a bit longer to import. This is common for larger "Astro.glob(...)" or "import.meta.globEager(...)" calls, for instance. Hang tight!` + )} is taking a bit longer to import. This is common for larger "Astro.glob(...)" or "import.meta.glob(...)" calls, for instance. Hang tight!` ); clearInterval(routeCollectionLogTimeout); }, 10000); diff --git a/packages/astro/src/core/build/static-build.ts b/packages/astro/src/core/build/static-build.ts index c912b74c1..8680438f8 100644 --- a/packages/astro/src/core/build/static-build.ts +++ b/packages/astro/src/core/build/static-build.ts @@ -6,7 +6,7 @@ import { fileURLToPath } from 'url'; import * as vite from 'vite'; import { BuildInternals, createBuildInternals } from '../../core/build/internal.js'; import { prependForwardSlash } from '../../core/path.js'; -import { emptyDir, removeDir } from '../../core/util.js'; +import { emptyDir, removeDir, resolveDependency } from '../../core/util.js'; import { runHookBuildSetup } from '../../integrations/index.js'; import { rollupPluginAstroBuildCSS } from '../../vite-plugin-build-css/index.js'; import type { ViteConfigWithSSR } from '../create-vite'; @@ -67,10 +67,12 @@ export async function staticBuild(opts: StaticBuildOptions) { const ssrResult = (await ssrBuild(opts, internals, pageInput)) as RollupOutput; info(opts.logging, 'build', dim(`Completed in ${getTimeStat(timer.ssr, performance.now())}.`)); - const clientInput = new Set([ + const rendererClientEntrypoints = opts.astroConfig._ctx.renderers.map((r) => r.clientEntrypoint).filter(a => typeof a === 'string') as string[] + + const clientInput = new Set([ ...internals.discoveredHydratedComponents, ...internals.discoveredClientOnlyComponents, - ...(astroConfig._ctx.renderers.map((r) => r.clientEntrypoint).filter((a) => a) as string[]), + ...rendererClientEntrypoints, ...internals.discoveredScripts, ]); @@ -167,7 +169,7 @@ async function ssrBuild(opts: StaticBuildOptions, internals: BuildInternals, inp async function clientBuild( opts: StaticBuildOptions, internals: BuildInternals, - input: Set + input: Set, ) { const { astroConfig, viteConfig } = opts; const timer = performance.now(); diff --git a/packages/astro/src/core/create-vite.ts b/packages/astro/src/core/create-vite.ts index 07d73733f..27badc1c7 100644 --- a/packages/astro/src/core/create-vite.ts +++ b/packages/astro/src/core/create-vite.ts @@ -2,7 +2,6 @@ import type { AstroConfig } from '../@types/astro'; import type { LogOptions } from './logger/core'; import fs from 'fs'; -import { builtinModules } from 'module'; import { fileURLToPath } from 'url'; import * as vite from 'vite'; import astroPostprocessVitePlugin from '../vite-plugin-astro-postprocess/index.js'; @@ -14,28 +13,7 @@ import astroIntegrationsContainerPlugin from '../vite-plugin-integrations-contai import jsxVitePlugin from '../vite-plugin-jsx/index.js'; import markdownVitePlugin from '../vite-plugin-markdown/index.js'; import astroScriptsPlugin from '../vite-plugin-scripts/index.js'; - -// Some packages are just external, and that’s the way it goes. -const ALWAYS_EXTERNAL = new Set([ - ...builtinModules.map((name) => `node:${name}`), - '@sveltejs/vite-plugin-svelte', - 'micromark-util-events-to-acorn', - '@astrojs/markdown-remark', - // in-lined for markdown modules - 'github-slugger', - 'node-fetch', - 'prismjs', - 'shiki', - 'unified', - 'whatwg-url', -]); -const ALWAYS_NOEXTERNAL = new Set([ - // This is only because Vite's native ESM doesn't resolve "exports" correctly. - 'astro', - // Handle recommended nanostores. Only @nanostores/preact is required from our testing! - // Full explanation and related bug report: https://github.com/withastro/astro/pull/3667 - '@nanostores/preact', -]); +import { resolveDependency } from './util.js'; // note: ssr is still an experimental API hence the type omission from `vite` export type ViteConfigWithSSR = vite.InlineConfig & { ssr?: vite.SSROptions }; @@ -46,13 +24,36 @@ interface CreateViteOptions { mode: 'dev' | 'build'; } +const ALWAYS_NOEXTERNAL = new Set([ + // This is only because Vite's native ESM doesn't resolve "exports" correctly. + 'astro', + // Vite fails on nested `.astro` imports without bundling + 'astro/components', + // Handle recommended nanostores. Only @nanostores/preact is required from our testing! + // Full explanation and related bug report: https://github.com/withastro/astro/pull/3667 + '@nanostores/preact', +]); + +function getSsrNoExternalDeps(projectRoot: URL): string[] { + let noExternalDeps = [] + for (const dep of ALWAYS_NOEXTERNAL) { + try { + resolveDependency(dep, projectRoot) + noExternalDeps.push(dep) + } catch { + // ignore dependency if *not* installed / present in your project + // prevents hard error from Vite! + } + } + return noExternalDeps +} + /** Return a common starting point for all Vite actions */ export async function createVite( commandConfig: ViteConfigWithSSR, { astroConfig, logging, mode }: CreateViteOptions ): Promise { - // Scan for any third-party Astro packages. Vite needs these to be passed to `ssr.noExternal`. - const astroPackages = await getAstroPackages(astroConfig); + const thirdPartyAstroPackages = await getAstroPackages(astroConfig); // Start with the Vite configuration that Astro core needs const commonConfig: ViteConfigWithSSR = { cacheDir: fileURLToPath(new URL('./node_modules/.vite/', astroConfig.root)), // using local caches allows Astro to be used in monorepos, etc. @@ -82,7 +83,6 @@ export async function createVite( 'import.meta.env.SITE': astroConfig.site ? `'${astroConfig.site}'` : 'undefined', }, server: { - force: true, // force dependency rebuild (TODO: enabled only while next is unstable; eventually only call in "production" mode?) hmr: process.env.NODE_ENV === 'test' || process.env.NODE_ENV === 'production' ? false @@ -115,11 +115,12 @@ export async function createVite( ], conditions: ['astro'], }, - // Note: SSR API is in beta (https://vitejs.dev/guide/ssr.html) ssr: { - external: [...ALWAYS_EXTERNAL], - noExternal: [...ALWAYS_NOEXTERNAL, ...astroPackages], - }, + noExternal: [ + ...getSsrNoExternalDeps(astroConfig.root), + ...thirdPartyAstroPackages, + ], + } }; // Merge configs: we merge vite configuration objects together in the following order, @@ -131,27 +132,33 @@ export async function createVite( let result = commonConfig; result = vite.mergeConfig(result, astroConfig.vite || {}); result = vite.mergeConfig(result, commandConfig); - sortPlugins(result); + if (result.plugins) { + sortPlugins(result.plugins); + } return result; } -function getPluginName(plugin: vite.PluginOption) { - if (plugin && typeof plugin === 'object' && !Array.isArray(plugin)) { - return plugin.name; - } +function isVitePlugin(plugin: vite.PluginOption): plugin is vite.Plugin { + return Boolean(plugin?.hasOwnProperty('name')); } -function sortPlugins(result: ViteConfigWithSSR) { +function findPluginIndexByName(pluginOptions: vite.PluginOption[], name: string): number { + return pluginOptions.findIndex(function (pluginOption) { + // Use isVitePlugin to ignore nulls, booleans, promises, and arrays + // CAUTION: could be a problem if a plugin we're searching for becomes async! + return isVitePlugin(pluginOption) && pluginOption.name === name + }) +} + +function sortPlugins(pluginOptions: vite.PluginOption[]) { // HACK: move mdxPlugin to top because it needs to run before internal JSX plugin - const mdxPluginIndex = - result.plugins?.findIndex((plugin) => getPluginName(plugin) === '@mdx-js/rollup') ?? -1; + const mdxPluginIndex = findPluginIndexByName(pluginOptions, '@mdx-js/rollup'); if (mdxPluginIndex === -1) return; - const jsxPluginIndex = - result.plugins?.findIndex((plugin) => getPluginName(plugin) === 'astro:jsx') ?? -1; - const mdxPlugin = result.plugins?.[mdxPluginIndex]; - result.plugins?.splice(mdxPluginIndex, 1); - result.plugins?.splice(jsxPluginIndex, 0, mdxPlugin); + const jsxPluginIndex = findPluginIndexByName(pluginOptions, 'astro:jsx'); + const mdxPlugin = pluginOptions[mdxPluginIndex]; + pluginOptions.splice(mdxPluginIndex, 1); + pluginOptions.splice(jsxPluginIndex, 0, mdxPlugin); } // Scans `projectRoot` for third-party Astro packages that could export an `.astro` file diff --git a/packages/astro/src/core/util.ts b/packages/astro/src/core/util.ts index 2dae8ae12..0bbc0a72a 100644 --- a/packages/astro/src/core/util.ts +++ b/packages/astro/src/core/util.ts @@ -105,9 +105,9 @@ export function codeFrame(src: string, loc: ErrorPayload['err']['loc']): string return output; } -export function resolveDependency(dep: string, astroConfig: AstroConfig) { +export function resolveDependency(dep: string, projectRoot: URL) { const resolved = resolve.sync(dep, { - basedir: fileURLToPath(astroConfig.root), + basedir: fileURLToPath(projectRoot), }); // For Windows compat, we need a fully resolved `file://` URL string return pathToFileURL(resolved).toString(); diff --git a/packages/astro/src/vite-plugin-astro/hmr.ts b/packages/astro/src/vite-plugin-astro/hmr.ts index cc9b26770..3d990fe4b 100644 --- a/packages/astro/src/vite-plugin-astro/hmr.ts +++ b/packages/astro/src/vite-plugin-astro/hmr.ts @@ -41,7 +41,7 @@ export async function trackCSSDependencies( } // Update the module graph, telling it about our CSS deps. - moduleGraph.updateModuleInfo(mod, depModules, new Set(), true); + moduleGraph.updateModuleInfo(mod, depModules, new Map(), new Set(), new Set(), true); for (const dep of cssDeps) { this.addWatchFile(dep); } diff --git a/packages/astro/src/vite-plugin-astro/index.ts b/packages/astro/src/vite-plugin-astro/index.ts index 7b58a62d3..9dfbdddac 100644 --- a/packages/astro/src/vite-plugin-astro/index.ts +++ b/packages/astro/src/vite-plugin-astro/index.ts @@ -67,7 +67,7 @@ export default function astro({ config, logging }: AstroPluginOptions): vite.Plu configureServer(server) { viteDevServer = server; }, - // note: don’t claim .astro files with resolveId() — it prevents Vite from transpiling the final JS (import.meta.globEager, etc.) + // note: don’t claim .astro files with resolveId() — it prevents Vite from transpiling the final JS (import.meta.glob, etc.) async resolveId(id, from, opts) { // If resolving from an astro subresource such as a hoisted script, // we need to resolve relative paths ourselves. diff --git a/packages/astro/test/fixtures/api-routes/package.json b/packages/astro/test/fixtures/api-routes/package.json new file mode 100644 index 000000000..0f7052df4 --- /dev/null +++ b/packages/astro/test/fixtures/api-routes/package.json @@ -0,0 +1,8 @@ +{ + "name": "@test/api-routes", + "version": "0.0.0", + "private": true, + "dependencies": { + "astro": "workspace:*" + } +} diff --git a/packages/astro/test/fixtures/astro-response/package.json b/packages/astro/test/fixtures/astro-response/package.json new file mode 100644 index 000000000..a83253490 --- /dev/null +++ b/packages/astro/test/fixtures/astro-response/package.json @@ -0,0 +1,8 @@ +{ + "name": "@test/astro-response", + "version": "0.0.0", + "private": true, + "dependencies": { + "astro": "workspace:*" + } +} diff --git a/packages/astro/test/fixtures/config-vite/package.json b/packages/astro/test/fixtures/config-vite/package.json new file mode 100644 index 000000000..c226030fb --- /dev/null +++ b/packages/astro/test/fixtures/config-vite/package.json @@ -0,0 +1,8 @@ +{ + "name": "@test/config-vite", + "version": "0.0.0", + "private": true, + "dependencies": { + "astro": "workspace:*" + } +} diff --git a/packages/astro/test/fixtures/fontsource-package/astro.config.mjs b/packages/astro/test/fixtures/fontsource-package/astro.config.mjs new file mode 100644 index 000000000..03d5ecbec --- /dev/null +++ b/packages/astro/test/fixtures/fontsource-package/astro.config.mjs @@ -0,0 +1,13 @@ +import { defineConfig } from 'astro/config'; + +// https://astro.build/config +export default defineConfig({ + vite: { + ssr: { + noExternal: [ + '@fontsource/montserrat', + '@fontsource/monofett', + ] + } + } +}); diff --git a/packages/astro/test/fixtures/hmr-css/package.json b/packages/astro/test/fixtures/hmr-css/package.json new file mode 100644 index 000000000..36bf56c91 --- /dev/null +++ b/packages/astro/test/fixtures/hmr-css/package.json @@ -0,0 +1,8 @@ +{ + "name": "@test/hmr-css", + "version": "0.0.0", + "private": true, + "dependencies": { + "astro": "workspace:*" + } +} diff --git a/packages/astro/test/fixtures/import-ts-with-js/package.json b/packages/astro/test/fixtures/import-ts-with-js/package.json new file mode 100644 index 000000000..53405e943 --- /dev/null +++ b/packages/astro/test/fixtures/import-ts-with-js/package.json @@ -0,0 +1,8 @@ +{ + "name": "@test/import-ts-with-js", + "version": "0.0.0", + "private": true, + "dependencies": { + "astro": "workspace:*" + } +} diff --git a/packages/astro/test/fixtures/page-level-styles/package.json b/packages/astro/test/fixtures/page-level-styles/package.json new file mode 100644 index 000000000..a5df4918d --- /dev/null +++ b/packages/astro/test/fixtures/page-level-styles/package.json @@ -0,0 +1,8 @@ +{ + "name": "@test/page-level-styles", + "version": "0.0.0", + "private": true, + "dependencies": { + "astro": "workspace:*" + } +} diff --git a/packages/astro/test/fixtures/ssr-api-route/package.json b/packages/astro/test/fixtures/ssr-api-route/package.json new file mode 100644 index 000000000..f31c4aeee --- /dev/null +++ b/packages/astro/test/fixtures/ssr-api-route/package.json @@ -0,0 +1,8 @@ +{ + "name": "@test/ssr-api-route", + "version": "0.0.0", + "private": true, + "dependencies": { + "astro": "workspace:*" + } +} diff --git a/packages/astro/test/fixtures/ssr-assets/package.json b/packages/astro/test/fixtures/ssr-assets/package.json new file mode 100644 index 000000000..446962ec2 --- /dev/null +++ b/packages/astro/test/fixtures/ssr-assets/package.json @@ -0,0 +1,8 @@ +{ + "name": "@test/ssr-assets", + "version": "0.0.0", + "private": true, + "dependencies": { + "astro": "workspace:*" + } +} diff --git a/packages/astro/test/fixtures/ssr-dynamic/package.json b/packages/astro/test/fixtures/ssr-dynamic/package.json new file mode 100644 index 000000000..f79690814 --- /dev/null +++ b/packages/astro/test/fixtures/ssr-dynamic/package.json @@ -0,0 +1,8 @@ +{ + "name": "@test/ssr-dynamic", + "version": "0.0.0", + "private": true, + "dependencies": { + "astro": "workspace:*" + } +} diff --git a/packages/astro/test/fixtures/ssr-hoisted-script/package.json b/packages/astro/test/fixtures/ssr-hoisted-script/package.json new file mode 100644 index 000000000..d77f090b1 --- /dev/null +++ b/packages/astro/test/fixtures/ssr-hoisted-script/package.json @@ -0,0 +1,8 @@ +{ + "name": "@test/ssr-hoisted-script", + "version": "0.0.0", + "private": true, + "dependencies": { + "astro": "workspace:*" + } +} diff --git a/packages/astro/test/fixtures/ssr-request/package.json b/packages/astro/test/fixtures/ssr-request/package.json new file mode 100644 index 000000000..4b71cfa55 --- /dev/null +++ b/packages/astro/test/fixtures/ssr-request/package.json @@ -0,0 +1,8 @@ +{ + "name": "@test/ssr-request", + "version": "0.0.0", + "private": true, + "dependencies": { + "astro": "workspace:*" + } +} diff --git a/packages/astro/test/fixtures/ssr-response/package.json b/packages/astro/test/fixtures/ssr-response/package.json new file mode 100644 index 000000000..420d01c55 --- /dev/null +++ b/packages/astro/test/fixtures/ssr-response/package.json @@ -0,0 +1,8 @@ +{ + "name": "@test/ssr-response", + "version": "0.0.0", + "private": true, + "dependencies": { + "astro": "workspace:*" + } +} diff --git a/packages/astro/test/fixtures/status-code/package.json b/packages/astro/test/fixtures/status-code/package.json new file mode 100644 index 000000000..fcb9f1c94 --- /dev/null +++ b/packages/astro/test/fixtures/status-code/package.json @@ -0,0 +1,8 @@ +{ + "name": "@test/status-code", + "version": "0.0.0", + "private": true, + "dependencies": { + "astro": "workspace:*" + } +} diff --git a/packages/astro/test/fixtures/type-imports/package.json b/packages/astro/test/fixtures/type-imports/package.json new file mode 100644 index 000000000..6efd1e208 --- /dev/null +++ b/packages/astro/test/fixtures/type-imports/package.json @@ -0,0 +1,8 @@ +{ + "name": "@test/type-imports", + "version": "0.0.0", + "private": true, + "dependencies": { + "astro": "workspace:*" + } +} diff --git a/packages/astro/test/fixtures/unused-slot/package.json b/packages/astro/test/fixtures/unused-slot/package.json new file mode 100644 index 000000000..b30e1f40e --- /dev/null +++ b/packages/astro/test/fixtures/unused-slot/package.json @@ -0,0 +1,8 @@ +{ + "name": "@test/unused-slot", + "version": "0.0.0", + "private": true, + "dependencies": { + "astro": "workspace:*" + } +} diff --git a/packages/integrations/image/src/index.ts b/packages/integrations/image/src/index.ts index 7c5176133..f857bdc70 100644 --- a/packages/integrations/image/src/index.ts +++ b/packages/integrations/image/src/index.ts @@ -34,7 +34,7 @@ const createIntegration = (options: IntegrationOptions = {}): AstroIntegration = include: ['image-size', 'sharp'], }, ssr: { - noExternal: ['@astrojs/image'], + noExternal: ['@astrojs/image', resolvedOptions.serviceEntryPoint], }, }; } diff --git a/packages/integrations/svelte/package.json b/packages/integrations/svelte/package.json index 139ee7a36..c9f837cb0 100644 --- a/packages/integrations/svelte/package.json +++ b/packages/integrations/svelte/package.json @@ -33,11 +33,11 @@ "dev": "astro-scripts dev \"src/**/*.ts\"" }, "dependencies": { - "@sveltejs/vite-plugin-svelte": "^1.0.0-next.48", + "@sveltejs/vite-plugin-svelte": "^1.0.1", "postcss-load-config": "^3.1.4", "svelte-preprocess": "^4.10.7", "svelte2tsx": "^0.5.11", - "vite": "^2.9.10" + "vite": "^3.0.0" }, "devDependencies": { "astro": "workspace:*", diff --git a/packages/integrations/vue/package.json b/packages/integrations/vue/package.json index f3f28d778..0c694f683 100644 --- a/packages/integrations/vue/package.json +++ b/packages/integrations/vue/package.json @@ -33,8 +33,8 @@ "dev": "astro-scripts dev \"src/**/*.ts\"" }, "dependencies": { - "@vitejs/plugin-vue": "^2.3.3", - "vite": "^2.9.10" + "@vitejs/plugin-vue": "^3.0.0", + "vite": "^3.0.0" }, "devDependencies": { "astro": "workspace:*", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 665a03cfb..01ec6c10d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -546,7 +546,7 @@ importers: strip-ansi: ^7.0.1 supports-esm: ^1.0.0 tsconfig-resolver: ^3.0.1 - vite: ^2.9.14 + vite: ^3.0.0 yargs-parser: ^21.0.1 zod: ^3.17.3 dependencies: @@ -604,7 +604,7 @@ importers: strip-ansi: 7.0.1 supports-esm: 1.0.0 tsconfig-resolver: 3.0.1 - vite: 2.9.14_sass@1.53.0 + vite: 3.0.0_sass@1.53.0 yargs-parser: 21.0.1 zod: 3.17.3 devDependencies: @@ -1055,6 +1055,12 @@ importers: '@astrojs/svelte': link:../../../../integrations/svelte astro: link:../../.. + packages/astro/test/fixtures/api-routes: + specifiers: + astro: workspace:* + dependencies: + astro: link:../../.. + packages/astro/test/fixtures/astro pages: specifiers: astro: workspace:* @@ -1341,6 +1347,12 @@ importers: dependencies: astro: link:../../.. + packages/astro/test/fixtures/astro-response: + specifiers: + astro: workspace:* + dependencies: + astro: link:../../.. + packages/astro/test/fixtures/astro-scripts: specifiers: astro: workspace:* @@ -1401,6 +1413,12 @@ importers: dependencies: astro: link:../../.. + packages/astro/test/fixtures/config-vite: + specifiers: + astro: workspace:* + dependencies: + astro: link:../../.. + packages/astro/test/fixtures/css-assets: specifiers: '@astrojs/test-font-awesome-package': file:packages/font-awesome @@ -1505,6 +1523,18 @@ importers: '@fontsource/montserrat': 4.5.11 astro: link:../../.. + packages/astro/test/fixtures/hmr-css: + specifiers: + astro: workspace:* + dependencies: + astro: link:../../.. + + packages/astro/test/fixtures/import-ts-with-js: + specifiers: + astro: workspace:* + dependencies: + astro: link:../../.. + packages/astro/test/fixtures/integration-add-page-extension: specifiers: astro: workspace:* @@ -1574,6 +1604,12 @@ importers: '@astrojs/preact': link:../../../../integrations/preact astro: link:../../.. + packages/astro/test/fixtures/page-level-styles: + specifiers: + astro: workspace:* + dependencies: + astro: link:../../.. + packages/astro/test/fixtures/postcss: specifiers: '@astrojs/solid-js': workspace:* @@ -1703,6 +1739,24 @@ importers: '@astrojs/solid-js': link:../../../../integrations/solid astro: link:../../.. + packages/astro/test/fixtures/ssr-api-route: + specifiers: + astro: workspace:* + dependencies: + astro: link:../../.. + + packages/astro/test/fixtures/ssr-assets: + specifiers: + astro: workspace:* + dependencies: + astro: link:../../.. + + packages/astro/test/fixtures/ssr-dynamic: + specifiers: + astro: workspace:* + dependencies: + astro: link:../../.. + packages/astro/test/fixtures/ssr-env: specifiers: '@astrojs/preact': workspace:* @@ -1711,6 +1765,12 @@ importers: '@astrojs/preact': link:../../../../integrations/preact astro: link:../../.. + packages/astro/test/fixtures/ssr-hoisted-script: + specifiers: + astro: workspace:* + dependencies: + astro: link:../../.. + packages/astro/test/fixtures/ssr-markdown: specifiers: astro: workspace:* @@ -1731,6 +1791,18 @@ importers: dependencies: astro: link:../../.. + packages/astro/test/fixtures/ssr-request: + specifiers: + astro: workspace:* + dependencies: + astro: link:../../.. + + packages/astro/test/fixtures/ssr-response: + specifiers: + astro: workspace:* + dependencies: + astro: link:../../.. + packages/astro/test/fixtures/ssr-scripts: specifiers: '@astrojs/preact': 'workspace:' @@ -1794,6 +1866,12 @@ importers: packages/astro/test/fixtures/static-build/pkg: specifiers: {} + packages/astro/test/fixtures/status-code: + specifiers: + astro: workspace:* + dependencies: + astro: link:../../.. + packages/astro/test/fixtures/streaming: specifiers: astro: workspace:* @@ -1822,6 +1900,18 @@ importers: postcss: 8.4.14 tailwindcss: 3.1.5 + packages/astro/test/fixtures/type-imports: + specifiers: + astro: workspace:* + dependencies: + astro: link:../../.. + + packages/astro/test/fixtures/unused-slot: + specifiers: + astro: workspace:* + dependencies: + astro: link:../../.. + packages/astro/test/fixtures/virtual-astro-file: specifiers: astro: workspace:* @@ -2190,20 +2280,20 @@ importers: packages/integrations/svelte: specifiers: - '@sveltejs/vite-plugin-svelte': ^1.0.0-next.48 + '@sveltejs/vite-plugin-svelte': ^1.0.1 astro: workspace:* astro-scripts: workspace:* postcss-load-config: ^3.1.4 svelte: ^3.48.0 svelte-preprocess: ^4.10.7 svelte2tsx: ^0.5.11 - vite: ^2.9.10 + vite: ^3.0.0 dependencies: - '@sveltejs/vite-plugin-svelte': 1.0.0-next.49_svelte@3.49.0+vite@2.9.14 + '@sveltejs/vite-plugin-svelte': 1.0.1_svelte@3.49.0+vite@3.0.0 postcss-load-config: 3.1.4 svelte-preprocess: 4.10.7_k3vaqsyrx2lfvza3vdeafxime4 svelte2tsx: 0.5.11_svelte@3.49.0 - vite: 2.9.14 + vite: 3.0.0 devDependencies: astro: link:../../astro astro-scripts: link:../../../scripts @@ -2252,14 +2342,14 @@ importers: packages/integrations/vue: specifiers: - '@vitejs/plugin-vue': ^2.3.3 + '@vitejs/plugin-vue': ^3.0.0 astro: workspace:* astro-scripts: workspace:* - vite: ^2.9.10 + vite: ^3.0.0 vue: ^3.2.37 dependencies: - '@vitejs/plugin-vue': 2.3.3_vite@2.9.14+vue@3.2.37 - vite: 2.9.14 + '@vitejs/plugin-vue': 3.0.0_vite@3.0.0+vue@3.2.37 + vite: 3.0.0 devDependencies: astro: link:../../astro astro-scripts: link:../../../scripts @@ -7769,13 +7859,13 @@ packages: string.prototype.matchall: 4.0.7 dev: true - /@sveltejs/vite-plugin-svelte/1.0.0-next.49_svelte@3.49.0+vite@2.9.14: - resolution: {integrity: sha512-AKh0Ka8EDgidnxWUs8Hh2iZLZovkETkefO99XxZ4sW4WGJ7VFeBx5kH/NIIGlaNHLcrIvK3CK0HkZwC3Cici0A==} - engines: {node: ^14.13.1 || >= 16} + /@sveltejs/vite-plugin-svelte/1.0.1_svelte@3.49.0+vite@3.0.0: + resolution: {integrity: sha512-PorCgUounn0VXcpeJu+hOweZODKmGuLHsLomwqSj+p26IwjjGffmYQfVHtiTWq+NqaUuuHWWG7vPge6UFw4Aeg==} + engines: {node: ^14.18.0 || >= 16} peerDependencies: diff-match-patch: ^1.0.5 svelte: ^3.44.0 - vite: ^2.9.0 + vite: ^3.0.0 peerDependenciesMeta: diff-match-patch: optional: true @@ -7789,7 +7879,7 @@ packages: magic-string: 0.26.2 svelte: 3.49.0 svelte-hmr: 0.14.12_svelte@3.49.0 - vite: 2.9.14 + vite: 3.0.0 transitivePeerDependencies: - supports-color dev: false @@ -8375,17 +8465,17 @@ packages: - supports-color dev: false - /@vitejs/plugin-vue/2.3.3_vite@2.9.14+vue@3.2.37: - resolution: {integrity: sha512-SmQLDyhz+6lGJhPELsBdzXGc+AcaT8stgkbiTFGpXPe8Tl1tJaBw1A6pxDqDuRsVkD8uscrkx3hA7QDOoKYtyw==} - engines: {node: '>=12.0.0'} + /@vitejs/plugin-vue/3.0.0_vite@3.0.0+vue@3.2.37: + resolution: {integrity: sha512-yWP34ArFh/jAeNUDkkLz/kVRLjf5ppJiq4L36f64Cp6dIrMQeYZGDP9xxdemlXfZR9ylN9JgHUl3GzfqOtgYDg==} + engines: {node: '>=14.18.0'} peerDependencies: - vite: ^2.5.10 + vite: ^3.0.0 vue: ^3.2.25 peerDependenciesMeta: vite: optional: true dependencies: - vite: 2.9.14 + vite: 3.0.0 vue: 3.2.37 dev: false @@ -15396,14 +15486,15 @@ packages: - supports-color dev: true - /vite/2.9.14: - resolution: {integrity: sha512-P/UCjSpSMcE54r4mPak55hWAZPlyfS369svib/gpmz8/01L822lMPOJ/RYW6tLCe1RPvMvOsJ17erf55bKp4Hw==} - engines: {node: '>=12.2.0'} + /vite/3.0.0: + resolution: {integrity: sha512-M7phQhY3+fRZa0H+1WzI6N+/onruwPTBTMvaj7TzgZ0v2TE+N2sdLKxJOfOv9CckDWt5C4HmyQP81xB4dwRKzA==} + engines: {node: '>=14.18.0'} hasBin: true peerDependencies: less: '*' sass: '*' stylus: '*' + terser: ^5.4.0 peerDependenciesMeta: less: optional: true @@ -15411,6 +15502,8 @@ packages: optional: true stylus: optional: true + terser: + optional: true dependencies: esbuild: 0.14.48 postcss: 8.4.14 @@ -15420,14 +15513,15 @@ packages: fsevents: 2.3.2 dev: false - /vite/2.9.14_sass@1.53.0: - resolution: {integrity: sha512-P/UCjSpSMcE54r4mPak55hWAZPlyfS369svib/gpmz8/01L822lMPOJ/RYW6tLCe1RPvMvOsJ17erf55bKp4Hw==} - engines: {node: '>=12.2.0'} + /vite/3.0.0_sass@1.53.0: + resolution: {integrity: sha512-M7phQhY3+fRZa0H+1WzI6N+/onruwPTBTMvaj7TzgZ0v2TE+N2sdLKxJOfOv9CckDWt5C4HmyQP81xB4dwRKzA==} + engines: {node: '>=14.18.0'} hasBin: true peerDependencies: less: '*' sass: '*' stylus: '*' + terser: ^5.4.0 peerDependenciesMeta: less: optional: true @@ -15435,6 +15529,8 @@ packages: optional: true stylus: optional: true + terser: + optional: true dependencies: esbuild: 0.14.48 postcss: 8.4.14