@rushstack/module-minifier 0.4.37 → 0.4.39

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.
@@ -1,9 +1,4 @@
1
1
  import { type MinifyOptions } from 'terser';
2
- declare module 'terser' {
3
- interface SourceMapOptions {
4
- asObject?: boolean;
5
- }
6
- }
7
2
  import type { IModuleMinificationRequest, IModuleMinificationResult } from './types';
8
3
  /**
9
4
  * Minifies a single chunk of code. Factored out for reuse between WorkerPoolMinifier and LocalMinifier
@@ -1 +1 @@
1
- {"version":3,"file":"MinifySingleFile.d.ts","sourceRoot":"","sources":["../src/MinifySingleFile.ts"],"names":[],"mappings":"AAGA,OAAO,EAAU,KAAK,aAAa,EAAmD,MAAM,QAAQ,CAAC;AAGrG,OAAO,QAAQ,QAAQ,CAAC;IAEtB,UAAU,gBAAgB;QACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;KACpB;CACF;AAGD,OAAO,KAAK,EAAE,0BAA0B,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAMrF;;;GAGG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,0BAA0B,EACnC,aAAa,EAAE,aAAa,GAC3B,OAAO,CAAC,yBAAyB,CAAC,CA4DpC"}
1
+ {"version":3,"file":"MinifySingleFile.d.ts","sourceRoot":"","sources":["../src/MinifySingleFile.ts"],"names":[],"mappings":"AAGA,OAAO,EAAU,KAAK,aAAa,EAAmD,MAAM,QAAQ,CAAC;AAIrG,OAAO,KAAK,EAAE,0BAA0B,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AAMrF;;;GAGG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,0BAA0B,EACnC,aAAa,EAAE,aAAa,GAC3B,OAAO,CAAC,yBAAyB,CAAC,CAgEpC"}
@@ -30,11 +30,16 @@ async function minifySingleFileAsync(request, terserOptions) {
30
30
  if (mangle && externals) {
31
31
  mangle.reserved = mangle.reserved ? externals.concat(mangle.reserved) : externals;
32
32
  }
33
- finalOptions.sourceMap = nameForMap
34
- ? {
33
+ // SourceMap is only generated if nameForMap is provided- overrides terserOptions.sourceMap
34
+ if (nameForMap) {
35
+ finalOptions.sourceMap = {
36
+ includeSources: true,
35
37
  asObject: true
36
- }
37
- : false;
38
+ };
39
+ }
40
+ else {
41
+ finalOptions.sourceMap = false;
42
+ }
38
43
  const minified = await (0, terser_1.minify)({
39
44
  [nameForMap || 'code']: code
40
45
  }, finalOptions);
@@ -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,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,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;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;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;AAGrG,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,CAAC;QACH,MAAM,EACJ,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,SAAS,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ACf,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;AAnED,sDAmEC","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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rushstack/module-minifier",
3
- "version": "0.4.37",
3
+ "version": "0.4.39",
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,12 +14,12 @@
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.37"
17
+ "@rushstack/worker-pool": "0.4.38"
18
18
  },
19
19
  "devDependencies": {
20
20
  "@types/serialize-javascript": "5.0.2",
21
- "local-node-rig": "1.0.0",
22
- "@rushstack/heft": "0.66.0"
21
+ "@rushstack/heft": "0.66.1",
22
+ "local-node-rig": "1.0.0"
23
23
  },
24
24
  "peerDependencies": {
25
25
  "@types/node": "*"