Skip to content

Commit

Permalink
feat!: remove deprecated critters support
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Jan 8, 2025
1 parent cca9c09 commit 09201ec
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 67 deletions.
5 changes: 0 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -90,9 +89,6 @@
"beasties": {
"optional": true
},
"critters": {
"optional": true
},
"vue-router": {
"optional": true
}
Expand All @@ -116,7 +112,6 @@
"@types/yargs": "catalog:",
"beasties": "catalog:",
"bumpp": "catalog:",
"critters": "catalog:",
"eslint": "catalog:",
"esno": "catalog:",
"fast-glob": "catalog:",
Expand Down
30 changes: 0 additions & 30 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions src/node/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -57,7 +57,7 @@ export async function build(ssgOptions: Partial<ViteSSGOptions> = {}, viteConfig
base,
}: ViteSSGOptions = mergedOptions

const beastiesOptions = mergedOptions.beastiesOptions ?? mergedOptions.crittersOptions ?? {}
const beastiesOptions = mergedOptions.beastiesOptions ?? {}

if (fs.existsSync(ssgOutTempFolder))
await fs.remove(ssgOutTempFolder)
Expand Down Expand Up @@ -137,8 +137,9 @@ export async function build(ssgOptions: Partial<ViteSSGOptions> = {}, 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`')}`)

Expand Down
20 changes: 1 addition & 19 deletions src/node/critical.ts
Original file line number Diff line number Diff line change
@@ -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<Critters | Beasties | undefined> {
export async function getBeasties(outDir: string, options: Options = {}): Promise<Beasties | undefined> {
try {
const BeastiesClass = (await import('beasties')).default

Expand All @@ -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
}
}
9 changes: 0 additions & 9 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand Down Expand Up @@ -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.
*
Expand Down

0 comments on commit 09201ec

Please sign in to comment.