From 09201ec981df94d9efb9524290514755ba8aa982 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Wed, 8 Jan 2025 14:27:24 +0800 Subject: [PATCH] feat!: remove deprecated `critters` support --- package.json | 5 ----- pnpm-lock.yaml | 30 ------------------------------ pnpm-workspace.yaml | 1 - src/node/build.ts | 7 ++++--- src/node/critical.ts | 20 +------------------- src/types.ts | 9 --------- 6 files changed, 5 insertions(+), 67 deletions(-) diff --git a/package.json b/package.json index b4b03ce..3bf8fe1 100644 --- a/package.json +++ b/package.json @@ -81,7 +81,6 @@ }, "peerDependencies": { "beasties": "^0.2.0", - "critters": "^0.0.24", "vite": "^2.0.0 || ^3.0.0 || ^4.0.0 || ^5.0.0-0 || ^6.0.0", "vue": "^3.2.10", "vue-router": "^4.0.1" @@ -90,9 +89,6 @@ "beasties": { "optional": true }, - "critters": { - "optional": true - }, "vue-router": { "optional": true } @@ -116,7 +112,6 @@ "@types/yargs": "catalog:", "beasties": "catalog:", "bumpp": "catalog:", - "critters": "catalog:", "eslint": "catalog:", "esno": "catalog:", "fast-glob": "catalog:", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6574098..af49a76 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -39,9 +39,6 @@ catalogs: bumpp: specifier: ^9.9.3 version: 9.9.3 - critters: - specifier: ^0.0.25 - version: 0.0.25 cross-env: specifier: ^7.0.3 version: 7.0.3 @@ -174,9 +171,6 @@ importers: bumpp: specifier: 'catalog:' version: 9.9.3 - critters: - specifier: 'catalog:' - version: 0.0.25 eslint: specifier: 'catalog:' version: 9.17.0(jiti@2.4.2) @@ -2127,10 +2121,6 @@ packages: core-js-compat@3.38.1: resolution: {integrity: sha512-JRH6gfXxGmrzF3tZ57lFx97YARxCXPaMzPo6jELZhv88pBH5VXpQ+y0znKGlFnzuaihqhLbefxSJxWJMPtfDzw==} - critters@0.0.25: - resolution: {integrity: sha512-ROF/tjJyyRdM8/6W0VqoN5Ql05xAGnkf5b7f3sTEl1bI5jTQQf8O918RD/V9tEb9pRY/TKcvJekDbJtniHyPtQ==} - deprecated: Ownership of Critters has moved to the Nuxt team, who will be maintaining the project going forward. If you'd like to keep using Critters, please switch to the actively-maintained fork at https://github.com/danielroe/beasties - cross-env@7.0.3: resolution: {integrity: sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==} engines: {node: '>=10.14', npm: '>=6', yarn: '>=1'} @@ -2811,9 +2801,6 @@ packages: html5parser@2.0.2: resolution: {integrity: sha512-L0y+IdTVxHsovmye8MBtFgBvWZnq1C9WnI/SmJszxoQjmUH1psX2uzDk21O5k5et6udxdGjwxkbmT9eVRoG05w==} - htmlparser2@8.0.2: - resolution: {integrity: sha512-GYdjWKDkbRLkZ5geuHs5NY1puJ+PXwP7+fHPRz06Eirsb9ugf6d8kkXav6ADhcODhFFPMIXyxkxSuMf3D6NCFA==} - htmlparser2@9.1.0: resolution: {integrity: sha512-5zfg6mHUoaer/97TxnGpxmbR7zJtPwIYFMZ/H5ucTlPZhKvtum05yiPK3Mgai3a0DyVxv7qYqoweaEd2nrYQzQ==} @@ -6569,16 +6556,6 @@ snapshots: dependencies: browserslist: 4.24.0 - critters@0.0.25: - dependencies: - chalk: 4.1.2 - css-select: 5.1.0 - dom-serializer: 2.0.0 - domhandler: 5.0.3 - htmlparser2: 8.0.2 - postcss: 8.4.49 - postcss-media-query-parser: 0.2.3 - cross-env@7.0.3: dependencies: cross-spawn: 7.0.6 @@ -7463,13 +7440,6 @@ snapshots: dependencies: tslib: 2.7.0 - htmlparser2@8.0.2: - dependencies: - domelementtype: 2.3.0 - domhandler: 5.0.3 - domutils: 3.1.0 - entities: 4.5.0 - htmlparser2@9.1.0: dependencies: domelementtype: 2.3.0 diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 7bebf16..ef2d903 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -12,7 +12,6 @@ catalog: '@vitejs/plugin-vue': ^5.2.1 beasties: ^0.2.0 bumpp: ^9.9.3 - critters: ^0.0.25 cross-env: ^7.0.3 eslint: ^9.17.0 esno: ^4.8.0 diff --git a/src/node/build.ts b/src/node/build.ts index caf06ab..dd663f0 100644 --- a/src/node/build.ts +++ b/src/node/build.ts @@ -14,7 +14,7 @@ import { blue, cyan, dim, gray, green, red, yellow } from 'kolorist' import PQueue from 'p-queue' import { mergeConfig, resolveConfig, build as viteBuild } from 'vite' import { serializeState } from '../utils/state' -import { getBeastiesOrCritters } from './critical' +import { getBeasties } from './critical' import { renderPreloadLinks } from './preload-links' import { buildLog, getSize, routesToPaths } from './utils' @@ -57,7 +57,7 @@ export async function build(ssgOptions: Partial = {}, viteConfig base, }: ViteSSGOptions = mergedOptions - const beastiesOptions = mergedOptions.beastiesOptions ?? mergedOptions.crittersOptions ?? {} + const beastiesOptions = mergedOptions.beastiesOptions ?? {} if (fs.existsSync(ssgOutTempFolder)) await fs.remove(ssgOutTempFolder) @@ -137,8 +137,9 @@ export async function build(ssgOptions: Partial = {}, viteConfig buildLog('Rendering Pages...', routesPaths.length) const beasties = beastiesOptions !== false - ? await getBeastiesOrCritters(outDir, beastiesOptions) + ? await getBeasties(outDir, beastiesOptions) : undefined + if (beasties) console.log(`${gray('[vite-ssg]')} ${blue('Critical CSS generation enabled via `beasties`')}`) diff --git a/src/node/critical.ts b/src/node/critical.ts index a41d8e8..bacd83c 100644 --- a/src/node/critical.ts +++ b/src/node/critical.ts @@ -1,8 +1,7 @@ import type Beasties from 'beasties' import type { Options } from 'beasties' -import type Critters from 'critters' -export async function getBeastiesOrCritters(outDir: string, options: Options = {}): Promise { +export async function getBeasties(outDir: string, options: Options = {}): Promise { try { const BeastiesClass = (await import('beasties')).default @@ -17,21 +16,4 @@ export async function getBeastiesOrCritters(outDir: string, options: Options = { } catch { } - - try { - const CrittersClass = (await import('critters')).default - console.warn('`critters` is deprecated. Please use `beasties` instead.') - // @ts-expect-error critters is deprecated - return new CrittersClass({ - path: outDir, - logLevel: 'warn', - external: true, - inlineFonts: true, - preloadFonts: true, - ...options, - }) - } - catch { - return undefined - } } diff --git a/src/types.ts b/src/types.ts index 9ff2cb9..c1a58a5 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,6 +1,5 @@ import type { MergeHead, VueHeadClient } from '@unhead/vue' import type { Options as BeastiesOptions } from 'beasties' -import type { Options as CrittersOptions } from 'critters' import type { App } from 'vue' import type { Router, RouteRecordRaw, RouterOptions as VueRouterOptions } from 'vue-router' @@ -69,14 +68,6 @@ export interface ViteSSGOptions { */ includeAllRoutes?: boolean - /** - * Options for the critters package. - * - * @deprecated Use `beastiesOptions` instead. - * @see https://github.com/GoogleChromeLabs/critters - */ - crittersOptions?: CrittersOptions | false - /** * Options for the beasties package. *