@rushstack/module-minifier 0.8.14 → 0.9.1
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/CHANGELOG.json +40 -0
- package/CHANGELOG.md +15 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/lib-esm/LocalMinifier.js +76 -0
- package/lib-esm/LocalMinifier.js.map +1 -0
- package/lib-esm/MessagePortMinifier.js +64 -0
- package/lib-esm/MessagePortMinifier.js.map +1 -0
- package/lib-esm/MinifiedIdentifier.js +144 -0
- package/lib-esm/MinifiedIdentifier.js.map +1 -0
- package/lib-esm/MinifierWorker.js +21 -0
- package/lib-esm/MinifierWorker.js.map +1 -0
- package/lib-esm/MinifySingleFile.js +61 -0
- package/lib-esm/MinifySingleFile.js.map +1 -0
- package/lib-esm/NoopMinifier.js +54 -0
- package/lib-esm/NoopMinifier.js.map +1 -0
- package/lib-esm/WorkerPoolMinifier.js +132 -0
- package/lib-esm/WorkerPoolMinifier.js.map +1 -0
- package/lib-esm/constants.js +15 -0
- package/lib-esm/constants.js.map +1 -0
- package/lib-esm/index.js +9 -0
- package/lib-esm/index.js.map +1 -0
- package/lib-esm/types.js +4 -0
- package/lib-esm/types.js.map +1 -0
- package/package.json +30 -6
- /package/{lib → lib-commonjs}/LocalMinifier.js +0 -0
- /package/{lib → lib-commonjs}/LocalMinifier.js.map +0 -0
- /package/{lib → lib-commonjs}/MessagePortMinifier.js +0 -0
- /package/{lib → lib-commonjs}/MessagePortMinifier.js.map +0 -0
- /package/{lib → lib-commonjs}/MinifiedIdentifier.js +0 -0
- /package/{lib → lib-commonjs}/MinifiedIdentifier.js.map +0 -0
- /package/{lib → lib-commonjs}/MinifierWorker.js +0 -0
- /package/{lib → lib-commonjs}/MinifierWorker.js.map +0 -0
- /package/{lib → lib-commonjs}/MinifySingleFile.js +0 -0
- /package/{lib → lib-commonjs}/MinifySingleFile.js.map +0 -0
- /package/{lib → lib-commonjs}/NoopMinifier.js +0 -0
- /package/{lib → lib-commonjs}/NoopMinifier.js.map +0 -0
- /package/{lib → lib-commonjs}/WorkerPoolMinifier.js +0 -0
- /package/{lib → lib-commonjs}/WorkerPoolMinifier.js.map +0 -0
- /package/{lib → lib-commonjs}/constants.js +0 -0
- /package/{lib → lib-commonjs}/constants.js.map +0 -0
- /package/{lib → lib-commonjs}/index.js +0 -0
- /package/{lib → lib-commonjs}/index.js.map +0 -0
- /package/{lib → lib-commonjs}/types.js +0 -0
- /package/{lib → lib-commonjs}/types.js.map +0 -0
- /package/{lib → lib-dts}/LocalMinifier.d.ts +0 -0
- /package/{lib → lib-dts}/LocalMinifier.d.ts.map +0 -0
- /package/{lib → lib-dts}/MessagePortMinifier.d.ts +0 -0
- /package/{lib → lib-dts}/MessagePortMinifier.d.ts.map +0 -0
- /package/{lib → lib-dts}/MinifiedIdentifier.d.ts +0 -0
- /package/{lib → lib-dts}/MinifiedIdentifier.d.ts.map +0 -0
- /package/{lib → lib-dts}/MinifierWorker.d.ts +0 -0
- /package/{lib → lib-dts}/MinifierWorker.d.ts.map +0 -0
- /package/{lib → lib-dts}/MinifySingleFile.d.ts +0 -0
- /package/{lib → lib-dts}/MinifySingleFile.d.ts.map +0 -0
- /package/{lib → lib-dts}/NoopMinifier.d.ts +0 -0
- /package/{lib → lib-dts}/NoopMinifier.d.ts.map +0 -0
- /package/{lib → lib-dts}/WorkerPoolMinifier.d.ts +0 -0
- /package/{lib → lib-dts}/WorkerPoolMinifier.d.ts.map +0 -0
- /package/{lib → lib-dts}/constants.d.ts +0 -0
- /package/{lib → lib-dts}/constants.d.ts.map +0 -0
- /package/{lib → lib-dts}/index.d.ts +0 -0
- /package/{lib → lib-dts}/index.d.ts.map +0 -0
- /package/{lib → lib-dts}/types.d.ts +0 -0
- /package/{lib → lib-dts}/types.d.ts.map +0 -0
package/CHANGELOG.json
CHANGED
|
@@ -1,6 +1,46 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rushstack/module-minifier",
|
|
3
3
|
"entries": [
|
|
4
|
+
{
|
|
5
|
+
"version": "0.9.1",
|
|
6
|
+
"tag": "@rushstack/module-minifier_v0.9.1",
|
|
7
|
+
"date": "Fri, 20 Feb 2026 00:15:04 GMT",
|
|
8
|
+
"comments": {
|
|
9
|
+
"patch": [
|
|
10
|
+
{
|
|
11
|
+
"comment": "Add `\"node\"` condition before `\"import\"` in the `\"exports\"` map so that Node.js uses the CJS output (which handles extensionless imports), while bundlers still use ESM via `\"import\"`. Fixes https://github.com/microsoft/rushstack/issues/5644."
|
|
12
|
+
}
|
|
13
|
+
],
|
|
14
|
+
"dependency": [
|
|
15
|
+
{
|
|
16
|
+
"comment": "Updating dependency \"@rushstack/worker-pool\" to `0.7.1`"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"comment": "Updating dependency \"@rushstack/heft\" to `1.2.1`"
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"version": "0.9.0",
|
|
26
|
+
"tag": "@rushstack/module-minifier_v0.9.0",
|
|
27
|
+
"date": "Thu, 19 Feb 2026 00:04:53 GMT",
|
|
28
|
+
"comments": {
|
|
29
|
+
"minor": [
|
|
30
|
+
{
|
|
31
|
+
"comment": "Normalize package layout. CommonJS is now under `lib-commonjs`, DTS is now under `lib-dts`, and ESM is now under `lib-esm`. Imports to `lib` still work as before, handled by the `\"exports\"` field in `package.json`."
|
|
32
|
+
}
|
|
33
|
+
],
|
|
34
|
+
"dependency": [
|
|
35
|
+
{
|
|
36
|
+
"comment": "Updating dependency \"@rushstack/worker-pool\" to `0.7.0`"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"comment": "Updating dependency \"@rushstack/heft\" to `1.2.0`"
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
},
|
|
4
44
|
{
|
|
5
45
|
"version": "0.8.14",
|
|
6
46
|
"tag": "@rushstack/module-minifier_v0.8.14",
|
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
# Change Log - @rushstack/module-minifier
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Fri, 20 Feb 2026 00:15:04 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 0.9.1
|
|
6
|
+
Fri, 20 Feb 2026 00:15:04 GMT
|
|
7
|
+
|
|
8
|
+
### Patches
|
|
9
|
+
|
|
10
|
+
- Add `"node"` condition before `"import"` in the `"exports"` map so that Node.js uses the CJS output (which handles extensionless imports), while bundlers still use ESM via `"import"`. Fixes https://github.com/microsoft/rushstack/issues/5644.
|
|
11
|
+
|
|
12
|
+
## 0.9.0
|
|
13
|
+
Thu, 19 Feb 2026 00:04:53 GMT
|
|
14
|
+
|
|
15
|
+
### Minor changes
|
|
16
|
+
|
|
17
|
+
- Normalize package layout. CommonJS is now under `lib-commonjs`, DTS is now under `lib-dts`, and ESM is now under `lib-esm`. Imports to `lib` still work as before, handled by the `"exports"` field in `package.json`.
|
|
4
18
|
|
|
5
19
|
## 0.8.14
|
|
6
20
|
Sat, 07 Feb 2026 01:13:26 GMT
|
package/dist/tsdoc-metadata.json
CHANGED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
2
|
+
// See LICENSE in the project root for license information.
|
|
3
|
+
import { createHash } from 'node:crypto';
|
|
4
|
+
import serialize from 'serialize-javascript';
|
|
5
|
+
import { minifySingleFileAsync } from './MinifySingleFile';
|
|
6
|
+
/**
|
|
7
|
+
* Minifier implementation that minifies code on the main thread.
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export class LocalMinifier {
|
|
11
|
+
constructor(options) {
|
|
12
|
+
const { terserOptions = {} } = options || {};
|
|
13
|
+
this._terserOptions = {
|
|
14
|
+
...terserOptions,
|
|
15
|
+
output: terserOptions.output
|
|
16
|
+
? {
|
|
17
|
+
...terserOptions.output
|
|
18
|
+
}
|
|
19
|
+
: {}
|
|
20
|
+
};
|
|
21
|
+
const { version: terserVersion } = require('terser/package.json');
|
|
22
|
+
this._configHash = createHash('sha256')
|
|
23
|
+
.update(LocalMinifier.name, 'utf8')
|
|
24
|
+
.update(`terser@${terserVersion}`)
|
|
25
|
+
.update(serialize(terserOptions))
|
|
26
|
+
.digest('base64');
|
|
27
|
+
this._resultCache = new Map();
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Transform that invokes Terser on the main thread
|
|
31
|
+
* @param request - The request to process
|
|
32
|
+
* @param callback - The callback to invoke
|
|
33
|
+
*/
|
|
34
|
+
minify(request, callback) {
|
|
35
|
+
const { hash } = request;
|
|
36
|
+
const cached = this._resultCache.get(hash);
|
|
37
|
+
if (cached) {
|
|
38
|
+
return callback(cached);
|
|
39
|
+
}
|
|
40
|
+
minifySingleFileAsync(request, this._terserOptions)
|
|
41
|
+
.then((result) => {
|
|
42
|
+
this._resultCache.set(hash, result);
|
|
43
|
+
callback(result);
|
|
44
|
+
})
|
|
45
|
+
.catch((error) => {
|
|
46
|
+
// This branch is here to satisfy the no-floating-promises lint rule
|
|
47
|
+
callback({
|
|
48
|
+
error: error,
|
|
49
|
+
code: undefined,
|
|
50
|
+
map: undefined,
|
|
51
|
+
hash
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* {@inheritdoc IModuleMinifier.connectAsync}
|
|
57
|
+
*/
|
|
58
|
+
async connectAsync() {
|
|
59
|
+
const disconnectAsync = async () => {
|
|
60
|
+
// Do nothing.
|
|
61
|
+
};
|
|
62
|
+
return {
|
|
63
|
+
configHash: this._configHash,
|
|
64
|
+
disconnectAsync,
|
|
65
|
+
disconnect: disconnectAsync
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* @deprecated Use {@link LocalMinifier.connectAsync} instead.
|
|
70
|
+
*/
|
|
71
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
72
|
+
async connect() {
|
|
73
|
+
return await this.connectAsync();
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=LocalMinifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocalMinifier.js","sourceRoot":"","sources":["../src/LocalMinifier.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AAE3D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,SAAS,MAAM,sBAAsB,CAAC;AAU7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAU3D;;;GAGG;AACH,MAAM,OAAO,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,UAAU,CAAC,QAAQ,CAAC;aACpC,MAAM,CAAC,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC;aAClC,MAAM,CAAC,UAAU,aAAa,EAAE,CAAC;aACjC,MAAM,CAAC,SAAS,CAAC,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,CAAC;YACX,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC;QAC1B,CAAC;QAED,qBAAqB,CAAC,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;IAED;;OAEG;IACI,KAAK,CAAC,YAAY;QACvB,MAAM,eAAe,GAA2C,KAAK,IAAI,EAAE;YACzE,cAAc;QAChB,CAAC,CAAC;QACF,OAAO;YACL,UAAU,EAAE,IAAI,CAAC,WAAW;YAC5B,eAAe;YACf,UAAU,EAAE,eAAe;SAC5B,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,gEAAgE;IACzD,KAAK,CAAC,OAAO;QAClB,OAAO,MAAM,IAAI,CAAC,YAAY,EAAE,CAAC;IACnC,CAAC;CACF","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 'node:crypto';\n\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 /**\n * {@inheritdoc IModuleMinifier.connectAsync}\n */\n public async connectAsync(): Promise<IMinifierConnection> {\n const disconnectAsync: IMinifierConnection['disconnectAsync'] = async () => {\n // Do nothing.\n };\n return {\n configHash: this._configHash,\n disconnectAsync,\n disconnect: disconnectAsync\n };\n }\n\n /**\n * @deprecated Use {@link LocalMinifier.connectAsync} instead.\n */\n // eslint-disable-next-line @typescript-eslint/naming-convention\n public async connect(): Promise<IMinifierConnection> {\n return await this.connectAsync();\n }\n}\n"]}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
2
|
+
// See LICENSE in the project root for license information.
|
|
3
|
+
import { once } from 'node:events';
|
|
4
|
+
/**
|
|
5
|
+
* Minifier implementation that outsources requests to the other side of a MessagePort
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export class MessagePortMinifier {
|
|
9
|
+
constructor(port) {
|
|
10
|
+
this.port = port;
|
|
11
|
+
this._callbacks = new Map();
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* No-op code transform.
|
|
15
|
+
* @param request - The request to process
|
|
16
|
+
* @param callback - The callback to invoke
|
|
17
|
+
*/
|
|
18
|
+
minify(request, callback) {
|
|
19
|
+
const { hash } = request;
|
|
20
|
+
const callbacks = this._callbacks.get(hash);
|
|
21
|
+
if (callbacks) {
|
|
22
|
+
callbacks.push(callback);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
this._callbacks.set(hash, [callback]);
|
|
26
|
+
this.port.postMessage(request);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* {@inheritdoc IModuleMinifier.connectAsync}
|
|
30
|
+
*/
|
|
31
|
+
async connectAsync() {
|
|
32
|
+
const configHashPromise = once(this.port, 'message');
|
|
33
|
+
this.port.postMessage('initialize');
|
|
34
|
+
const configHash = await configHashPromise;
|
|
35
|
+
const callbacks = this._callbacks;
|
|
36
|
+
function handler(message) {
|
|
37
|
+
if (typeof message === 'object') {
|
|
38
|
+
const callbacksForRequest = callbacks.get(message.hash);
|
|
39
|
+
callbacks.delete(message.hash);
|
|
40
|
+
for (const callback of callbacksForRequest) {
|
|
41
|
+
callback(message);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
this.port.on('message', handler);
|
|
46
|
+
const disconnectAsync = async () => {
|
|
47
|
+
this.port.off('message', handler);
|
|
48
|
+
this.port.close();
|
|
49
|
+
};
|
|
50
|
+
return {
|
|
51
|
+
configHash,
|
|
52
|
+
disconnectAsync,
|
|
53
|
+
disconnect: disconnectAsync
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* @deprecated Use {@link MessagePortMinifier.connectAsync} instead
|
|
58
|
+
*/
|
|
59
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
60
|
+
async connect() {
|
|
61
|
+
return await this.connectAsync();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=MessagePortMinifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MessagePortMinifier.js","sourceRoot":"","sources":["../src/MessagePortMinifier.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AAE3D,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAWnC;;;GAGG;AACH,MAAM,OAAO,mBAAmB;IAK9B,YAAmB,IAA+B;QAChD,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,CAAC;YACd,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YACzB,OAAO;QACT,CAAC;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;IAED;;OAEG;IACI,KAAK,CAAC,YAAY;QACvB,MAAM,iBAAiB,GAAoB,IAAI,CAAC,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,CAAC;gBAChC,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,CAAC;oBAC3C,QAAQ,CAAC,OAAO,CAAC,CAAC;gBACpB,CAAC;YACH,CAAC;QACH,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QACjC,MAAM,eAAe,GAA2C,KAAK,IAAI,EAAE;YACzE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;YAClC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;QACpB,CAAC,CAAC;QACF,OAAO;YACL,UAAU;YACV,eAAe;YACf,UAAU,EAAE,eAAe;SAC5B,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,gEAAgE;IACzD,KAAK,CAAC,OAAO;QAClB,OAAO,MAAM,IAAI,CAAC,YAAY,EAAE,CAAC;IACnC,CAAC;CACF","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 'node:events';\nimport type * as WorkerThreads from 'node: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: WorkerThreads.MessagePort;\n\n private readonly _callbacks: Map<string, IModuleMinificationCallback[]>;\n\n public constructor(port: WorkerThreads.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 /**\n * {@inheritdoc IModuleMinifier.connectAsync}\n */\n public async connectAsync(): 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 const disconnectAsync: IMinifierConnection['disconnectAsync'] = async () => {\n this.port.off('message', handler);\n this.port.close();\n };\n return {\n configHash,\n disconnectAsync,\n disconnect: disconnectAsync\n };\n }\n\n /**\n * @deprecated Use {@link MessagePortMinifier.connectAsync} instead\n */\n // eslint-disable-next-line @typescript-eslint/naming-convention\n public async connect(): Promise<IMinifierConnection> {\n return await this.connectAsync();\n }\n}\n"]}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
2
|
+
// See LICENSE in the project root for license information.
|
|
3
|
+
// TODO: Allow dynamic override of these values in the input to the minifier
|
|
4
|
+
import { IDENTIFIER_LEADING_DIGITS, IDENTIFIER_TRAILING_DIGITS } from './constants';
|
|
5
|
+
// Set of ECMAScript reserved keywords (past and present): https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar
|
|
6
|
+
const RESERVED_KEYWORDS = [
|
|
7
|
+
'abstract',
|
|
8
|
+
'arguments',
|
|
9
|
+
'boolean',
|
|
10
|
+
'break',
|
|
11
|
+
'byte',
|
|
12
|
+
'case',
|
|
13
|
+
'catch',
|
|
14
|
+
'char',
|
|
15
|
+
'class',
|
|
16
|
+
'const',
|
|
17
|
+
'continue',
|
|
18
|
+
'debugger',
|
|
19
|
+
'default',
|
|
20
|
+
'delete',
|
|
21
|
+
'do',
|
|
22
|
+
'double',
|
|
23
|
+
'else',
|
|
24
|
+
'enum',
|
|
25
|
+
'export',
|
|
26
|
+
'extends',
|
|
27
|
+
'false',
|
|
28
|
+
'final',
|
|
29
|
+
'finally',
|
|
30
|
+
'float',
|
|
31
|
+
'for',
|
|
32
|
+
'function',
|
|
33
|
+
'get',
|
|
34
|
+
'goto',
|
|
35
|
+
'if',
|
|
36
|
+
'implements',
|
|
37
|
+
'import',
|
|
38
|
+
'in',
|
|
39
|
+
'instanceof',
|
|
40
|
+
'int',
|
|
41
|
+
'interface',
|
|
42
|
+
'let',
|
|
43
|
+
'long',
|
|
44
|
+
'native',
|
|
45
|
+
'new',
|
|
46
|
+
'null',
|
|
47
|
+
'package',
|
|
48
|
+
'private',
|
|
49
|
+
'protected',
|
|
50
|
+
'public',
|
|
51
|
+
'return',
|
|
52
|
+
'set',
|
|
53
|
+
'short',
|
|
54
|
+
'static',
|
|
55
|
+
'super',
|
|
56
|
+
'switch',
|
|
57
|
+
'synchronized',
|
|
58
|
+
'this',
|
|
59
|
+
'throw',
|
|
60
|
+
'throws',
|
|
61
|
+
'transient',
|
|
62
|
+
'true',
|
|
63
|
+
'try',
|
|
64
|
+
'typeof',
|
|
65
|
+
'var',
|
|
66
|
+
'void',
|
|
67
|
+
'volatile',
|
|
68
|
+
'while',
|
|
69
|
+
'with',
|
|
70
|
+
'yield'
|
|
71
|
+
];
|
|
72
|
+
/**
|
|
73
|
+
* Gets a base54 string suitable for use as a JavaScript identifier, not accounting for reserved keywords
|
|
74
|
+
* @param ordinal - The number to convert to a base54 identifier
|
|
75
|
+
*/
|
|
76
|
+
export function getIdentifierInternal(ordinal) {
|
|
77
|
+
let ret = IDENTIFIER_LEADING_DIGITS[ordinal % 54];
|
|
78
|
+
// eslint-disable-next-line no-bitwise
|
|
79
|
+
ordinal = (ordinal / 54) | 0;
|
|
80
|
+
while (ordinal > 0) {
|
|
81
|
+
--ordinal;
|
|
82
|
+
// eslint-disable-next-line no-bitwise
|
|
83
|
+
ret += IDENTIFIER_TRAILING_DIGITS[ordinal & 0x3f];
|
|
84
|
+
ordinal >>>= 6;
|
|
85
|
+
}
|
|
86
|
+
return ret;
|
|
87
|
+
}
|
|
88
|
+
const leadingCharIndex = new Map();
|
|
89
|
+
for (let i = 0; i < 64; i++) {
|
|
90
|
+
leadingCharIndex.set(IDENTIFIER_LEADING_DIGITS.charCodeAt(i), i);
|
|
91
|
+
}
|
|
92
|
+
const trailingCharIndex = new Map();
|
|
93
|
+
for (let i = 0; i < 64; i++) {
|
|
94
|
+
trailingCharIndex.set(IDENTIFIER_TRAILING_DIGITS.charCodeAt(i), i);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Converts an identifier into the ordinal that would produce it, not accounting for reserved keywords
|
|
98
|
+
* Returns NaN if the result would exceed 31 bits
|
|
99
|
+
* @param identifier - The identifier to convert to a numeric value
|
|
100
|
+
*/
|
|
101
|
+
export function getOrdinalFromIdentifierInternal(identifier) {
|
|
102
|
+
let ordinal = 0;
|
|
103
|
+
for (let i = identifier.length - 1; i > 0; i--) {
|
|
104
|
+
if (ordinal >= 0x2000000) {
|
|
105
|
+
return NaN;
|
|
106
|
+
}
|
|
107
|
+
ordinal <<= 6;
|
|
108
|
+
ordinal += trailingCharIndex.get(identifier.charCodeAt(i)) + 1;
|
|
109
|
+
}
|
|
110
|
+
if (ordinal >= 0x2000000) {
|
|
111
|
+
return NaN;
|
|
112
|
+
}
|
|
113
|
+
ordinal *= 54;
|
|
114
|
+
ordinal += leadingCharIndex.get(identifier.charCodeAt(0));
|
|
115
|
+
return ordinal;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* getIdentifier(n) would otherwise return each of these specified ECMAScript reserved keywords, which are not legal identifiers.
|
|
119
|
+
*/
|
|
120
|
+
const RESERVED_ORDINALS = (() => {
|
|
121
|
+
const reserved = [];
|
|
122
|
+
for (const keyword of RESERVED_KEYWORDS) {
|
|
123
|
+
const ordinal = getOrdinalFromIdentifierInternal(keyword);
|
|
124
|
+
if (!isNaN(ordinal)) {
|
|
125
|
+
reserved.push(ordinal);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return reserved.sort((x, y) => x - y);
|
|
129
|
+
})();
|
|
130
|
+
/**
|
|
131
|
+
* Gets a base54 string suitable for use as a JavaScript identifier, omitting those that are valid ECMAScript keywords
|
|
132
|
+
*
|
|
133
|
+
* @param ordinal - The number to convert to a base54 identifier
|
|
134
|
+
*
|
|
135
|
+
* @public
|
|
136
|
+
*/
|
|
137
|
+
export function getIdentifier(ordinal) {
|
|
138
|
+
// Need to skip over reserved keywords
|
|
139
|
+
for (let i = 0, len = RESERVED_ORDINALS.length; i < len && ordinal >= RESERVED_ORDINALS[i]; i++) {
|
|
140
|
+
++ordinal;
|
|
141
|
+
}
|
|
142
|
+
return getIdentifierInternal(ordinal);
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=MinifiedIdentifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MinifiedIdentifier.js","sourceRoot":"","sources":["../src/MinifiedIdentifier.ts"],"names":[],"mappings":"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","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 // eslint-disable-next-line no-bitwise\n ordinal = (ordinal / 54) | 0;\n while (ordinal > 0) {\n --ordinal;\n // eslint-disable-next-line no-bitwise\n ret += IDENTIFIER_TRAILING_DIGITS[ordinal & 0x3f];\n ordinal >>>= 6;\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;\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"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
2
|
+
// See LICENSE in the project root for license information.
|
|
3
|
+
import { parentPort, workerData } from 'node:worker_threads';
|
|
4
|
+
import { minifySingleFileAsync } from './MinifySingleFile';
|
|
5
|
+
const terserOptions = workerData;
|
|
6
|
+
// Set to non-zero to help debug unexpected graceful exit
|
|
7
|
+
process.exitCode = 2;
|
|
8
|
+
async function handler(message) {
|
|
9
|
+
if (!message) {
|
|
10
|
+
parentPort.off('postMessage', handler);
|
|
11
|
+
parentPort.close();
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const result = await minifySingleFileAsync(message, terserOptions);
|
|
15
|
+
parentPort.postMessage(result);
|
|
16
|
+
}
|
|
17
|
+
parentPort.once('close', () => {
|
|
18
|
+
process.exitCode = 0;
|
|
19
|
+
});
|
|
20
|
+
parentPort.on('message', handler);
|
|
21
|
+
//# sourceMappingURL=MinifierWorker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MinifierWorker.js","sourceRoot":"","sources":["../src/MinifierWorker.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AAE3D,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAI7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAG3D,MAAM,aAAa,GAAkB,UAAU,CAAC;AAEhD,yDAAyD;AACzD,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AAErB,KAAK,UAAU,OAAO,CAAC,OAAmC;IACxD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,UAAW,CAAC,GAAG,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;QACxC,UAAW,CAAC,KAAK,EAAE,CAAC;QACpB,OAAO;IACT,CAAC;IAED,MAAM,MAAM,GAA8B,MAAM,qBAAqB,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;IAE9F,UAAW,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;AAClC,CAAC;AAED,UAAW,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE;IAC7B,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;AACvB,CAAC,CAAC,CAAC;AACH,UAAW,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,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 { parentPort, workerData } from 'node:worker_threads';\n\nimport type { MinifyOptions } from 'terser';\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\nasync function handler(message: IModuleMinificationRequest): Promise<void> {\n if (!message) {\n parentPort!.off('postMessage', handler);\n parentPort!.close();\n return;\n }\n\n const result: IModuleMinificationResult = await minifySingleFileAsync(message, terserOptions);\n\n parentPort!.postMessage(result);\n}\n\nparentPort!.once('close', () => {\n process.exitCode = 0;\n});\nparentPort!.on('message', handler);\n"]}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
2
|
+
// See LICENSE in the project root for license information.
|
|
3
|
+
import { minify } from 'terser';
|
|
4
|
+
import { getIdentifier } from './MinifiedIdentifier';
|
|
5
|
+
const nth_identifier = {
|
|
6
|
+
get: getIdentifier
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Minifies a single chunk of code. Factored out for reuse between WorkerPoolMinifier and LocalMinifier
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export async function minifySingleFileAsync(request, terserOptions) {
|
|
13
|
+
const { code, nameForMap, hash, externals } = request;
|
|
14
|
+
try {
|
|
15
|
+
const { format: rawFormat, output: rawOutput, mangle: originalMangle, ...remainingOptions } = terserOptions;
|
|
16
|
+
const format = rawFormat || rawOutput || {};
|
|
17
|
+
const mangle = originalMangle === false ? false : typeof originalMangle === 'object' ? { ...originalMangle } : {};
|
|
18
|
+
const finalOptions = {
|
|
19
|
+
...remainingOptions,
|
|
20
|
+
format,
|
|
21
|
+
mangle
|
|
22
|
+
};
|
|
23
|
+
format.comments = false;
|
|
24
|
+
if (mangle) {
|
|
25
|
+
mangle.nth_identifier = nth_identifier;
|
|
26
|
+
}
|
|
27
|
+
if (mangle && externals) {
|
|
28
|
+
mangle.reserved = mangle.reserved ? externals.concat(mangle.reserved) : externals;
|
|
29
|
+
}
|
|
30
|
+
// SourceMap is only generated if nameForMap is provided- overrides terserOptions.sourceMap
|
|
31
|
+
if (nameForMap) {
|
|
32
|
+
finalOptions.sourceMap = {
|
|
33
|
+
includeSources: true,
|
|
34
|
+
asObject: true
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
finalOptions.sourceMap = false;
|
|
39
|
+
}
|
|
40
|
+
const minified = await minify({
|
|
41
|
+
[nameForMap || 'code']: code
|
|
42
|
+
}, finalOptions);
|
|
43
|
+
return {
|
|
44
|
+
error: undefined,
|
|
45
|
+
code: minified.code,
|
|
46
|
+
map: minified.map,
|
|
47
|
+
hash
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
// eslint-disable-next-line no-console
|
|
52
|
+
console.error(error);
|
|
53
|
+
return {
|
|
54
|
+
error: error,
|
|
55
|
+
code: undefined,
|
|
56
|
+
map: undefined,
|
|
57
|
+
hash
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=MinifySingleFile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MinifySingleFile.js","sourceRoot":"","sources":["../src/MinifySingleFile.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AAE3D,OAAO,EAAE,MAAM,EAAuE,MAAM,QAAQ,CAAC;AAGrG,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGrD,MAAM,cAAc,GAA4B;IAC9C,GAAG,EAAE,aAAa;CACnB,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,OAAmC,EACnC,aAA4B;IAE5B,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAEtD,IAAI,CAAC;QACH,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,CAAC;YACX,MAAM,CAAC,cAAc,GAAG,cAAc,CAAC;QACzC,CAAC;QAED,IAAI,MAAM,IAAI,SAAS,EAAE,CAAC;YACxB,MAAM,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACpF,CAAC;QAED,2FAA2F;QAC3F,IAAI,UAAU,EAAE,CAAC;YACf,YAAY,CAAC,SAAS,GAAG;gBACvB,cAAc,EAAE,IAAI;gBACpB,QAAQ,EAAE,IAAI;aACf,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,YAAY,CAAC,SAAS,GAAG,KAAK,CAAC;QACjC,CAAC;QAED,MAAM,QAAQ,GAAiB,MAAM,MAAM,CACzC;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;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,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;IACJ,CAAC;AACH,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 { minify, type MinifyOptions, type MinifyOutput, type SimpleIdentifierMangler } from 'terser';\nimport type { RawSourceMap } from 'source-map';\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 // SourceMap is only generated if nameForMap is provided- overrides terserOptions.sourceMap\n if (nameForMap) {\n finalOptions.sourceMap = {\n includeSources: true,\n asObject: true\n };\n } else {\n finalOptions.sourceMap = false;\n }\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"]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
2
|
+
// See LICENSE in the project root for license information.
|
|
3
|
+
/**
|
|
4
|
+
* Minifier implementation that does not actually transform the code, for debugging.
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export class NoopMinifier {
|
|
8
|
+
/**
|
|
9
|
+
* No-op code transform.
|
|
10
|
+
* @param request - The request to process
|
|
11
|
+
* @param callback - The callback to invoke
|
|
12
|
+
*/
|
|
13
|
+
minify(request, callback) {
|
|
14
|
+
const { code, hash, nameForMap } = request;
|
|
15
|
+
callback({
|
|
16
|
+
hash,
|
|
17
|
+
error: undefined,
|
|
18
|
+
code,
|
|
19
|
+
// If source maps are requested, provide an empty source map
|
|
20
|
+
map: nameForMap
|
|
21
|
+
? {
|
|
22
|
+
version: 3,
|
|
23
|
+
names: [],
|
|
24
|
+
file: nameForMap,
|
|
25
|
+
sources: [nameForMap],
|
|
26
|
+
sourcesContent: [code],
|
|
27
|
+
// In source mapping parlance, this means "map line 0, column 0 to the input file at index 0, line 0, column 0"
|
|
28
|
+
mappings: 'AAAA'
|
|
29
|
+
}
|
|
30
|
+
: undefined
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* {@inheritdoc IModuleMinifier.connectAsync}
|
|
35
|
+
*/
|
|
36
|
+
async connectAsync() {
|
|
37
|
+
const disconnectAsync = async () => {
|
|
38
|
+
// Do nothing.
|
|
39
|
+
};
|
|
40
|
+
return {
|
|
41
|
+
configHash: NoopMinifier.name,
|
|
42
|
+
disconnectAsync,
|
|
43
|
+
disconnect: disconnectAsync
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* @deprecated Use {@link NoopMinifier.connectAsync} instead
|
|
48
|
+
*/
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
50
|
+
async connect() {
|
|
51
|
+
return await this.connectAsync();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=NoopMinifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NoopMinifier.js","sourceRoot":"","sources":["../src/NoopMinifier.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AAS3D;;;GAGG;AACH,MAAM,OAAO,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;IAED;;OAEG;IACI,KAAK,CAAC,YAAY;QACvB,MAAM,eAAe,GAA2C,KAAK,IAAI,EAAE;YACzE,cAAc;QAChB,CAAC,CAAC;QAEF,OAAO;YACL,UAAU,EAAE,YAAY,CAAC,IAAI;YAC7B,eAAe;YACf,UAAU,EAAE,eAAe;SAC5B,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,gEAAgE;IACzD,KAAK,CAAC,OAAO;QAClB,OAAO,MAAM,IAAI,CAAC,YAAY,EAAE,CAAC;IACnC,CAAC;CACF","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 /**\n * {@inheritdoc IModuleMinifier.connectAsync}\n */\n public async connectAsync(): Promise<IMinifierConnection> {\n const disconnectAsync: IMinifierConnection['disconnectAsync'] = async () => {\n // Do nothing.\n };\n\n return {\n configHash: NoopMinifier.name,\n disconnectAsync,\n disconnect: disconnectAsync\n };\n }\n\n /**\n * @deprecated Use {@link NoopMinifier.connectAsync} instead\n */\n // eslint-disable-next-line @typescript-eslint/naming-convention\n public async connect(): Promise<IMinifierConnection> {\n return await this.connectAsync();\n }\n}\n"]}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
2
|
+
// See LICENSE in the project root for license information.
|
|
3
|
+
import { createHash } from 'node:crypto';
|
|
4
|
+
import os from 'node:os';
|
|
5
|
+
import serialize from 'serialize-javascript';
|
|
6
|
+
import { WorkerPool } from '@rushstack/worker-pool';
|
|
7
|
+
/**
|
|
8
|
+
* Minifier implementation that uses a thread pool for minification.
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export class WorkerPoolMinifier {
|
|
12
|
+
constructor(options) {
|
|
13
|
+
var _a, _b;
|
|
14
|
+
const { maxThreads = (_b = (_a = os.availableParallelism) === null || _a === void 0 ? void 0 : _a.call(os)) !== null && _b !== void 0 ? _b : os.cpus().length, terserOptions = {}, verbose = false, workerResourceLimits } = options || {};
|
|
15
|
+
const activeRequests = new Map();
|
|
16
|
+
const resultCache = new Map();
|
|
17
|
+
const terserPool = new WorkerPool({
|
|
18
|
+
id: 'Minifier',
|
|
19
|
+
maxWorkers: maxThreads,
|
|
20
|
+
workerData: terserOptions,
|
|
21
|
+
workerScriptPath: require.resolve('./MinifierWorker'),
|
|
22
|
+
workerResourceLimits
|
|
23
|
+
});
|
|
24
|
+
const { version: terserVersion } = require('terser/package.json');
|
|
25
|
+
this._configHash = createHash('sha256')
|
|
26
|
+
.update(WorkerPoolMinifier.name, 'utf8')
|
|
27
|
+
.update(`terser@${terserVersion}`)
|
|
28
|
+
.update(serialize(terserOptions))
|
|
29
|
+
.digest('base64');
|
|
30
|
+
this._activeRequests = activeRequests;
|
|
31
|
+
this._refCount = 0;
|
|
32
|
+
this._resultCache = resultCache;
|
|
33
|
+
this._pool = terserPool;
|
|
34
|
+
this._verbose = verbose;
|
|
35
|
+
this._deduped = 0;
|
|
36
|
+
this._minified = 0;
|
|
37
|
+
}
|
|
38
|
+
get maxThreads() {
|
|
39
|
+
return this._pool.maxWorkers;
|
|
40
|
+
}
|
|
41
|
+
set maxThreads(threads) {
|
|
42
|
+
this._pool.maxWorkers = threads;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Transform code by farming it out to a worker pool.
|
|
46
|
+
* @param request - The request to process
|
|
47
|
+
* @param callback - The callback to invoke
|
|
48
|
+
*/
|
|
49
|
+
minify(request, callback) {
|
|
50
|
+
const { hash } = request;
|
|
51
|
+
const cached = this._resultCache.get(hash);
|
|
52
|
+
if (cached) {
|
|
53
|
+
++this._deduped;
|
|
54
|
+
return callback(cached);
|
|
55
|
+
}
|
|
56
|
+
const { _activeRequests: activeRequests } = this;
|
|
57
|
+
const callbacks = activeRequests.get(hash);
|
|
58
|
+
if (callbacks) {
|
|
59
|
+
++this._deduped;
|
|
60
|
+
callbacks.push(callback);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
activeRequests.set(hash, [callback]);
|
|
64
|
+
++this._minified;
|
|
65
|
+
this._pool
|
|
66
|
+
.checkoutWorkerAsync(true)
|
|
67
|
+
.then((worker) => {
|
|
68
|
+
const cb = (message) => {
|
|
69
|
+
worker.off('message', cb);
|
|
70
|
+
const workerCallbacks = activeRequests.get(message.hash);
|
|
71
|
+
activeRequests.delete(message.hash);
|
|
72
|
+
this._resultCache.set(message.hash, message);
|
|
73
|
+
for (const workerCallback of workerCallbacks) {
|
|
74
|
+
workerCallback(message);
|
|
75
|
+
}
|
|
76
|
+
// This should always be the last thing done with the worker
|
|
77
|
+
this._pool.checkinWorker(worker);
|
|
78
|
+
};
|
|
79
|
+
worker.on('message', cb);
|
|
80
|
+
worker.postMessage(request);
|
|
81
|
+
})
|
|
82
|
+
.catch((error) => {
|
|
83
|
+
const errorCallbacks = activeRequests.get(hash);
|
|
84
|
+
for (const errorCallback of errorCallbacks) {
|
|
85
|
+
errorCallback({
|
|
86
|
+
hash,
|
|
87
|
+
error,
|
|
88
|
+
code: undefined,
|
|
89
|
+
map: undefined
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* {@inheritdoc IModuleMinifier.connectAsync}
|
|
96
|
+
*/
|
|
97
|
+
async connectAsync() {
|
|
98
|
+
if (++this._refCount === 1) {
|
|
99
|
+
this._pool.reset();
|
|
100
|
+
}
|
|
101
|
+
const disconnectAsync = async () => {
|
|
102
|
+
if (--this._refCount === 0) {
|
|
103
|
+
if (this._verbose) {
|
|
104
|
+
// eslint-disable-next-line no-console
|
|
105
|
+
console.log(`Shutting down minifier worker pool`);
|
|
106
|
+
}
|
|
107
|
+
await this._pool.finishAsync();
|
|
108
|
+
this._resultCache.clear();
|
|
109
|
+
this._activeRequests.clear();
|
|
110
|
+
if (this._verbose) {
|
|
111
|
+
// eslint-disable-next-line no-console
|
|
112
|
+
console.log(`Module minification: ${this._deduped} Deduped, ${this._minified} Processed`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
this._deduped = 0;
|
|
116
|
+
this._minified = 0;
|
|
117
|
+
};
|
|
118
|
+
return {
|
|
119
|
+
configHash: this._configHash,
|
|
120
|
+
disconnectAsync,
|
|
121
|
+
disconnect: disconnectAsync
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* @deprecated Use {@link WorkerPoolMinifier.connectAsync} instead
|
|
126
|
+
*/
|
|
127
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
128
|
+
async connect() {
|
|
129
|
+
return await this.connectAsync();
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=WorkerPoolMinifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WorkerPoolMinifier.js","sourceRoot":"","sources":["../src/WorkerPoolMinifier.ts"],"names":[],"mappings":"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","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 'node:crypto';\nimport os from 'node:os';\nimport type { ResourceLimits } from 'node:worker_threads';\n\nimport serialize from 'serialize-javascript';\nimport type { MinifyOptions } from 'terser';\n\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.availableParallelism()\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 * Optional resource limits for the workers.\n */\n workerResourceLimits?: ResourceLimits;\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 {\n maxThreads = os.availableParallelism?.() ?? os.cpus().length,\n terserOptions = {},\n verbose = false,\n workerResourceLimits\n } = 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 workerResourceLimits\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 /**\n * {@inheritdoc IModuleMinifier.connectAsync}\n */\n public async connectAsync(): Promise<IMinifierConnection> {\n if (++this._refCount === 1) {\n this._pool.reset();\n }\n\n const disconnectAsync: IMinifierConnection['disconnectAsync'] = 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 return {\n configHash: this._configHash,\n\n disconnectAsync,\n disconnect: disconnectAsync\n };\n }\n\n /**\n * @deprecated Use {@link WorkerPoolMinifier.connectAsync} instead\n */\n // eslint-disable-next-line @typescript-eslint/naming-convention\n public async connect(): Promise<IMinifierConnection> {\n return await this.connectAsync();\n }\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
2
|
+
// See LICENSE in the project root for license information.
|
|
3
|
+
/**
|
|
4
|
+
* The sorted sequence of leading digits for mangled identifiers
|
|
5
|
+
* Used in MinifiedIdentifier computation for converting an ordinal to a valid ECMAScript identifier
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export const IDENTIFIER_LEADING_DIGITS = 'etnairoscdlufpm_hbgvySDIxCOwEALkMPTUFHRNBjVzGKWqQYJXZ$';
|
|
9
|
+
/**
|
|
10
|
+
* The sorted sequence of trailing digits for mangled identifiers
|
|
11
|
+
* Used in MinifiedIdentifier computation for converting an ordinal to a valid ECMAScript identifier
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
export const IDENTIFIER_TRAILING_DIGITS = 'etnairoscdlufpm_hbg01v32y67S4985DIxCOwEALkMPTUFHRNBjVzGKWqQYJXZ$';
|
|
15
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AAE3D;;;;GAIG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAW,wDAAwD,CAAC;AAE1G;;;;GAIG;AACH,MAAM,CAAC,MAAM,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"]}
|
package/lib-esm/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
|
|
2
|
+
// See LICENSE in the project root for license information.
|
|
3
|
+
export { LocalMinifier } from './LocalMinifier';
|
|
4
|
+
export { MessagePortMinifier } from './MessagePortMinifier';
|
|
5
|
+
export { getIdentifier } from './MinifiedIdentifier';
|
|
6
|
+
export { minifySingleFileAsync as _minifySingleFileAsync } from './MinifySingleFile';
|
|
7
|
+
export { NoopMinifier } from './NoopMinifier';
|
|
8
|
+
export { WorkerPoolMinifier } from './WorkerPoolMinifier';
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,2DAA2D;AAe3D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,EAAE,qBAAqB,IAAI,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAErF,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAc9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,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/// <reference types=\"node\" preserve=\"true\" />\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"]}
|
package/lib-esm/types.js
ADDED
|
@@ -0,0 +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 /**\n * @deprecated Use {@link IMinifierConnection.disconnectAsync} instead.\n */\n disconnect(): Promise<void>;\n\n /**\n * Callback to be invoked when done with the minifier\n */\n disconnectAsync(): 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 * @deprecated Use {@link IModuleMinifier.connectAsync} instead.\n */\n connect(): Promise<IMinifierConnection>;\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 connectAsync(): Promise<IMinifierConnection>;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,9 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rushstack/module-minifier",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "Wrapper for terser to support bulk parallel minification.",
|
|
5
|
-
"main": "lib/index.js",
|
|
6
|
-
"
|
|
5
|
+
"main": "./lib-commonjs/index.js",
|
|
6
|
+
"module": "./lib-esm/index.js",
|
|
7
|
+
"types": "./dist/module-minifier.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/module-minifier.d.ts",
|
|
11
|
+
"node": "./lib-commonjs/index.js",
|
|
12
|
+
"import": "./lib-esm/index.js",
|
|
13
|
+
"require": "./lib-commonjs/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./lib/*": {
|
|
16
|
+
"types": "./lib-dts/*.d.ts",
|
|
17
|
+
"node": "./lib-commonjs/*.js",
|
|
18
|
+
"import": "./lib-esm/*.js",
|
|
19
|
+
"require": "./lib-commonjs/*.js"
|
|
20
|
+
},
|
|
21
|
+
"./package.json": "./package.json"
|
|
22
|
+
},
|
|
23
|
+
"typesVersions": {
|
|
24
|
+
"*": {
|
|
25
|
+
"lib/*": [
|
|
26
|
+
"lib-dts/*"
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
},
|
|
7
30
|
"license": "MIT",
|
|
8
31
|
"repository": {
|
|
9
32
|
"url": "https://github.com/microsoft/rushstack.git",
|
|
@@ -14,14 +37,14 @@
|
|
|
14
37
|
"serialize-javascript": "6.0.2",
|
|
15
38
|
"source-map": "~0.7.3",
|
|
16
39
|
"terser": "^5.9.0",
|
|
17
|
-
"@rushstack/worker-pool": "0.
|
|
40
|
+
"@rushstack/worker-pool": "0.7.1"
|
|
18
41
|
},
|
|
19
42
|
"devDependencies": {
|
|
20
43
|
"@types/node": "20.17.19",
|
|
21
44
|
"@types/serialize-javascript": "5.0.2",
|
|
22
45
|
"eslint": "~9.37.0",
|
|
23
|
-
"
|
|
24
|
-
"
|
|
46
|
+
"@rushstack/heft": "1.2.1",
|
|
47
|
+
"local-node-rig": "1.0.0"
|
|
25
48
|
},
|
|
26
49
|
"peerDependencies": {
|
|
27
50
|
"@types/node": "*"
|
|
@@ -31,6 +54,7 @@
|
|
|
31
54
|
"optional": true
|
|
32
55
|
}
|
|
33
56
|
},
|
|
57
|
+
"sideEffects": false,
|
|
34
58
|
"scripts": {
|
|
35
59
|
"build": "heft build --clean",
|
|
36
60
|
"_phase:build": "heft run --only build -- --clean",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|