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 | /**
|
---|
9 | * A request to optimize JavaScript using the supplied options.
|
---|
10 | */
|
---|
11 | interface OptimizeRequest {
|
---|
12 | /**
|
---|
13 | * The options to use when optimizing.
|
---|
14 | */
|
---|
15 | options: {
|
---|
16 | /**
|
---|
17 | * Controls advanced optimizations.
|
---|
18 | * Currently these are only terser related:
|
---|
19 | * * terser compress passes are set to 2
|
---|
20 | * * terser pure_getters option is enabled
|
---|
21 | */
|
---|
22 | advanced: boolean;
|
---|
23 | /**
|
---|
24 | * Specifies the string tokens that should be replaced with a defined value.
|
---|
25 | */
|
---|
26 | define?: Record<string, string>;
|
---|
27 | /**
|
---|
28 | * Controls whether class, function, and variable names should be left intact
|
---|
29 | * throughout the output code.
|
---|
30 | */
|
---|
31 | keepNames: boolean;
|
---|
32 | /**
|
---|
33 | * Controls whether license text is removed from the output code.
|
---|
34 | * Within the CLI, this option is linked to the license extraction functionality.
|
---|
35 | */
|
---|
36 | removeLicenses: boolean;
|
---|
37 | /**
|
---|
38 | * Controls whether source maps should be generated.
|
---|
39 | */
|
---|
40 | sourcemap: boolean;
|
---|
41 | /**
|
---|
42 | * Specifies the target ECMAScript version for the output code.
|
---|
43 | */
|
---|
44 | target: 5 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020;
|
---|
45 | /**
|
---|
46 | * Controls whether esbuild should only use the WASM-variant instead of trying to
|
---|
47 | * use the native variant. Some platforms may not support the native-variant and
|
---|
48 | * this option allows one support test to be conducted prior to all the workers starting.
|
---|
49 | */
|
---|
50 | alwaysUseWasm: boolean;
|
---|
51 | };
|
---|
52 | /**
|
---|
53 | * The JavaScript asset to optimize.
|
---|
54 | */
|
---|
55 | asset: {
|
---|
56 | /**
|
---|
57 | * The name of the JavaScript asset (typically the filename).
|
---|
58 | */
|
---|
59 | name: string;
|
---|
60 | /**
|
---|
61 | * The source content of the JavaScript asset.
|
---|
62 | */
|
---|
63 | code: string;
|
---|
64 | /**
|
---|
65 | * The source map of the JavaScript asset, if available.
|
---|
66 | * This map is merged with all intermediate source maps during optimization.
|
---|
67 | */
|
---|
68 | map: object;
|
---|
69 | };
|
---|
70 | }
|
---|
71 | /**
|
---|
72 | * Handles optimization requests sent from the main thread via the `JavaScriptOptimizerPlugin`.
|
---|
73 | */
|
---|
74 | export default function ({ asset, options }: OptimizeRequest): Promise<{
|
---|
75 | name: string;
|
---|
76 | code: string;
|
---|
77 | map: import("@ampproject/remapping/dist/types/source-map").default | undefined;
|
---|
78 | }>;
|
---|
79 | export {};
|
---|