terser-webpack-plugin

  • Version 5.3.16
  • Published
  • 93.7 kB
  • 5 dependencies
  • MIT license

Install

npm i terser-webpack-plugin
yarn add terser-webpack-plugin
pnpm add terser-webpack-plugin

Overview

Terser plugin for webpack

Index

Functions

function esbuildMinify

esbuildMinify: typeof esbuildMinify;
  • Parameter input

    input

    Parameter sourceMap

    source map

    Parameter minimizerOptions

    options

    Returns

    {Promise} minimized result

function swcMinify

swcMinify: typeof swcMinify;
  • Parameter input

    input

    Parameter sourceMap

    source map

    Parameter minimizerOptions

    options

    Returns

    {Promise} minimized result

function terserMinify

terserMinify: typeof terserMinify;
  • Parameter input

    input

    Parameter sourceMap

    source map

    Parameter minimizerOptions

    options

    Parameter extractComments

    extract comments option

    Returns

    {Promise} minimized result

function uglifyJsMinify

uglifyJsMinify: typeof uglifyJsMinify;
  • Parameter input

    input

    Parameter sourceMap

    source map

    Parameter minimizerOptions

    options

    Parameter extractComments

    extract comments option

    Returns

    {Promise} minimized result

Classes

class TerserPlugin

class TerserPlugin<T = import('terser').MinifyOptions> {}
  • [T=import("terser").MinifyOptions]

constructor

constructor(
options?: BasePluginOptions &
(
| {
minify?: MinimizerImplementation<T>;
terserOptions?: MinimizerOptions<T>;
}
| {
minify: MinimizerImplementation<T>;
terserOptions?: MinimizerOptions<T>;
}
)
);
  • Parameter options

    options

method apply

apply: (compiler: any) => void;
  • Parameter compiler

    compiler

    Returns

    {void}

Type Aliases

type Asset

type Asset = import('webpack').Asset;

    type AssetInfo

    type AssetInfo = import('webpack').AssetInfo;

      type BasePluginOptions

      type BasePluginOptions = {
      /**
      * test rule
      */
      test?: Rules | undefined;
      /**
      * include rile
      */
      include?: Rules | undefined;
      /**
      * exclude rule
      */
      exclude?: Rules | undefined;
      /**
      * extract comments options
      */
      extractComments?: ExtractCommentsOptions | undefined;
      /**
      * parallel option
      */
      parallel?: Parallel | undefined;
      };

        type BasicMinimizerImplementation

        type BasicMinimizerImplementation<T> = (
        input: Input,
        sourceMap: RawSourceMap | undefined,
        minifyOptions: MinimizerOptions<T>,
        extractComments: ExtractCommentsOptions | undefined
        ) => Promise<MinimizedResult> | MinimizedResult;

          type Compilation

          type Compilation = import('webpack').Compilation;

            type Compiler

            type Compiler = import('webpack').Compiler;

              type Configuration

              type Configuration = import('webpack').Configuration;

                type CustomOptions

                type CustomOptions = {
                [key: string]: any;
                };

                  type DefinedDefaultMinimizerAndOptions

                  type DefinedDefaultMinimizerAndOptions<T> = T extends import('terser').MinifyOptions
                  ? {
                  minify?: MinimizerImplementation<T> | undefined;
                  terserOptions?: MinimizerOptions<T> | undefined;
                  }
                  : {
                  minify: MinimizerImplementation<T>;
                  terserOptions?: MinimizerOptions<T> | undefined;
                  };

                    type ErrorObject

                    type ErrorObject = {
                    /**
                    * message
                    */
                    message: string;
                    /**
                    * line number
                    */
                    line?: number | undefined;
                    /**
                    * column number
                    */
                    column?: number | undefined;
                    /**
                    * error stack trace
                    */
                    stack?: string | undefined;
                    };

                      type ExtractCommentsBanner

                      type ExtractCommentsBanner = boolean | string | ((commentsFile: string) => string);

                        type ExtractCommentsCondition

                        type ExtractCommentsCondition =
                        | boolean
                        | 'all'
                        | 'some'
                        | RegExp
                        | ExtractCommentsFunction;

                          type ExtractCommentsFilename

                          type ExtractCommentsFilename = string | ((fileData: any) => string);

                            type ExtractCommentsFunction

                            type ExtractCommentsFunction = (
                            astNode: any,
                            comment: {
                            value: string;
                            type: 'comment1' | 'comment2' | 'comment3' | 'comment4';
                            pos: number;
                            line: number;
                            col: number;
                            }
                            ) => boolean;

                              type ExtractCommentsObject

                              type ExtractCommentsObject = {
                              /**
                              * condition which comments need to be expected
                              */
                              condition?: ExtractCommentsCondition | undefined;
                              /**
                              * filename for extracted comments
                              */
                              filename?: ExtractCommentsFilename | undefined;
                              /**
                              * banner in filename for extracted comments
                              */
                              banner?: ExtractCommentsBanner | undefined;
                              };

                                type ExtractCommentsOptions

                                type ExtractCommentsOptions = ExtractCommentsCondition | ExtractCommentsObject;

                                  type InferDefaultType

                                  type InferDefaultType<T> = T extends infer U ? U : CustomOptions;

                                    type Input

                                    type Input = {
                                    [file: string]: string;
                                    };

                                      type InternalOptions

                                      type InternalOptions<T> = {
                                      /**
                                      * name
                                      */
                                      name: string;
                                      /**
                                      * input
                                      */
                                      input: string;
                                      /**
                                      * input source map
                                      */
                                      inputSourceMap: RawSourceMap | undefined;
                                      /**
                                      * extract comments option
                                      */
                                      extractComments: ExtractCommentsOptions | undefined;
                                      /**
                                      * minimizer
                                      */
                                      minimizer: {
                                      implementation: MinimizerImplementation<T>;
                                      options: MinimizerOptions<T>;
                                      };
                                      };

                                        type InternalPluginOptions

                                        type InternalPluginOptions<T> = BasePluginOptions & {
                                        minimizer: {
                                        implementation: MinimizerImplementation<T>;
                                        options: MinimizerOptions<T>;
                                        };
                                        };

                                          type JestWorker

                                          type JestWorker = import('jest-worker').Worker;

                                            type MinimizedResult

                                            type MinimizedResult = {
                                            /**
                                            * code
                                            */
                                            code?: string | undefined;
                                            /**
                                            * source map
                                            */
                                            map?: RawSourceMap | undefined;
                                            /**
                                            * errors
                                            */
                                            errors?: Array<Error | string> | undefined;
                                            /**
                                            * warnings
                                            */
                                            warnings?: Array<Error | string> | undefined;
                                            /**
                                            * extracted comments
                                            */
                                            extractedComments?: Array<string> | undefined;
                                            };

                                              type MinimizeFunctionHelpers

                                              type MinimizeFunctionHelpers = {
                                              /**
                                              * function that returns version of minimizer
                                              */
                                              getMinimizerVersion?: (() => string | undefined) | undefined;
                                              /**
                                              * true when minimizer support worker threads, otherwise false
                                              */
                                              supportsWorkerThreads?: (() => boolean | undefined) | undefined;
                                              };

                                                type MinimizerImplementation

                                                type MinimizerImplementation<T> = BasicMinimizerImplementation<T> &
                                                MinimizeFunctionHelpers;

                                                  type MinimizerOptions

                                                  type MinimizerOptions<T> = PredefinedOptions<T> & InferDefaultType<T>;

                                                    type MinimizerWorker

                                                    type MinimizerWorker<T> = JestWorker & {
                                                    transform: (options: string) => Promise<MinimizedResult>;
                                                    minify: (options: InternalOptions<T>) => Promise<MinimizedResult>;
                                                    };

                                                      type Parallel

                                                      type Parallel = undefined | boolean | number;

                                                        type PredefinedOptions

                                                        type PredefinedOptions<T> = {
                                                        /**
                                                        * true when code is a EC module, otherwise false
                                                        */
                                                        module?:
                                                        | (T extends {
                                                        module?: infer P;
                                                        }
                                                        ? P
                                                        : boolean | string)
                                                        | undefined;
                                                        /**
                                                        * ecma version
                                                        */
                                                        ecma?:
                                                        | (T extends {
                                                        ecma?: infer P;
                                                        }
                                                        ? P
                                                        : number | string)
                                                        | undefined;
                                                        };

                                                          type RawSourceMap

                                                          type RawSourceMap = import('@jridgewell/trace-mapping').EncodedSourceMap & {
                                                          sources: string[];
                                                          sourcesContent?: string[];
                                                          file: string;
                                                          };

                                                            type Rule

                                                            type Rule = RegExp | string;

                                                              type Rules

                                                              type Rules = Rule[] | Rule;

                                                                type Schema

                                                                type Schema = import('schema-utils/declarations/validate').Schema;

                                                                  type TraceMap

                                                                  type TraceMap = import('@jridgewell/trace-mapping').TraceMap;

                                                                    Namespaces

                                                                    namespace esbuildMinify

                                                                    namespace esbuildMinify {}

                                                                      function getMinimizerVersion

                                                                      getMinimizerVersion: () => string | undefined;
                                                                      • Returns

                                                                        {string | undefined} the minimizer version

                                                                      function supportsWorkerThreads

                                                                      supportsWorkerThreads: () => boolean | undefined;
                                                                      • Returns

                                                                        {boolean | undefined} true if worker thread is supported, false otherwise

                                                                      namespace swcMinify

                                                                      namespace swcMinify {}

                                                                        function getMinimizerVersion

                                                                        getMinimizerVersion: () => string | undefined;
                                                                        • Returns

                                                                          {string | undefined} the minimizer version

                                                                        function supportsWorkerThreads

                                                                        supportsWorkerThreads: () => boolean | undefined;
                                                                        • Returns

                                                                          {boolean | undefined} true if worker thread is supported, false otherwise

                                                                        namespace terserMinify

                                                                        namespace terserMinify {}

                                                                          function getMinimizerVersion

                                                                          getMinimizerVersion: () => string | undefined;
                                                                          • Returns

                                                                            {string | undefined} the minimizer version

                                                                          function supportsWorkerThreads

                                                                          supportsWorkerThreads: () => boolean | undefined;
                                                                          • Returns

                                                                            {boolean | undefined} true if worker thread is supported, false otherwise

                                                                          namespace uglifyJsMinify

                                                                          namespace uglifyJsMinify {}

                                                                            function getMinimizerVersion

                                                                            getMinimizerVersion: () => string | undefined;
                                                                            • Returns

                                                                              {string | undefined} the minimizer version

                                                                            function supportsWorkerThreads

                                                                            supportsWorkerThreads: () => boolean | undefined;
                                                                            • Returns

                                                                              {boolean | undefined} true if worker thread is supported, false otherwise

                                                                            Package Files (2)

                                                                            Dependencies (5)

                                                                            Dev Dependencies (42)

                                                                            Peer Dependencies (1)

                                                                            Badge

                                                                            To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                            You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/terser-webpack-plugin.

                                                                            • Markdown
                                                                              [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/terser-webpack-plugin)
                                                                            • HTML
                                                                              <a href="https://www.jsdocs.io/package/terser-webpack-plugin"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>