1 | /**
|
---|
2 | * @license
|
---|
3 | * Copyright Google LLC All Rights Reserved.
|
---|
4 | *
|
---|
5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
6 | * found in the LICENSE file at https://angular.io/license
|
---|
7 | */
|
---|
8 | import { ScriptTarget } from 'typescript';
|
---|
9 | import type { Compiler } from 'webpack';
|
---|
10 | /**
|
---|
11 | * The options used to configure the {@link JavaScriptOptimizerPlugin}.
|
---|
12 | */
|
---|
13 | export interface JavaScriptOptimizerOptions {
|
---|
14 | /**
|
---|
15 | * Enables advanced optimizations in the underlying JavaScript optimizers.
|
---|
16 | * This currently increases the `terser` passes to 3 and enables the `pure_getters`
|
---|
17 | * option for `terser`.
|
---|
18 | */
|
---|
19 | advanced: boolean;
|
---|
20 | /**
|
---|
21 | * An object record of string keys that will be replaced with their respective values when found
|
---|
22 | * within the code during optimization.
|
---|
23 | */
|
---|
24 | define: Record<string, string | number | boolean>;
|
---|
25 | /**
|
---|
26 | * Enables the generation of a sourcemap during optimization.
|
---|
27 | * The output sourcemap will be a full sourcemap containing the merge of the input sourcemap and
|
---|
28 | * all intermediate sourcemaps.
|
---|
29 | */
|
---|
30 | sourcemap: boolean;
|
---|
31 | /**
|
---|
32 | * The ECMAScript version that should be used when generating output code.
|
---|
33 | * The optimizer will not adjust the output code with features present in newer
|
---|
34 | * ECMAScript versions.
|
---|
35 | */
|
---|
36 | target: ScriptTarget;
|
---|
37 | /**
|
---|
38 | * Enables the retention of identifier names and ensures that function and class names are
|
---|
39 | * present in the output code.
|
---|
40 | */
|
---|
41 | keepNames: boolean;
|
---|
42 | /**
|
---|
43 | * Enables the removal of all license comments from the output code.
|
---|
44 | */
|
---|
45 | removeLicenses: boolean;
|
---|
46 | }
|
---|
47 | /**
|
---|
48 | * A Webpack plugin that provides JavaScript optimization capabilities.
|
---|
49 | *
|
---|
50 | * The plugin uses both `esbuild` and `terser` to provide both fast and highly-optimized
|
---|
51 | * code output. `esbuild` is used as an initial pass to remove the majority of unused code
|
---|
52 | * as well as shorten identifiers. `terser` is then used as a secondary pass to apply
|
---|
53 | * optimizations not yet implemented by `esbuild`.
|
---|
54 | */
|
---|
55 | export declare class JavaScriptOptimizerPlugin {
|
---|
56 | options: Partial<JavaScriptOptimizerOptions>;
|
---|
57 | constructor(options?: Partial<JavaScriptOptimizerOptions>);
|
---|
58 | apply(compiler: Compiler): void;
|
---|
59 | }
|
---|