Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,10 @@
"peerDependencies": {
"rollup": ">=2.0.0"
},
"peerDependenciesMeta": {
"rollup": {
"optional": true
}
},
"packageManager": "yarn@4.12.0"
}
24 changes: 14 additions & 10 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ import { basename, dirname, join } from 'path'
import { promisify } from 'util'
import { gzip, ZlibOptions } from 'zlib'

import {
import type {
OutputAsset,
OutputChunk,
OutputOptions,
Plugin,
VERSION,
} from 'rollup'

const readFile = promisify(fs.readFile)
Expand Down Expand Up @@ -128,14 +127,19 @@ function getOutputFileContent(

// actual plugin code

function performInitChecks(options: GzipPluginOptions) {
if (VERSION < '2.0.0') {
console.error(
'[rollup-plugin-gzip] This plugin supports rollup version >= 2.0.0!',
)
console.error(
'For older rollup versions, please use an older version of this plugin.',
)
async function performInitChecks(options: GzipPluginOptions) {
try {
const { VERSION } = await import('rollup')
if (VERSION < '2.0.0') {
console.error(
'[rollup-plugin-gzip] This plugin supports rollup version >= 2.0.0!',
)
console.error(
'For older rollup versions, please use an older version of this plugin.',
)
}
} catch {
// rollup not available (e.g. using rolldown) — skip version check
}

// check for old options
Expand Down
Loading