Skip to content

Commit

Permalink
feat: emit a warning when minify: true (#3182)
Browse files Browse the repository at this point in the history
### Description

closes #3173 

This is a simple feature issue that I noticed nobody was working on, so
I implemented it.
  • Loading branch information
shulaoda authored Dec 18, 2024
1 parent 2643701 commit ef5d11b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
11 changes: 10 additions & 1 deletion packages/rolldown/src/log/logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,16 @@ const INVALID_LOG_POSITION = 'INVALID_LOG_POSITION',
PLUGIN_ERROR = 'PLUGIN_ERROR',
INPUT_HOOK_IN_OUTPUT_PLUGIN = 'INPUT_HOOK_IN_OUTPUT_PLUGIN',
CYCLE_LOADING = 'CYCLE_LOADING',
MULTIPLY_NOTIFY_OPTION = 'MULTIPLY_NOTIFY_OPTION'
MULTIPLY_NOTIFY_OPTION = 'MULTIPLY_NOTIFY_OPTION',
MINIFY_WARNING = 'MINIFY_WARNING'

export function logMinifyWarning(): RollupLog {
return {
code: MINIFY_WARNING,
message:
'The built-in minifier is still under development. Setting "minify: true" is not recommended for production use.',
}
}

export function logInvalidLogPosition(pluginName: string): RollupLog {
return {
Expand Down
25 changes: 15 additions & 10 deletions packages/rolldown/src/utils/create-bundler-option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ import {
normalizePlugins,
} from './normalize-plugin-option'
import { initializeParallelPlugins } from './initialize-parallel-plugins'
import type { InputOptions } from '../options/input-options'
import type { OutputOptions } from '../options/output-options'
import { LOG_LEVEL_INFO } from '../log/logging'
import { getLogger, getOnLog } from '../log/logger'
import { getObjectPlugins } from '../plugin/plugin-driver'
import { LogHandler } from '../rollup'
import { logMinifyWarning } from '../log/logs'
import { getLogger, getOnLog } from '../log/logger'
import { LOG_LEVEL_INFO, LOG_LEVEL_WARN } from '../log/logging'
import type { InputOptions } from '../options/input-options'
import type { OutputOptions } from '../options/output-options'

export async function createBundlerOptions(
inputOptions: InputOptions,
Expand All @@ -33,19 +34,23 @@ export async function createBundlerOptions(

const outputPlugins = await normalizePluginOption(outputOptions.plugins)

// The `outputOptions` hook is called with the input plugins and the output plugins
outputOptions = pluginDriver.callOutputOptionsHook(
[...inputPlugins, ...outputPlugins],
outputOptions,
)

const logLevel = inputOptions.logLevel || LOG_LEVEL_INFO
const onLog = getLogger(
getObjectPlugins(inputPlugins),
getOnLog(inputOptions, logLevel),
logLevel,
)

// The `outputOptions` hook is called with the input plugins and the output plugins
outputOptions = pluginDriver.callOutputOptionsHook(
[...inputPlugins, ...outputPlugins],
outputOptions,
)

if (outputOptions.minify === true) {
onLog(LOG_LEVEL_WARN, logMinifyWarning())
}

let plugins = [
...normalizePlugins(inputPlugins, ANONYMOUS_PLUGIN_PREFIX),
...checkOutputPluginOption(
Expand Down

0 comments on commit ef5d11b

Please sign in to comment.