@rushstack/module-minifier 0.4.8 → 0.4.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,24 +1,24 @@
1
- @rushstack/module-minifier
2
-
3
- Copyright (c) Microsoft Corporation. All rights reserved.
4
-
5
- MIT License
6
-
7
- Permission is hereby granted, free of charge, to any person obtaining
8
- a copy of this software and associated documentation files (the
9
- "Software"), to deal in the Software without restriction, including
10
- without limitation the rights to use, copy, modify, merge, publish,
11
- distribute, sublicense, and/or sell copies of the Software, and to
12
- permit persons to whom the Software is furnished to do so, subject to
13
- the following conditions:
14
-
15
- The above copyright notice and this permission notice shall be
16
- included in all copies or substantial portions of the Software.
17
-
18
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ @rushstack/module-minifier
2
+
3
+ Copyright (c) Microsoft Corporation. All rights reserved.
4
+
5
+ MIT License
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining
8
+ a copy of this software and associated documentation files (the
9
+ "Software"), to deal in the Software without restriction, including
10
+ without limitation the rights to use, copy, modify, merge, publish,
11
+ distribute, sublicense, and/or sell copies of the Software, and to
12
+ permit persons to whom the Software is furnished to do so, subject to
13
+ the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be
16
+ included in all copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,12 +1,12 @@
1
- # @rushstack/module-minifier
2
-
3
- This library wraps terser in convenient handles for parallelization. It powers @rushstack/webpack4-module-minifier-plugin and @rushstack/webpack5-module-minifier-plugin but has no coupling with webpack.
4
-
5
- ## Links
6
-
7
- - [CHANGELOG.md](
8
- https://github.com/microsoft/rushstack/blob/main/libraries/module-minifier/CHANGELOG.md) - Find
9
- out what's new in the latest version
10
- - [API Reference](https://rushstack.io/pages/api/module-minifier/)
11
-
12
- `@rushstack/module-minifier` is part of the [Rush Stack](https://rushstack.io/) family of projects.
1
+ # @rushstack/module-minifier
2
+
3
+ This library wraps terser in convenient handles for parallelization. It powers @rushstack/webpack4-module-minifier-plugin and @rushstack/webpack5-module-minifier-plugin but has no coupling with webpack.
4
+
5
+ ## Links
6
+
7
+ - [CHANGELOG.md](
8
+ https://github.com/microsoft/rushstack/blob/main/libraries/module-minifier/CHANGELOG.md) - Find
9
+ out what's new in the latest version
10
+ - [API Reference](https://rushstack.io/pages/api/module-minifier/)
11
+
12
+ `@rushstack/module-minifier` is part of the [Rush Stack](https://rushstack.io/) family of projects.
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.37.2"
8
+ "packageVersion": "7.38.0"
9
9
  }
10
10
  ]
11
11
  }
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;YAC1C,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YACpC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACnB,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YACf,oEAAoE;YACpE,QAAQ,CAAC;gBACP,KAAK,EAAE,KAAc;gBACrB,IAAI,EAAE,SAAS;gBACf,GAAG,EAAE,SAAS;gBACd,IAAI;aACL,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IAEM,KAAK,CAAC,OAAO;QAClB,OAAO;YACL,UAAU,EAAE,IAAI,CAAC,WAAW;YAC5B,UAAU,EAAE,KAAK,IAAI,EAAE;gBACrB,cAAc;YAChB,CAAC;SACF,CAAC;IACJ,CAAC;CACF;AAlED,sCAkEC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { createHash } from 'crypto';\nimport serialize from 'serialize-javascript';\nimport type { MinifyOptions } from 'terser';\n\nimport type {\n IMinifierConnection,\n IModuleMinificationCallback,\n IModuleMinificationRequest,\n IModuleMinificationResult,\n IModuleMinifier\n} from './types';\nimport { minifySingleFileAsync } from './MinifySingleFile';\n\n/**\n * Options for configuring the LocalMinifier\n * @public\n */\nexport interface ILocalMinifierOptions {\n terserOptions?: MinifyOptions;\n}\n\n/**\n * Minifier implementation that minifies code on the main thread.\n * @public\n */\nexport class LocalMinifier implements IModuleMinifier {\n private readonly _terserOptions: MinifyOptions;\n\n private readonly _resultCache: Map<string, IModuleMinificationResult>;\n private readonly _configHash: string;\n\n public constructor(options: ILocalMinifierOptions) {\n const { terserOptions = {} } = options || {};\n\n this._terserOptions = {\n ...terserOptions,\n output: terserOptions.output\n ? {\n ...terserOptions.output\n }\n : {}\n };\n\n const { version: terserVersion } = require('terser/package.json');\n\n this._configHash = createHash('sha256')\n .update(LocalMinifier.name, 'utf8')\n .update(`terser@${terserVersion}`)\n .update(serialize(terserOptions))\n .digest('base64');\n\n this._resultCache = new Map();\n }\n\n /**\n * Transform that invokes Terser on the main thread\n * @param request - The request to process\n * @param callback - The callback to invoke\n */\n public minify(request: IModuleMinificationRequest, callback: IModuleMinificationCallback): void {\n const { hash } = request;\n\n const cached: IModuleMinificationResult | undefined = this._resultCache.get(hash);\n if (cached) {\n return callback(cached);\n }\n\n minifySingleFileAsync(request, this._terserOptions)\n .then((result: IModuleMinificationResult) => {\n this._resultCache.set(hash, result);\n callback(result);\n })\n .catch((error) => {\n // This branch is here to satisfy the no-floating-promises lint rule\n callback({\n error: error as Error,\n code: undefined,\n map: undefined,\n hash\n });\n });\n }\n\n public async connect(): Promise<IMinifierConnection> {\n return {\n configHash: this._configHash,\n disconnect: async () => {\n // Do nothing.\n }\n };\n }\n}\n"]}
1
+ {"version":3,"file":"LocalMinifier.js","sourceRoot":"","sources":["../src/LocalMinifier.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;AAE3D,mCAAoC;AACpC,gFAA6C;AAU7C,yDAA2D;AAU3D;;;GAGG;AACH,MAAa,aAAa;IAMxB,YAAmB,OAA8B;QAC/C,MAAM,EAAE,aAAa,GAAG,EAAE,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;QAE7C,IAAI,CAAC,cAAc,GAAG;YACpB,GAAG,aAAa;YAChB,MAAM,EAAE,aAAa,CAAC,MAAM;gBAC1B,CAAC,CAAC;oBACE,GAAG,aAAa,CAAC,MAAM;iBACxB;gBACH,CAAC,CAAC,EAAE;SACP,CAAC;QAEF,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;QAElE,IAAI,CAAC,WAAW,GAAG,IAAA,mBAAU,EAAC,QAAQ,CAAC;aACpC,MAAM,CAAC,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC;aAClC,MAAM,CAAC,UAAU,aAAa,EAAE,CAAC;aACjC,MAAM,CAAC,IAAA,8BAAS,EAAC,aAAa,CAAC,CAAC;aAChC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAEpB,IAAI,CAAC,YAAY,GAAG,IAAI,GAAG,EAAE,CAAC;IAChC,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,OAAmC,EAAE,QAAqC;QACtF,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;QAEzB,MAAM,MAAM,GAA0C,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAClF,IAAI,MAAM,EAAE;YACV,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC;SACzB;QAED,IAAA,wCAAqB,EAAC,OAAO,EAAE,IAAI,CAAC,cAAc,CAAC;aAChD,IAAI,CAAC,CAAC,MAAiC,EAAE,EAAE;YAC1C,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YACpC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACnB,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YACf,oEAAoE;YACpE,QAAQ,CAAC;gBACP,KAAK,EAAE,KAAc;gBACrB,IAAI,EAAE,SAAS;gBACf,GAAG,EAAE,SAAS;gBACd,IAAI;aACL,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IAEM,KAAK,CAAC,OAAO;QAClB,OAAO;YACL,UAAU,EAAE,IAAI,CAAC,WAAW;YAC5B,UAAU,EAAE,KAAK,IAAI,EAAE;gBACrB,cAAc;YAChB,CAAC;SACF,CAAC;IACJ,CAAC;CACF;AAlED,sCAkEC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport { createHash } from 'crypto';\r\nimport serialize from 'serialize-javascript';\r\nimport type { MinifyOptions } from 'terser';\r\n\r\nimport type {\r\n IMinifierConnection,\r\n IModuleMinificationCallback,\r\n IModuleMinificationRequest,\r\n IModuleMinificationResult,\r\n IModuleMinifier\r\n} from './types';\r\nimport { minifySingleFileAsync } from './MinifySingleFile';\r\n\r\n/**\r\n * Options for configuring the LocalMinifier\r\n * @public\r\n */\r\nexport interface ILocalMinifierOptions {\r\n terserOptions?: MinifyOptions;\r\n}\r\n\r\n/**\r\n * Minifier implementation that minifies code on the main thread.\r\n * @public\r\n */\r\nexport class LocalMinifier implements IModuleMinifier {\r\n private readonly _terserOptions: MinifyOptions;\r\n\r\n private readonly _resultCache: Map<string, IModuleMinificationResult>;\r\n private readonly _configHash: string;\r\n\r\n public constructor(options: ILocalMinifierOptions) {\r\n const { terserOptions = {} } = options || {};\r\n\r\n this._terserOptions = {\r\n ...terserOptions,\r\n output: terserOptions.output\r\n ? {\r\n ...terserOptions.output\r\n }\r\n : {}\r\n };\r\n\r\n const { version: terserVersion } = require('terser/package.json');\r\n\r\n this._configHash = createHash('sha256')\r\n .update(LocalMinifier.name, 'utf8')\r\n .update(`terser@${terserVersion}`)\r\n .update(serialize(terserOptions))\r\n .digest('base64');\r\n\r\n this._resultCache = new Map();\r\n }\r\n\r\n /**\r\n * Transform that invokes Terser on the main thread\r\n * @param request - The request to process\r\n * @param callback - The callback to invoke\r\n */\r\n public minify(request: IModuleMinificationRequest, callback: IModuleMinificationCallback): void {\r\n const { hash } = request;\r\n\r\n const cached: IModuleMinificationResult | undefined = this._resultCache.get(hash);\r\n if (cached) {\r\n return callback(cached);\r\n }\r\n\r\n minifySingleFileAsync(request, this._terserOptions)\r\n .then((result: IModuleMinificationResult) => {\r\n this._resultCache.set(hash, result);\r\n callback(result);\r\n })\r\n .catch((error) => {\r\n // This branch is here to satisfy the no-floating-promises lint rule\r\n callback({\r\n error: error as Error,\r\n code: undefined,\r\n map: undefined,\r\n hash\r\n });\r\n });\r\n }\r\n\r\n public async connect(): Promise<IMinifierConnection> {\r\n return {\r\n configHash: this._configHash,\r\n disconnect: async () => {\r\n // Do nothing.\r\n }\r\n };\r\n }\r\n}\r\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BAC/B,KAAK,MAAM,QAAQ,IAAI,mBAAmB,EAAE;oBAC1C,QAAQ,CAAC,OAAO,CAAC,CAAC;iBACnB;aACF;QACH,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QACjC,OAAO;YACL,UAAU;YACV,UAAU,EAAE,KAAK,IAAI,EAAE;gBACrB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;gBAClC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;YACpB,CAAC;SACF,CAAC;IACJ,CAAC;CACF;AAvDD,kDAuDC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { once } from 'events';\nimport type { MessagePort } from 'worker_threads';\n\nimport type {\n IMinifierConnection,\n IModuleMinificationCallback,\n IModuleMinificationRequest,\n IModuleMinificationResult,\n IModuleMinifier\n} from './types';\n\n/**\n * Minifier implementation that outsources requests to the other side of a MessagePort\n * @public\n */\nexport class MessagePortMinifier implements IModuleMinifier {\n public readonly port: MessagePort;\n\n private readonly _callbacks: Map<string, IModuleMinificationCallback[]>;\n\n public constructor(port: MessagePort) {\n this.port = port;\n this._callbacks = new Map();\n }\n\n /**\n * No-op code transform.\n * @param request - The request to process\n * @param callback - The callback to invoke\n */\n public minify(request: IModuleMinificationRequest, callback: IModuleMinificationCallback): void {\n const { hash } = request;\n\n const callbacks: IModuleMinificationCallback[] | undefined = this._callbacks.get(hash);\n if (callbacks) {\n callbacks.push(callback);\n return;\n }\n\n this._callbacks.set(hash, [callback]);\n\n this.port.postMessage(request);\n }\n\n public async connect(): Promise<IMinifierConnection> {\n const configHashPromise: Promise<string> = once(this.port, 'message') as unknown as Promise<string>;\n this.port.postMessage('initialize');\n const configHash: string = await configHashPromise;\n\n const callbacks: Map<string, IModuleMinificationCallback[]> = this._callbacks;\n\n function handler(message: IModuleMinificationResult | number | false): void {\n if (typeof message === 'object') {\n const callbacksForRequest: IModuleMinificationCallback[] = callbacks.get(message.hash)!;\n callbacks.delete(message.hash);\n for (const callback of callbacksForRequest) {\n callback(message);\n }\n }\n }\n\n this.port.on('message', handler);\n return {\n configHash,\n disconnect: async () => {\n this.port.off('message', handler);\n this.port.close();\n }\n };\n }\n}\n"]}
1
+ {"version":3,"file":"MessagePortMinifier.js","sourceRoot":"","sources":["../src/MessagePortMinifier.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,mCAA8B;AAW9B;;;GAGG;AACH,MAAa,mBAAmB;IAK9B,YAAmB,IAAiB;QAClC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,IAAI,GAAG,EAAE,CAAC;IAC9B,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,OAAmC,EAAE,QAAqC;QACtF,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;QAEzB,MAAM,SAAS,GAA8C,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACvF,IAAI,SAAS,EAAE;YACb,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACzB,OAAO;SACR;QAED,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;QAEtC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;IAEM,KAAK,CAAC,OAAO;QAClB,MAAM,iBAAiB,GAAoB,IAAA,aAAI,EAAC,IAAI,CAAC,IAAI,EAAE,SAAS,CAA+B,CAAC;QACpG,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;QACpC,MAAM,UAAU,GAAW,MAAM,iBAAiB,CAAC;QAEnD,MAAM,SAAS,GAA+C,IAAI,CAAC,UAAU,CAAC;QAE9E,SAAS,OAAO,CAAC,OAAmD;YAClE,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;gBAC/B,MAAM,mBAAmB,GAAkC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAE,CAAC;gBACxF,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;gBAC/B,KAAK,MAAM,QAAQ,IAAI,mBAAmB,EAAE;oBAC1C,QAAQ,CAAC,OAAO,CAAC,CAAC;iBACnB;aACF;QACH,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QACjC,OAAO;YACL,UAAU;YACV,UAAU,EAAE,KAAK,IAAI,EAAE;gBACrB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;gBAClC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;YACpB,CAAC;SACF,CAAC;IACJ,CAAC;CACF;AAvDD,kDAuDC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport { once } from 'events';\r\nimport type { MessagePort } from 'worker_threads';\r\n\r\nimport type {\r\n IMinifierConnection,\r\n IModuleMinificationCallback,\r\n IModuleMinificationRequest,\r\n IModuleMinificationResult,\r\n IModuleMinifier\r\n} from './types';\r\n\r\n/**\r\n * Minifier implementation that outsources requests to the other side of a MessagePort\r\n * @public\r\n */\r\nexport class MessagePortMinifier implements IModuleMinifier {\r\n public readonly port: MessagePort;\r\n\r\n private readonly _callbacks: Map<string, IModuleMinificationCallback[]>;\r\n\r\n public constructor(port: MessagePort) {\r\n this.port = port;\r\n this._callbacks = new Map();\r\n }\r\n\r\n /**\r\n * No-op code transform.\r\n * @param request - The request to process\r\n * @param callback - The callback to invoke\r\n */\r\n public minify(request: IModuleMinificationRequest, callback: IModuleMinificationCallback): void {\r\n const { hash } = request;\r\n\r\n const callbacks: IModuleMinificationCallback[] | undefined = this._callbacks.get(hash);\r\n if (callbacks) {\r\n callbacks.push(callback);\r\n return;\r\n }\r\n\r\n this._callbacks.set(hash, [callback]);\r\n\r\n this.port.postMessage(request);\r\n }\r\n\r\n public async connect(): Promise<IMinifierConnection> {\r\n const configHashPromise: Promise<string> = once(this.port, 'message') as unknown as Promise<string>;\r\n this.port.postMessage('initialize');\r\n const configHash: string = await configHashPromise;\r\n\r\n const callbacks: Map<string, IModuleMinificationCallback[]> = this._callbacks;\r\n\r\n function handler(message: IModuleMinificationResult | number | false): void {\r\n if (typeof message === 'object') {\r\n const callbacksForRequest: IModuleMinificationCallback[] = callbacks.get(message.hash)!;\r\n callbacks.delete(message.hash);\r\n for (const callback of callbacksForRequest) {\r\n callback(message);\r\n }\r\n }\r\n }\r\n\r\n this.port.on('message', handler);\r\n return {\r\n configHash,\r\n disconnect: async () => {\r\n this.port.off('message', handler);\r\n this.port.close();\r\n }\r\n };\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"MinifiedIdentifier.js","sourceRoot":"","sources":["../src/MinifiedIdentifier.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,4EAA4E;AAC5E,2CAAoF;AAEpF,4IAA4I;AAC5I,MAAM,iBAAiB,GAAa;IAClC,UAAU;IACV,WAAW;IACX,SAAS;IACT,OAAO;IACP,MAAM;IACN,MAAM;IACN,OAAO;IACP,MAAM;IACN,OAAO;IACP,OAAO;IACP,UAAU;IACV,UAAU;IACV,SAAS;IACT,QAAQ;IACR,IAAI;IACJ,QAAQ;IACR,MAAM;IACN,MAAM;IACN,QAAQ;IACR,SAAS;IACT,OAAO;IACP,OAAO;IACP,SAAS;IACT,OAAO;IACP,KAAK;IACL,UAAU;IACV,KAAK;IACL,MAAM;IACN,IAAI;IACJ,YAAY;IACZ,QAAQ;IACR,IAAI;IACJ,YAAY;IACZ,KAAK;IACL,WAAW;IACX,KAAK;IACL,MAAM;IACN,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IAAI,OAAO,IAAI,iBAAiB,CAAC,CAAC,CAAC,EAC1C,CAAC,EAAE,EACH;QACA,EAAE,OAAO,CAAC;KACX;IAED,OAAO,qBAAqB,CAAC,OAAO,CAAC,CAAC;AACxC,CAAC;AAXD,sCAWC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\n// TODO: Allow dynamic override of these values in the input to the minifier\nimport { IDENTIFIER_LEADING_DIGITS, IDENTIFIER_TRAILING_DIGITS } from './constants';\n\n// Set of ECMAScript reserved keywords (past and present): https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar\nconst RESERVED_KEYWORDS: string[] = [\n 'abstract',\n 'arguments',\n 'boolean',\n 'break',\n 'byte',\n 'case',\n 'catch',\n 'char',\n 'class',\n 'const',\n 'continue',\n 'debugger',\n 'default',\n 'delete',\n 'do',\n 'double',\n 'else',\n 'enum',\n 'export',\n 'extends',\n 'false',\n 'final',\n 'finally',\n 'float',\n 'for',\n 'function',\n 'get',\n 'goto',\n 'if',\n 'implements',\n 'import',\n 'in',\n 'instanceof',\n 'int',\n 'interface',\n 'let',\n 'long',\n 'native',\n 'new',\n 'null',\n 'package',\n 'private',\n 'protected',\n 'public',\n 'return',\n 'set',\n 'short',\n 'static',\n 'super',\n 'switch',\n 'synchronized',\n 'this',\n 'throw',\n 'throws',\n 'transient',\n 'true',\n 'try',\n 'typeof',\n 'var',\n 'void',\n 'volatile',\n 'while',\n 'with',\n 'yield'\n];\n\n/**\n * Gets a base54 string suitable for use as a JavaScript identifier, not accounting for reserved keywords\n * @param ordinal - The number to convert to a base54 identifier\n */\nexport function getIdentifierInternal(ordinal: number): string {\n let ret: string = IDENTIFIER_LEADING_DIGITS[ordinal % 54];\n\n ordinal = (ordinal / 54) | 0; // eslint-disable-line no-bitwise\n while (ordinal > 0) {\n --ordinal;\n ret += IDENTIFIER_TRAILING_DIGITS[ordinal & 0x3f]; // eslint-disable-line no-bitwise\n ordinal >>>= 6; // eslint-disable-line no-bitwise\n }\n\n return ret;\n}\n\nconst leadingCharIndex: Map<number, number> = new Map();\nfor (let i: number = 0; i < 64; i++) {\n leadingCharIndex.set(IDENTIFIER_LEADING_DIGITS.charCodeAt(i), i);\n}\n\nconst trailingCharIndex: Map<number, number> = new Map();\nfor (let i: number = 0; i < 64; i++) {\n trailingCharIndex.set(IDENTIFIER_TRAILING_DIGITS.charCodeAt(i), i);\n}\n\n/**\n * Converts an identifier into the ordinal that would produce it, not accounting for reserved keywords\n * Returns NaN if the result would exceed 31 bits\n * @param identifier - The identifier to convert to a numeric value\n */\nexport function getOrdinalFromIdentifierInternal(identifier: string): number {\n let ordinal: number = 0;\n\n for (let i: number = identifier.length - 1; i > 0; i--) {\n if (ordinal >= 0x2000000) {\n return NaN;\n }\n\n ordinal <<= 6; // eslint-disable-line no-bitwise\n ordinal += trailingCharIndex.get(identifier.charCodeAt(i))! + 1;\n }\n\n if (ordinal >= 0x2000000) {\n return NaN;\n }\n\n ordinal *= 54;\n ordinal += leadingCharIndex.get(identifier.charCodeAt(0))!;\n return ordinal;\n}\n\n/**\n * getIdentifier(n) would otherwise return each of these specified ECMAScript reserved keywords, which are not legal identifiers.\n */\nconst RESERVED_ORDINALS: number[] = ((): number[] => {\n const reserved: number[] = [];\n for (const keyword of RESERVED_KEYWORDS) {\n const ordinal: number = getOrdinalFromIdentifierInternal(keyword);\n if (!isNaN(ordinal)) {\n reserved.push(ordinal);\n }\n }\n return reserved.sort((x: number, y: number) => x - y);\n})();\n\n/**\n * Gets a base54 string suitable for use as a JavaScript identifier, omitting those that are valid ECMAScript keywords\n *\n * @param ordinal - The number to convert to a base54 identifier\n *\n * @public\n */\nexport function getIdentifier(ordinal: number): string {\n // Need to skip over reserved keywords\n for (\n let i: number = 0, len: number = RESERVED_ORDINALS.length;\n i < len && ordinal >= RESERVED_ORDINALS[i];\n i++\n ) {\n ++ordinal;\n }\n\n return getIdentifierInternal(ordinal);\n}\n"]}
1
+ {"version":3,"file":"MinifiedIdentifier.js","sourceRoot":"","sources":["../src/MinifiedIdentifier.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,4EAA4E;AAC5E,2CAAoF;AAEpF,4IAA4I;AAC5I,MAAM,iBAAiB,GAAa;IAClC,UAAU;IACV,WAAW;IACX,SAAS;IACT,OAAO;IACP,MAAM;IACN,MAAM;IACN,OAAO;IACP,MAAM;IACN,OAAO;IACP,OAAO;IACP,UAAU;IACV,UAAU;IACV,SAAS;IACT,QAAQ;IACR,IAAI;IACJ,QAAQ;IACR,MAAM;IACN,MAAM;IACN,QAAQ;IACR,SAAS;IACT,OAAO;IACP,OAAO;IACP,SAAS;IACT,OAAO;IACP,KAAK;IACL,UAAU;IACV,KAAK;IACL,MAAM;IACN,IAAI;IACJ,YAAY;IACZ,QAAQ;IACR,IAAI;IACJ,YAAY;IACZ,KAAK;IACL,WAAW;IACX,KAAK;IACL,MAAM;IACN,QAAQ;IACR,KAAK;IACL,MAAM;IACN,SAAS;IACT,SAAS;IACT,WAAW;IACX,QAAQ;IACR,QAAQ;IACR,KAAK;IACL,OAAO;IACP,QAAQ;IACR,OAAO;IACP,QAAQ;IACR,cAAc;IACd,MAAM;IACN,OAAO;IACP,QAAQ;IACR,WAAW;IACX,MAAM;IACN,KAAK;IACL,QAAQ;IACR,KAAK;IACL,MAAM;IACN,UAAU;IACV,OAAO;IACP,MAAM;IACN,OAAO;CACR,CAAC;AAEF;;;GAGG;AACH,SAAgB,qBAAqB,CAAC,OAAe;IACnD,IAAI,GAAG,GAAW,qCAAyB,CAAC,OAAO,GAAG,EAAE,CAAC,CAAC;IAE1D,OAAO,GAAG,CAAC,OAAO,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,iCAAiC;IAC/D,OAAO,OAAO,GAAG,CAAC,EAAE;QAClB,EAAE,OAAO,CAAC;QACV,GAAG,IAAI,sCAA0B,CAAC,OAAO,GAAG,IAAI,CAAC,C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EAmBC;AAED;;GAEG;AACH,MAAM,iBAAiB,GAAa,CAAC,GAAa,EAAE;IAClD,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,KAAK,MAAM,OAAO,IAAI,iBAAiB,EAAE;QACvC,MAAM,OAAO,GAAW,gCAAgC,CAAC,OAAO,CAAC,CAAC;QAClE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE;YACnB,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;SACxB;KACF;IACD,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAS,EAAE,CAAS,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AACxD,CAAC,CAAC,EAAE,CAAC;AAEL;;;;;;GAMG;AACH,SAAgB,aAAa,CAAC,OAAe;IAC3C,sCAAsC;IACtC,KACE,IAAI,CAAC,GAAW,CAAC,EAAE,GAAG,GAAW,iBAAiB,CAAC,MAAM,EACzD,CAAC,GAAG,GAAG,IAAI,OAAO,IAAI,iBAAiB,CAAC,CAAC,CAAC,EAC1C,CAAC,EAAE,EACH;QACA,EAAE,OAAO,CAAC;KACX;IAED,OAAO,qBAAqB,CAAC,OAAO,CAAC,CAAC;AACxC,CAAC;AAXD,sCAWC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\n// TODO: Allow dynamic override of these values in the input to the minifier\r\nimport { IDENTIFIER_LEADING_DIGITS, IDENTIFIER_TRAILING_DIGITS } from './constants';\r\n\r\n// Set of ECMAScript reserved keywords (past and present): https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar\r\nconst RESERVED_KEYWORDS: string[] = [\r\n 'abstract',\r\n 'arguments',\r\n 'boolean',\r\n 'break',\r\n 'byte',\r\n 'case',\r\n 'catch',\r\n 'char',\r\n 'class',\r\n 'const',\r\n 'continue',\r\n 'debugger',\r\n 'default',\r\n 'delete',\r\n 'do',\r\n 'double',\r\n 'else',\r\n 'enum',\r\n 'export',\r\n 'extends',\r\n 'false',\r\n 'final',\r\n 'finally',\r\n 'float',\r\n 'for',\r\n 'function',\r\n 'get',\r\n 'goto',\r\n 'if',\r\n 'implements',\r\n 'import',\r\n 'in',\r\n 'instanceof',\r\n 'int',\r\n 'interface',\r\n 'let',\r\n 'long',\r\n 'native',\r\n 'new',\r\n 'null',\r\n 'package',\r\n 'private',\r\n 'protected',\r\n 'public',\r\n 'return',\r\n 'set',\r\n 'short',\r\n 'static',\r\n 'super',\r\n 'switch',\r\n 'synchronized',\r\n 'this',\r\n 'throw',\r\n 'throws',\r\n 'transient',\r\n 'true',\r\n 'try',\r\n 'typeof',\r\n 'var',\r\n 'void',\r\n 'volatile',\r\n 'while',\r\n 'with',\r\n 'yield'\r\n];\r\n\r\n/**\r\n * Gets a base54 string suitable for use as a JavaScript identifier, not accounting for reserved keywords\r\n * @param ordinal - The number to convert to a base54 identifier\r\n */\r\nexport function getIdentifierInternal(ordinal: number): string {\r\n let ret: string = IDENTIFIER_LEADING_DIGITS[ordinal % 54];\r\n\r\n ordinal = (ordinal / 54) | 0; // eslint-disable-line no-bitwise\r\n while (ordinal > 0) {\r\n --ordinal;\r\n ret += IDENTIFIER_TRAILING_DIGITS[ordinal & 0x3f]; // eslint-disable-line no-bitwise\r\n ordinal >>>= 6; // eslint-disable-line no-bitwise\r\n }\r\n\r\n return ret;\r\n}\r\n\r\nconst leadingCharIndex: Map<number, number> = new Map();\r\nfor (let i: number = 0; i < 64; i++) {\r\n leadingCharIndex.set(IDENTIFIER_LEADING_DIGITS.charCodeAt(i), i);\r\n}\r\n\r\nconst trailingCharIndex: Map<number, number> = new Map();\r\nfor (let i: number = 0; i < 64; i++) {\r\n trailingCharIndex.set(IDENTIFIER_TRAILING_DIGITS.charCodeAt(i), i);\r\n}\r\n\r\n/**\r\n * Converts an identifier into the ordinal that would produce it, not accounting for reserved keywords\r\n * Returns NaN if the result would exceed 31 bits\r\n * @param identifier - The identifier to convert to a numeric value\r\n */\r\nexport function getOrdinalFromIdentifierInternal(identifier: string): number {\r\n let ordinal: number = 0;\r\n\r\n for (let i: number = identifier.length - 1; i > 0; i--) {\r\n if (ordinal >= 0x2000000) {\r\n return NaN;\r\n }\r\n\r\n ordinal <<= 6; // eslint-disable-line no-bitwise\r\n ordinal += trailingCharIndex.get(identifier.charCodeAt(i))! + 1;\r\n }\r\n\r\n if (ordinal >= 0x2000000) {\r\n return NaN;\r\n }\r\n\r\n ordinal *= 54;\r\n ordinal += leadingCharIndex.get(identifier.charCodeAt(0))!;\r\n return ordinal;\r\n}\r\n\r\n/**\r\n * getIdentifier(n) would otherwise return each of these specified ECMAScript reserved keywords, which are not legal identifiers.\r\n */\r\nconst RESERVED_ORDINALS: number[] = ((): number[] => {\r\n const reserved: number[] = [];\r\n for (const keyword of RESERVED_KEYWORDS) {\r\n const ordinal: number = getOrdinalFromIdentifierInternal(keyword);\r\n if (!isNaN(ordinal)) {\r\n reserved.push(ordinal);\r\n }\r\n }\r\n return reserved.sort((x: number, y: number) => x - y);\r\n})();\r\n\r\n/**\r\n * Gets a base54 string suitable for use as a JavaScript identifier, omitting those that are valid ECMAScript keywords\r\n *\r\n * @param ordinal - The number to convert to a base54 identifier\r\n *\r\n * @public\r\n */\r\nexport function getIdentifier(ordinal: number): string {\r\n // Need to skip over reserved keywords\r\n for (\r\n let i: number = 0, len: number = RESERVED_ORDINALS.length;\r\n i < len && ordinal >= RESERVED_ORDINALS[i];\r\n i++\r\n ) {\r\n ++ordinal;\r\n }\r\n\r\n return getIdentifierInternal(ordinal);\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"MinifierWorker.js","sourceRoot":"","sources":["../src/MinifierWorker.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;AAG3D,mDAAwD;AAExD,yDAA2D;AAG3D,MAAM,aAAa,GAAkB,2BAAU,CAAC;AAEhD,yDAAyD;AACzD,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AAErB,2BAAW,CAAC,EAAE,CAAC,SAAS,EAAE,KAAK,EAAE,OAAmC,EAAE,EAAE;IACtE,IAAI,CAAC,OAAO,EAAE;QACZ,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KACjB;IAED,MAAM,MAAM,GAA8B,MAAM,IAAA,wCAAqB,EAAC,OAAO,EAAE,aAAa,CAAC,CAAC;IAE9F,2BAAW,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;AAClC,CAAC,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { MinifyOptions } from 'terser';\nimport { parentPort, workerData } from 'worker_threads';\n\nimport { minifySingleFileAsync } from './MinifySingleFile';\nimport type { IModuleMinificationRequest, IModuleMinificationResult } from './types';\n\nconst terserOptions: MinifyOptions = workerData;\n\n// Set to non-zero to help debug unexpected graceful exit\nprocess.exitCode = 2;\n\nparentPort!.on('message', async (message: IModuleMinificationRequest) => {\n if (!message) {\n process.exit(0);\n }\n\n const result: IModuleMinificationResult = await minifySingleFileAsync(message, terserOptions);\n\n parentPort!.postMessage(result);\n});\n"]}
1
+ {"version":3,"file":"MinifierWorker.js","sourceRoot":"","sources":["../src/MinifierWorker.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;AAG3D,mDAAwD;AAExD,yDAA2D;AAG3D,MAAM,aAAa,GAAkB,2BAAU,CAAC;AAEhD,yDAAyD;AACzD,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AAErB,2BAAW,CAAC,EAAE,CAAC,SAAS,EAAE,KAAK,EAAE,OAAmC,EAAE,EAAE;IACtE,IAAI,CAAC,OAAO,EAAE;QACZ,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KACjB;IAED,MAAM,MAAM,GAA8B,MAAM,IAAA,wCAAqB,EAAC,OAAO,EAAE,aAAa,CAAC,CAAC;IAE9F,2BAAW,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;AAClC,CAAC,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport type { MinifyOptions } from 'terser';\r\nimport { parentPort, workerData } from 'worker_threads';\r\n\r\nimport { minifySingleFileAsync } from './MinifySingleFile';\r\nimport type { IModuleMinificationRequest, IModuleMinificationResult } from './types';\r\n\r\nconst terserOptions: MinifyOptions = workerData;\r\n\r\n// Set to non-zero to help debug unexpected graceful exit\r\nprocess.exitCode = 2;\r\n\r\nparentPort!.on('message', async (message: IModuleMinificationRequest) => {\r\n if (!message) {\r\n process.exit(0);\r\n }\r\n\r\n const result: IModuleMinificationResult = await minifySingleFileAsync(message, terserOptions);\r\n\r\n parentPort!.postMessage(result);\r\n});\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"MinifySingleFile.js","sourceRoot":"","sources":["../src/MinifySingleFile.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,mCAAqG;AAUrG,6DAAqD;AAGrD,MAAM,cAAc,GAA4B;IAC9C,GAAG,EAAE,kCAAa;CACnB,CAAC;AAEF;;;GAGG;AACI,KAAK,UAAU,qBAAqB,CACzC,OAAmC,EACnC,aAA4B;IAE5B,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAEtD,IAAI;QACF,MAAM,EACJ,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,cAAc,EACtB,GAAG,gBAAgB,EACpB,GAAG,aAAa,CAAC;QAElB,MAAM,MAAM,GAA4B,SAAS,IAAI,SAAS,IAAI,EAAE,CAAC;QAErE,MAAM,MAAM,GACV,cAAc,KAAK,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,cAAc,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAErG,MAAM,YAAY,GAAkB;YAClC,GAAG,gBAAgB;YACnB,MAAM;YACN,MAAM;SACP,CAAC;QACF,MAAM,CAAC,QAAQ,GAAG,KAAK,CAAC;QAExB,IAAI,MAAM,EAAE;YACV,MAAM,CAAC,cAAc,GAAG,cAAc,CAAC;SACxC;QAED,IAAI,MAAM,IAAI,SAAS,EAAE;YACvB,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;SACnF;QAED,YAAY,CAAC,SAAS,GAAG,UAAU;YACjC,CAAC,CAAC;gBACE,QAAQ,EAAE,IAAI;aACf;YACH,CAAC,CAAC,KAAK,CAAC;QAEV,MAAM,QAAQ,GAAiB,MAAM,IAAA,eAAM,EACzC;YACE,CAAC,UAAU,IAAI,MAAM,CAAC,EAAE,IAAI;SAC7B,EACD,YAAY,CACb,CAAC;QAEF,OAAO;YACL,KAAK,EAAE,SAAS;YAChB,IAAI,EAAE,QAAQ,CAAC,IAAK;YACpB,GAAG,EAAE,QAAQ,CAAC,GAA8B;YAC5C,IAAI;SACL,CAAC;KACH;IAAC,OAAO,KAAK,EAAE;QACd,sCAAsC;QACtC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACrB,OAAO;YACL,KAAK,EAAE,KAAc;YACrB,IAAI,EAAE,SAAS;YACf,GAAG,EAAE,SAAS;YACd,IAAI;SACL,CAAC;KACH;AACH,CAAC;AA/DD,sDA+DC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { minify, type MinifyOptions, type MinifyOutput, type SimpleIdentifierMangler } from 'terser';\nimport type { RawSourceMap } from 'source-map';\n\ndeclare module 'terser' {\n // eslint-disable-next-line @typescript-eslint/naming-convention\n interface SourceMapOptions {\n asObject?: boolean;\n }\n}\n\nimport { getIdentifier } from './MinifiedIdentifier';\nimport type { IModuleMinificationRequest, IModuleMinificationResult } from './types';\n\nconst nth_identifier: SimpleIdentifierMangler = {\n get: getIdentifier\n};\n\n/**\n * Minifies a single chunk of code. Factored out for reuse between WorkerPoolMinifier and LocalMinifier\n * @internal\n */\nexport async function minifySingleFileAsync(\n request: IModuleMinificationRequest,\n terserOptions: MinifyOptions\n): Promise<IModuleMinificationResult> {\n const { code, nameForMap, hash, externals } = request;\n\n try {\n const {\n format: rawFormat,\n output: rawOutput,\n mangle: originalMangle,\n ...remainingOptions\n } = terserOptions;\n\n const format: MinifyOptions['format'] = rawFormat || rawOutput || {};\n\n const mangle: MinifyOptions['mangle'] =\n originalMangle === false ? false : typeof originalMangle === 'object' ? { ...originalMangle } : {};\n\n const finalOptions: MinifyOptions = {\n ...remainingOptions,\n format,\n mangle\n };\n format.comments = false;\n\n if (mangle) {\n mangle.nth_identifier = nth_identifier;\n }\n\n if (mangle && externals) {\n mangle.reserved = mangle.reserved ? externals.concat(mangle.reserved) : externals;\n }\n\n finalOptions.sourceMap = nameForMap\n ? {\n asObject: true\n }\n : false;\n\n const minified: MinifyOutput = await minify(\n {\n [nameForMap || 'code']: code\n },\n finalOptions\n );\n\n return {\n error: undefined,\n code: minified.code!,\n map: minified.map as unknown as RawSourceMap,\n hash\n };\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error(error);\n return {\n error: error as Error,\n code: undefined,\n map: undefined,\n hash\n };\n }\n}\n"]}
1
+ {"version":3,"file":"MinifySingleFile.js","sourceRoot":"","sources":["../src/MinifySingleFile.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D,mCAAqG;AAUrG,6DAAqD;AAGrD,MAAM,cAAc,GAA4B;IAC9C,GAAG,EAAE,kCAAa;CACnB,CAAC;AAEF;;;GAGG;AACI,KAAK,UAAU,qBAAqB,CACzC,OAAm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CAAC;KACH;IAAC,OAAO,KAAK,EAAE;QACd,sCAAsC;QACtC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACrB,OAAO;YACL,KAAK,EAAE,KAAc;YACrB,IAAI,EAAE,SAAS;YACf,GAAG,EAAE,SAAS;YACd,IAAI;SACL,CAAC;KACH;AACH,CAAC;AA/DD,sDA+DC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport { minify, type MinifyOptions, type MinifyOutput, type SimpleIdentifierMangler } from 'terser';\r\nimport type { RawSourceMap } from 'source-map';\r\n\r\ndeclare module 'terser' {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n interface SourceMapOptions {\r\n asObject?: boolean;\r\n }\r\n}\r\n\r\nimport { getIdentifier } from './MinifiedIdentifier';\r\nimport type { IModuleMinificationRequest, IModuleMinificationResult } from './types';\r\n\r\nconst nth_identifier: SimpleIdentifierMangler = {\r\n get: getIdentifier\r\n};\r\n\r\n/**\r\n * Minifies a single chunk of code. Factored out for reuse between WorkerPoolMinifier and LocalMinifier\r\n * @internal\r\n */\r\nexport async function minifySingleFileAsync(\r\n request: IModuleMinificationRequest,\r\n terserOptions: MinifyOptions\r\n): Promise<IModuleMinificationResult> {\r\n const { code, nameForMap, hash, externals } = request;\r\n\r\n try {\r\n const {\r\n format: rawFormat,\r\n output: rawOutput,\r\n mangle: originalMangle,\r\n ...remainingOptions\r\n } = terserOptions;\r\n\r\n const format: MinifyOptions['format'] = rawFormat || rawOutput || {};\r\n\r\n const mangle: MinifyOptions['mangle'] =\r\n originalMangle === false ? false : typeof originalMangle === 'object' ? { ...originalMangle } : {};\r\n\r\n const finalOptions: MinifyOptions = {\r\n ...remainingOptions,\r\n format,\r\n mangle\r\n };\r\n format.comments = false;\r\n\r\n if (mangle) {\r\n mangle.nth_identifier = nth_identifier;\r\n }\r\n\r\n if (mangle && externals) {\r\n mangle.reserved = mangle.reserved ? externals.concat(mangle.reserved) : externals;\r\n }\r\n\r\n finalOptions.sourceMap = nameForMap\r\n ? {\r\n asObject: true\r\n }\r\n : false;\r\n\r\n const minified: MinifyOutput = await minify(\r\n {\r\n [nameForMap || 'code']: code\r\n },\r\n finalOptions\r\n );\r\n\r\n return {\r\n error: undefined,\r\n code: minified.code!,\r\n map: minified.map as unknown as RawSourceMap,\r\n hash\r\n };\r\n } catch (error) {\r\n // eslint-disable-next-line no-console\r\n console.error(error);\r\n return {\r\n error: error as Error,\r\n code: undefined,\r\n map: undefined,\r\n hash\r\n };\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"NoopMinifier.js","sourceRoot":"","sources":["../src/NoopMinifier.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAS3D;;;GAGG;AACH,MAAa,YAAY;IACvB;;;;OAIG;IACI,MAAM,CAAC,OAAmC,EAAE,QAAqC;QACtF,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;QAE3C,QAAQ,CAAC;YACP,IAAI;YACJ,KAAK,EAAE,SAAS;YAChB,IAAI;YACJ,4DAA4D;YAC5D,GAAG,EAAE,UAAU;gBACb,CAAC,CAAC;oBACE,OAAO,EAAE,CAAC;oBACV,KAAK,EAAE,EAAE;oBACT,IAAI,EAAE,UAAU;oBAChB,OAAO,EAAE,CAAC,UAAU,CAAC;oBACrB,cAAc,EAAE,CAAC,IAAI,CAAC;oBACtB,+GAA+G;oBAC/G,QAAQ,EAAE,MAAM;iBACjB;gBACH,CAAC,CAAC,SAAS;SACd,CAAC,CAAC;IACL,CAAC;IAEM,KAAK,CAAC,OAAO;QAClB,OAAO;YACL,UAAU,EAAE,YAAY,CAAC,IAAI;YAE7B,UAAU,EAAE,KAAK,IAAI,EAAE;gBACrB,cAAc;YAChB,CAAC;SACF,CAAC;IACJ,CAAC;CACF;AArCD,oCAqCC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type {\n IMinifierConnection,\n IModuleMinificationCallback,\n IModuleMinificationRequest,\n IModuleMinifier\n} from './types';\n\n/**\n * Minifier implementation that does not actually transform the code, for debugging.\n * @public\n */\nexport class NoopMinifier implements IModuleMinifier {\n /**\n * No-op code transform.\n * @param request - The request to process\n * @param callback - The callback to invoke\n */\n public minify(request: IModuleMinificationRequest, callback: IModuleMinificationCallback): void {\n const { code, hash, nameForMap } = request;\n\n callback({\n hash,\n error: undefined,\n code,\n // If source maps are requested, provide an empty source map\n map: nameForMap\n ? {\n version: 3,\n names: [],\n file: nameForMap,\n sources: [nameForMap],\n sourcesContent: [code],\n // In source mapping parlance, this means \"map line 0, column 0 to the input file at index 0, line 0, column 0\"\n mappings: 'AAAA'\n }\n : undefined\n });\n }\n\n public async connect(): Promise<IMinifierConnection> {\n return {\n configHash: NoopMinifier.name,\n\n disconnect: async () => {\n // Do nothing.\n }\n };\n }\n}\n"]}
1
+ {"version":3,"file":"NoopMinifier.js","sourceRoot":"","sources":["../src/NoopMinifier.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAS3D;;;GAGG;AACH,MAAa,YAAY;IACvB;;;;OAIG;IACI,MAAM,CAAC,OAAmC,EAAE,QAAqC;QACtF,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC;QAE3C,QAAQ,CAAC;YACP,IAAI;YACJ,KAAK,EAAE,SAAS;YAChB,IAAI;YACJ,4DAA4D;YAC5D,GAAG,EAAE,UAAU;gBACb,CAAC,CAAC;oBACE,OAAO,EAAE,CAAC;oBACV,KAAK,EAAE,EAAE;oBACT,IAAI,EAAE,UAAU;oBAChB,OAAO,EAAE,CAAC,UAAU,CAAC;oBACrB,cAAc,EAAE,CAAC,IAAI,CAAC;oBACtB,+GAA+G;oBAC/G,QAAQ,EAAE,MAAM;iBACjB;gBACH,CAAC,CAAC,SAAS;SACd,CAAC,CAAC;IACL,CAAC;IAEM,KAAK,CAAC,OAAO;QAClB,OAAO;YACL,UAAU,EAAE,YAAY,CAAC,IAAI;YAE7B,UAAU,EAAE,KAAK,IAAI,EAAE;gBACrB,cAAc;YAChB,CAAC;SACF,CAAC;IACJ,CAAC;CACF;AArCD,oCAqCC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport type {\r\n IMinifierConnection,\r\n IModuleMinificationCallback,\r\n IModuleMinificationRequest,\r\n IModuleMinifier\r\n} from './types';\r\n\r\n/**\r\n * Minifier implementation that does not actually transform the code, for debugging.\r\n * @public\r\n */\r\nexport class NoopMinifier implements IModuleMinifier {\r\n /**\r\n * No-op code transform.\r\n * @param request - The request to process\r\n * @param callback - The callback to invoke\r\n */\r\n public minify(request: IModuleMinificationRequest, callback: IModuleMinificationCallback): void {\r\n const { code, hash, nameForMap } = request;\r\n\r\n callback({\r\n hash,\r\n error: undefined,\r\n code,\r\n // If source maps are requested, provide an empty source map\r\n map: nameForMap\r\n ? {\r\n version: 3,\r\n names: [],\r\n file: nameForMap,\r\n sources: [nameForMap],\r\n sourcesContent: [code],\r\n // In source mapping parlance, this means \"map line 0, column 0 to the input file at index 0, line 0, column 0\"\r\n mappings: 'AAAA'\r\n }\r\n : undefined\r\n });\r\n }\r\n\r\n public async connect(): Promise<IMinifierConnection> {\r\n return {\r\n configHash: NoopMinifier.name,\r\n\r\n disconnect: async () => {\r\n // Do nothing.\r\n }\r\n };\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"WorkerPoolMinifier.js","sourceRoot":"","sources":["../src/WorkerPoolMinifier.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;AAE3D,mCAAoC;AACpC,2BAA0B;AAE1B,gFAA6C;AAE7C,wDAAoD;AAgCpD;;;GAGG;AACH,MAAa,kBAAkB;IAY7B,Y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,CAAC,QAAQ,GAAG,CAAC,CAAC;gBAClB,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC;YACrB,CAAC;SACF,CAAC;IACJ,CAAC;CACF;AAzID,gDAyIC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport { createHash } from 'crypto';\nimport { cpus } from 'os';\n\nimport serialize from 'serialize-javascript';\nimport type { MinifyOptions } from 'terser';\nimport { WorkerPool } from '@rushstack/worker-pool';\n\nimport type {\n IMinifierConnection,\n IModuleMinificationCallback,\n IModuleMinificationResult,\n IModuleMinificationRequest,\n IModuleMinifier\n} from './types';\n\n/**\n * Options for configuring the WorkerPoolMinifier\n * @public\n */\nexport interface IWorkerPoolMinifierOptions {\n /**\n * Maximum number of worker threads to use. Will never use more than there are modules to process.\n * Defaults to os.cpus().length\n */\n maxThreads?: number;\n /**\n * The options to forward to Terser.\n * `output.comments` is currently not configurable and will always extract license comments to a separate file.\n */\n terserOptions?: MinifyOptions;\n\n /**\n * If true, log to the console about the minification results.\n */\n verbose?: boolean;\n}\n\n/**\n * Minifier implementation that uses a thread pool for minification.\n * @public\n */\nexport class WorkerPoolMinifier implements IModuleMinifier {\n private readonly _pool: WorkerPool;\n private readonly _verbose: boolean;\n private readonly _configHash: string;\n\n private _refCount: number;\n private _deduped: number;\n private _minified: number;\n\n private readonly _resultCache: Map<string, IModuleMinificationResult>;\n private readonly _activeRequests: Map<string, IModuleMinificationCallback[]>;\n\n public constructor(options: IWorkerPoolMinifierOptions) {\n const { maxThreads = cpus().length, terserOptions = {}, verbose = false } = options || {};\n\n const activeRequests: Map<string, IModuleMinificationCallback[]> = new Map();\n const resultCache: Map<string, IModuleMinificationResult> = new Map();\n const terserPool: WorkerPool = new WorkerPool({\n id: 'Minifier',\n maxWorkers: maxThreads,\n workerData: terserOptions,\n workerScriptPath: require.resolve('./MinifierWorker')\n });\n\n const { version: terserVersion } = require('terser/package.json');\n\n this._configHash = createHash('sha256')\n .update(WorkerPoolMinifier.name, 'utf8')\n .update(`terser@${terserVersion}`)\n .update(serialize(terserOptions))\n .digest('base64');\n\n this._activeRequests = activeRequests;\n this._refCount = 0;\n this._resultCache = resultCache;\n this._pool = terserPool;\n this._verbose = verbose;\n\n this._deduped = 0;\n this._minified = 0;\n }\n\n public get maxThreads(): number {\n return this._pool.maxWorkers;\n }\n\n public set maxThreads(threads: number) {\n this._pool.maxWorkers = threads;\n }\n\n /**\n * Transform code by farming it out to a worker pool.\n * @param request - The request to process\n * @param callback - The callback to invoke\n */\n public minify(request: IModuleMinificationRequest, callback: IModuleMinificationCallback): void {\n const { hash } = request;\n\n const cached: IModuleMinificationResult | undefined = this._resultCache.get(hash);\n if (cached) {\n ++this._deduped;\n return callback(cached);\n }\n\n const { _activeRequests: activeRequests } = this;\n const callbacks: IModuleMinificationCallback[] | undefined = activeRequests.get(hash);\n if (callbacks) {\n ++this._deduped;\n callbacks.push(callback);\n return;\n }\n\n activeRequests.set(hash, [callback]);\n ++this._minified;\n\n this._pool\n .checkoutWorkerAsync(true)\n .then((worker) => {\n const cb: (message: IModuleMinificationResult) => void = (\n message: IModuleMinificationResult\n ): void => {\n worker.off('message', cb);\n const workerCallbacks: IModuleMinificationCallback[] | undefined = activeRequests.get(\n message.hash\n )!;\n activeRequests.delete(message.hash);\n this._resultCache.set(message.hash, message);\n for (const workerCallback of workerCallbacks) {\n workerCallback(message);\n }\n // This should always be the last thing done with the worker\n this._pool.checkinWorker(worker);\n };\n\n worker.on('message', cb);\n worker.postMessage(request);\n })\n .catch((error: Error) => {\n const errorCallbacks: IModuleMinificationCallback[] = activeRequests.get(hash)!;\n for (const errorCallback of errorCallbacks) {\n errorCallback({\n hash,\n error,\n code: undefined,\n map: undefined\n });\n }\n });\n }\n\n public async connect(): Promise<IMinifierConnection> {\n if (++this._refCount === 1) {\n this._pool.reset();\n }\n\n return {\n configHash: this._configHash,\n\n disconnect: async () => {\n if (--this._refCount === 0) {\n if (this._verbose) {\n // eslint-disable-next-line no-console\n console.log(`Shutting down minifier worker pool`);\n }\n await this._pool.finishAsync();\n this._resultCache.clear();\n this._activeRequests.clear();\n if (this._verbose) {\n // eslint-disable-next-line no-console\n console.log(`Module minification: ${this._deduped} Deduped, ${this._minified} Processed`);\n }\n }\n this._deduped = 0;\n this._minified = 0;\n }\n };\n }\n}\n"]}
1
+ {"version":3,"file":"WorkerPoolMinifier.js","sourceRoot":"","sources":["../src/WorkerPoolMinifier.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;;;;AAE3D,mCAAoC;AACpC,2BAA0B;AAE1B,gFAA6C;AAE7C,wDAAoD;AAgCpD;;;GAGG;AACH,MAAa,kBAAkB;IAY7B,YAAmB,OAAmC;QACpD,MAAM,EAAE,UAAU,GAAG,IAAA,SAAI,GAAE,CAAC,MAAM,EAAE,aAAa,GAAG,EAAE,EAAE,OAAO,GAAG,KAAK,EAAE,GAAG,OAAO,IAAI,EAAE,CAAC;QAE1F,MAAM,cAAc,GAA+C,IAAI,GAAG,EAAE,CAAC;QAC7E,MAAM,WAAW,GAA2C,IAAI,GAAG,EAAE,CAAC;QACtE,MAAM,UAAU,GAAe,IAAI,wBAAU,CAAC;YAC5C,EAAE,EAAE,UAAU;YACd,UAAU,EAAE,UAAU;YACtB,UAAU,EAAE,aAAa;YACzB,gBAAgB,EAAE,OAAO,CAAC,OAAO,CAAC,kBAAkB,CAAC;SACtD,CAAC,CAAC;QAEH,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;QAElE,IAAI,CAAC,WAAW,GAAG,IAAA,mBAAU,EAAC,QAAQ,CAAC;aACpC,MAAM,CAAC,kBAAkB,CAAC,IAAI,EAAE,MAAM,CAAC;aACvC,MAAM,CAAC,UAAU,aAAa,EAAE,CAAC;aACjC,MAAM,CAAC,IAAA,8BAAS,EAAC,aAAa,CAAC,CAAC;aAChC,MAAM,CAAC,QAAQ,C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EAAE;oBAC1B,IAAI,IAAI,CAAC,QAAQ,EAAE;wBACjB,sCAAsC;wBACtC,OAAO,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC;qBACnD;oBACD,MAAM,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;oBAC/B,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;oBAC1B,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;oBAC7B,IAAI,IAAI,CAAC,QAAQ,EAAE;wBACjB,sCAAsC;wBACtC,OAAO,CAAC,GAAG,CAAC,wBAAwB,IAAI,CAAC,QAAQ,aAAa,IAAI,CAAC,SAAS,YAAY,CAAC,CAAC;qBAC3F;iBACF;gBACD,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;gBAClB,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC;YACrB,CAAC;SACF,CAAC;IACJ,CAAC;CACF;AAzID,gDAyIC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport { createHash } from 'crypto';\r\nimport { cpus } from 'os';\r\n\r\nimport serialize from 'serialize-javascript';\r\nimport type { MinifyOptions } from 'terser';\r\nimport { WorkerPool } from '@rushstack/worker-pool';\r\n\r\nimport type {\r\n IMinifierConnection,\r\n IModuleMinificationCallback,\r\n IModuleMinificationResult,\r\n IModuleMinificationRequest,\r\n IModuleMinifier\r\n} from './types';\r\n\r\n/**\r\n * Options for configuring the WorkerPoolMinifier\r\n * @public\r\n */\r\nexport interface IWorkerPoolMinifierOptions {\r\n /**\r\n * Maximum number of worker threads to use. Will never use more than there are modules to process.\r\n * Defaults to os.cpus().length\r\n */\r\n maxThreads?: number;\r\n /**\r\n * The options to forward to Terser.\r\n * `output.comments` is currently not configurable and will always extract license comments to a separate file.\r\n */\r\n terserOptions?: MinifyOptions;\r\n\r\n /**\r\n * If true, log to the console about the minification results.\r\n */\r\n verbose?: boolean;\r\n}\r\n\r\n/**\r\n * Minifier implementation that uses a thread pool for minification.\r\n * @public\r\n */\r\nexport class WorkerPoolMinifier implements IModuleMinifier {\r\n private readonly _pool: WorkerPool;\r\n private readonly _verbose: boolean;\r\n private readonly _configHash: string;\r\n\r\n private _refCount: number;\r\n private _deduped: number;\r\n private _minified: number;\r\n\r\n private readonly _resultCache: Map<string, IModuleMinificationResult>;\r\n private readonly _activeRequests: Map<string, IModuleMinificationCallback[]>;\r\n\r\n public constructor(options: IWorkerPoolMinifierOptions) {\r\n const { maxThreads = cpus().length, terserOptions = {}, verbose = false } = options || {};\r\n\r\n const activeRequests: Map<string, IModuleMinificationCallback[]> = new Map();\r\n const resultCache: Map<string, IModuleMinificationResult> = new Map();\r\n const terserPool: WorkerPool = new WorkerPool({\r\n id: 'Minifier',\r\n maxWorkers: maxThreads,\r\n workerData: terserOptions,\r\n workerScriptPath: require.resolve('./MinifierWorker')\r\n });\r\n\r\n const { version: terserVersion } = require('terser/package.json');\r\n\r\n this._configHash = createHash('sha256')\r\n .update(WorkerPoolMinifier.name, 'utf8')\r\n .update(`terser@${terserVersion}`)\r\n .update(serialize(terserOptions))\r\n .digest('base64');\r\n\r\n this._activeRequests = activeRequests;\r\n this._refCount = 0;\r\n this._resultCache = resultCache;\r\n this._pool = terserPool;\r\n this._verbose = verbose;\r\n\r\n this._deduped = 0;\r\n this._minified = 0;\r\n }\r\n\r\n public get maxThreads(): number {\r\n return this._pool.maxWorkers;\r\n }\r\n\r\n public set maxThreads(threads: number) {\r\n this._pool.maxWorkers = threads;\r\n }\r\n\r\n /**\r\n * Transform code by farming it out to a worker pool.\r\n * @param request - The request to process\r\n * @param callback - The callback to invoke\r\n */\r\n public minify(request: IModuleMinificationRequest, callback: IModuleMinificationCallback): void {\r\n const { hash } = request;\r\n\r\n const cached: IModuleMinificationResult | undefined = this._resultCache.get(hash);\r\n if (cached) {\r\n ++this._deduped;\r\n return callback(cached);\r\n }\r\n\r\n const { _activeRequests: activeRequests } = this;\r\n const callbacks: IModuleMinificationCallback[] | undefined = activeRequests.get(hash);\r\n if (callbacks) {\r\n ++this._deduped;\r\n callbacks.push(callback);\r\n return;\r\n }\r\n\r\n activeRequests.set(hash, [callback]);\r\n ++this._minified;\r\n\r\n this._pool\r\n .checkoutWorkerAsync(true)\r\n .then((worker) => {\r\n const cb: (message: IModuleMinificationResult) => void = (\r\n message: IModuleMinificationResult\r\n ): void => {\r\n worker.off('message', cb);\r\n const workerCallbacks: IModuleMinificationCallback[] | undefined = activeRequests.get(\r\n message.hash\r\n )!;\r\n activeRequests.delete(message.hash);\r\n this._resultCache.set(message.hash, message);\r\n for (const workerCallback of workerCallbacks) {\r\n workerCallback(message);\r\n }\r\n // This should always be the last thing done with the worker\r\n this._pool.checkinWorker(worker);\r\n };\r\n\r\n worker.on('message', cb);\r\n worker.postMessage(request);\r\n })\r\n .catch((error: Error) => {\r\n const errorCallbacks: IModuleMinificationCallback[] = activeRequests.get(hash)!;\r\n for (const errorCallback of errorCallbacks) {\r\n errorCallback({\r\n hash,\r\n error,\r\n code: undefined,\r\n map: undefined\r\n });\r\n }\r\n });\r\n }\r\n\r\n public async connect(): Promise<IMinifierConnection> {\r\n if (++this._refCount === 1) {\r\n this._pool.reset();\r\n }\r\n\r\n return {\r\n configHash: this._configHash,\r\n\r\n disconnect: async () => {\r\n if (--this._refCount === 0) {\r\n if (this._verbose) {\r\n // eslint-disable-next-line no-console\r\n console.log(`Shutting down minifier worker pool`);\r\n }\r\n await this._pool.finishAsync();\r\n this._resultCache.clear();\r\n this._activeRequests.clear();\r\n if (this._verbose) {\r\n // eslint-disable-next-line no-console\r\n console.log(`Module minification: ${this._deduped} Deduped, ${this._minified} Processed`);\r\n }\r\n }\r\n this._deduped = 0;\r\n this._minified = 0;\r\n }\r\n };\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D;;;;GAIG;AACU,QAAA,yBAAyB,GAAW,wDAAwD,CAAC;AAE1G;;;;GAIG;AACU,QAAA,0BAA0B,GACrC,kEAAkE,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\n/**\n * The sorted sequence of leading digits for mangled identifiers\n * Used in MinifiedIdentifier computation for converting an ordinal to a valid ECMAScript identifier\n * @public\n */\nexport const IDENTIFIER_LEADING_DIGITS: string = 'etnairoscdlufpm_hbgvySDIxCOwEALkMPTUFHRNBjVzGKWqQYJXZ$';\n\n/**\n * The sorted sequence of trailing digits for mangled identifiers\n * Used in MinifiedIdentifier computation for converting an ordinal to a valid ECMAScript identifier\n * @public\n */\nexport const IDENTIFIER_TRAILING_DIGITS: string =\n 'etnairoscdlufpm_hbg01v32y67S4985DIxCOwEALkMPTUFHRNBjVzGKWqQYJXZ$';\n"]}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAE3D;;;;GAIG;AACU,QAAA,yBAAyB,GAAW,wDAAwD,CAAC;AAE1G;;;;GAIG;AACU,QAAA,0BAA0B,GACrC,kEAAkE,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\n/**\r\n * The sorted sequence of leading digits for mangled identifiers\r\n * Used in MinifiedIdentifier computation for converting an ordinal to a valid ECMAScript identifier\r\n * @public\r\n */\r\nexport const IDENTIFIER_LEADING_DIGITS: string = 'etnairoscdlufpm_hbgvySDIxCOwEALkMPTUFHRNBjVzGKWqQYJXZ$';\r\n\r\n/**\r\n * The sorted sequence of trailing digits for mangled identifiers\r\n * Used in MinifiedIdentifier computation for converting an ordinal to a valid ECMAScript identifier\r\n * @public\r\n */\r\nexport const IDENTIFIER_TRAILING_DIGITS: string =\r\n 'etnairoscdlufpm_hbg01v32y67S4985DIxCOwEALkMPTUFHRNBjVzGKWqQYJXZ$';\r\n"]}
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAa3D,iDAAgD;AAAvC,8GAAA,aAAa,OAAA;AAEtB,6DAA4D;AAAnD,0HAAA,mBAAmB,OAAA;AAE5B,2DAAqD;AAA5C,mHAAA,aAAa,OAAA;AAEtB,uDAAqF;AAA5E,0HAAA,qBAAqB,OAA0B;AAExD,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AAcrB,2DAA0D;AAAjD,wHAAA,kBAAkB,OAAA","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\n/**\n * This library wraps terser in convenient handles for parallelization.\n * It powers `@rushstack/webpack4-module-minifier-plugin` and `@rushstack/webpack5-module-minifier-plugin`\n * but has no coupling with webpack.\n *\n * @packageDocumentation\n */\n\nexport type { MinifyOptions } from 'terser';\n\nexport type { ILocalMinifierOptions } from './LocalMinifier';\nexport { LocalMinifier } from './LocalMinifier';\n\nexport { MessagePortMinifier } from './MessagePortMinifier';\n\nexport { getIdentifier } from './MinifiedIdentifier';\n\nexport { minifySingleFileAsync as _minifySingleFileAsync } from './MinifySingleFile';\n\nexport { NoopMinifier } from './NoopMinifier';\n\nexport type {\n IMinifierConnection,\n IModuleMinificationCallback,\n IModuleMinificationErrorResult,\n IModuleMinificationRequest,\n IModuleMinificationResult,\n IModuleMinificationSuccessResult,\n IModuleMinifier,\n IModuleMinifierFunction\n} from './types';\n\nexport type { IWorkerPoolMinifierOptions } from './WorkerPoolMinifier';\nexport { WorkerPoolMinifier } from './WorkerPoolMinifier';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAa3D,iDAAgD;AAAvC,8GAAA,aAAa,OAAA;AAEtB,6DAA4D;AAAnD,0HAAA,mBAAmB,OAAA;AAE5B,2DAAqD;AAA5C,mHAAA,aAAa,OAAA;AAEtB,uDAAqF;AAA5E,0HAAA,qBAAqB,OAA0B;AAExD,+CAA8C;AAArC,4GAAA,YAAY,OAAA;AAcrB,2DAA0D;AAAjD,wHAAA,kBAAkB,OAAA","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\n/**\r\n * This library wraps terser in convenient handles for parallelization.\r\n * It powers `@rushstack/webpack4-module-minifier-plugin` and `@rushstack/webpack5-module-minifier-plugin`\r\n * but has no coupling with webpack.\r\n *\r\n * @packageDocumentation\r\n */\r\n\r\nexport type { MinifyOptions } from 'terser';\r\n\r\nexport type { ILocalMinifierOptions } from './LocalMinifier';\r\nexport { LocalMinifier } from './LocalMinifier';\r\n\r\nexport { MessagePortMinifier } from './MessagePortMinifier';\r\n\r\nexport { getIdentifier } from './MinifiedIdentifier';\r\n\r\nexport { minifySingleFileAsync as _minifySingleFileAsync } from './MinifySingleFile';\r\n\r\nexport { NoopMinifier } from './NoopMinifier';\r\n\r\nexport type {\r\n IMinifierConnection,\r\n IModuleMinificationCallback,\r\n IModuleMinificationErrorResult,\r\n IModuleMinificationRequest,\r\n IModuleMinificationResult,\r\n IModuleMinificationSuccessResult,\r\n IModuleMinifier,\r\n IModuleMinifierFunction\r\n} from './types';\r\n\r\nexport type { IWorkerPoolMinifierOptions } from './WorkerPoolMinifier';\r\nexport { WorkerPoolMinifier } from './WorkerPoolMinifier';\r\n"]}
package/lib/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { RawSourceMap } from 'source-map';\n\n/**\n * Request to the minifier\n * @public\n */\nexport interface IModuleMinificationRequest {\n /**\n * Identity of the request. Will be included in the response.\n */\n hash: string;\n /**\n * The raw code fragment\n */\n code: string;\n /**\n * File name to show for the source code in the source map\n */\n nameForMap: string | undefined;\n /**\n * Reserved variable names, e.g. __WEBPACK_EXTERNAL_MODULE_1__\n */\n externals: string[] | undefined;\n}\n\n/**\n * Result from the minifier function when an error is encountered.\n * @public\n */\nexport interface IModuleMinificationErrorResult {\n /**\n * Identity of the request\n */\n hash: string;\n /**\n * The error encountered, to be added to the current compilation's error collection.\n */\n error: Error;\n /**\n * Marker property to always return the same result shape.\n */\n code?: undefined;\n /**\n * Marker property to always return the same result shape.\n */\n map?: undefined;\n}\n\n/**\n * Result from the minifier on a successful minification.\n * @public\n */\nexport interface IModuleMinificationSuccessResult {\n /**\n * Identity of the request\n */\n hash: string;\n /**\n * The error property being `undefined` indicates success.\n */\n error: undefined;\n /**\n * The minified code.\n */\n code: string;\n /**\n * Marker property to always return the same result shape.\n */\n map?: RawSourceMap;\n}\n\n/**\n * Result from the minifier.\n * @public\n */\nexport type IModuleMinificationResult = IModuleMinificationErrorResult | IModuleMinificationSuccessResult;\n\n/**\n * Callback passed to a minifier function\n * @public\n */\nexport interface IModuleMinificationCallback {\n (result: IModuleMinificationResult): void;\n}\n\n/**\n * An async function called to minify a chunk of code\n * @public\n */\nexport interface IModuleMinifierFunction {\n (request: IModuleMinificationRequest, callback: IModuleMinificationCallback): void;\n}\n\n/**\n * Metadata from the minifier for the plugin\n * @public\n */\nexport interface IMinifierConnection {\n /**\n * Hash of the configuration of this minifier, for cache busting.\n */\n configHash: string;\n /**\n * Callback to be invoked when done with the minifier\n */\n disconnect(): Promise<void>;\n}\n\n/**\n * Object that can be invoked to minify code.\n * @public\n */\nexport interface IModuleMinifier {\n /**\n * Asynchronously minify a module\n */\n minify: IModuleMinifierFunction;\n\n /**\n * Prevents the minifier from shutting down until the returned `disconnect()` callback is invoked.\n * The callback may be used to surface errors encountered by the minifier that may not be relevant to a specific file.\n * It should be called to allow the minifier to cleanup\n */\n connect(): Promise<IMinifierConnection>;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\r\n// See LICENSE in the project root for license information.\r\n\r\nimport type { RawSourceMap } from 'source-map';\r\n\r\n/**\r\n * Request to the minifier\r\n * @public\r\n */\r\nexport interface IModuleMinificationRequest {\r\n /**\r\n * Identity of the request. Will be included in the response.\r\n */\r\n hash: string;\r\n /**\r\n * The raw code fragment\r\n */\r\n code: string;\r\n /**\r\n * File name to show for the source code in the source map\r\n */\r\n nameForMap: string | undefined;\r\n /**\r\n * Reserved variable names, e.g. __WEBPACK_EXTERNAL_MODULE_1__\r\n */\r\n externals: string[] | undefined;\r\n}\r\n\r\n/**\r\n * Result from the minifier function when an error is encountered.\r\n * @public\r\n */\r\nexport interface IModuleMinificationErrorResult {\r\n /**\r\n * Identity of the request\r\n */\r\n hash: string;\r\n /**\r\n * The error encountered, to be added to the current compilation's error collection.\r\n */\r\n error: Error;\r\n /**\r\n * Marker property to always return the same result shape.\r\n */\r\n code?: undefined;\r\n /**\r\n * Marker property to always return the same result shape.\r\n */\r\n map?: undefined;\r\n}\r\n\r\n/**\r\n * Result from the minifier on a successful minification.\r\n * @public\r\n */\r\nexport interface IModuleMinificationSuccessResult {\r\n /**\r\n * Identity of the request\r\n */\r\n hash: string;\r\n /**\r\n * The error property being `undefined` indicates success.\r\n */\r\n error: undefined;\r\n /**\r\n * The minified code.\r\n */\r\n code: string;\r\n /**\r\n * Marker property to always return the same result shape.\r\n */\r\n map?: RawSourceMap;\r\n}\r\n\r\n/**\r\n * Result from the minifier.\r\n * @public\r\n */\r\nexport type IModuleMinificationResult = IModuleMinificationErrorResult | IModuleMinificationSuccessResult;\r\n\r\n/**\r\n * Callback passed to a minifier function\r\n * @public\r\n */\r\nexport interface IModuleMinificationCallback {\r\n (result: IModuleMinificationResult): void;\r\n}\r\n\r\n/**\r\n * An async function called to minify a chunk of code\r\n * @public\r\n */\r\nexport interface IModuleMinifierFunction {\r\n (request: IModuleMinificationRequest, callback: IModuleMinificationCallback): void;\r\n}\r\n\r\n/**\r\n * Metadata from the minifier for the plugin\r\n * @public\r\n */\r\nexport interface IMinifierConnection {\r\n /**\r\n * Hash of the configuration of this minifier, for cache busting.\r\n */\r\n configHash: string;\r\n /**\r\n * Callback to be invoked when done with the minifier\r\n */\r\n disconnect(): Promise<void>;\r\n}\r\n\r\n/**\r\n * Object that can be invoked to minify code.\r\n * @public\r\n */\r\nexport interface IModuleMinifier {\r\n /**\r\n * Asynchronously minify a module\r\n */\r\n minify: IModuleMinifierFunction;\r\n\r\n /**\r\n * Prevents the minifier from shutting down until the returned `disconnect()` callback is invoked.\r\n * The callback may be used to surface errors encountered by the minifier that may not be relevant to a specific file.\r\n * It should be called to allow the minifier to cleanup\r\n */\r\n connect(): Promise<IMinifierConnection>;\r\n}\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rushstack/module-minifier",
3
- "version": "0.4.8",
3
+ "version": "0.4.10",
4
4
  "description": "Wrapper for terser to support bulk parallel minification.",
5
5
  "main": "lib/index.js",
6
6
  "typings": "dist/module-minifier.d.ts",
@@ -14,11 +14,11 @@
14
14
  "serialize-javascript": "6.0.0",
15
15
  "source-map": "~0.7.3",
16
16
  "terser": "^5.9.0",
17
- "@rushstack/worker-pool": "0.4.8"
17
+ "@rushstack/worker-pool": "0.4.10"
18
18
  },
19
19
  "devDependencies": {
20
20
  "@types/serialize-javascript": "5.0.2",
21
- "@rushstack/heft": "0.62.2",
21
+ "@rushstack/heft": "0.63.0",
22
22
  "local-node-rig": "1.0.0"
23
23
  },
24
24
  "peerDependencies": {