@rushstack/heft-typescript-plugin 0.2.14 → 0.2.16
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configureProgramForMultiEmit.d.ts","sourceRoot":"","sources":["../src/configureProgramForMultiEmit.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,WAAW,MAAM,YAAY,CAAC;AAG/C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAmCrD,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,WAAW,CAAC,OAAO,EACjC,EAAE,EAAE,kBAAkB,EACtB,iBAAiB,EAAE,qBAAqB,EAAE,EAC1C,IAAI,EAAE,WAAW,GAAG,aAAa,GAAG,MAAM,GACzC;IAAE,YAAY,EAAE,GAAG,CAAC,WAAW,CAAC,UAAU,CAAC,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"configureProgramForMultiEmit.d.ts","sourceRoot":"","sources":["../src/configureProgramForMultiEmit.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,WAAW,MAAM,YAAY,CAAC;AAG/C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAmCrD,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,IAAI,EACV,YAAY,EAAE,WAAW,CAAC,OAAO,EACjC,EAAE,EAAE,kBAAkB,EACtB,iBAAiB,EAAE,qBAAqB,EAAE,EAC1C,IAAI,EAAE,WAAW,GAAG,aAAa,GAAG,MAAM,GACzC;IAAE,YAAY,EAAE,GAAG,CAAC,WAAW,CAAC,UAAU,CAAC,CAAA;CAAE,CA4I/C"}
|
|
@@ -59,9 +59,9 @@ function configureProgramForMultiEmit(innerProgram, ts, moduleKindsToEmit, mode)
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
const changedFiles = new Set();
|
|
62
|
-
program.emit = (targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) => {
|
|
62
|
+
program.emit = (targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit) => {
|
|
63
63
|
if (emitOnlyDtsFiles) {
|
|
64
|
-
return program[INNER_EMIT_SYMBOL](targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers);
|
|
64
|
+
return program[INNER_EMIT_SYMBOL](targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit);
|
|
65
65
|
}
|
|
66
66
|
if (targetSourceFile && changedFiles) {
|
|
67
67
|
changedFiles.add(targetSourceFile);
|
|
@@ -76,7 +76,7 @@ function configureProgramForMultiEmit(innerProgram, ts, moduleKindsToEmit, mode)
|
|
|
76
76
|
// Need to mutate the compiler options for the `module` field specifically, because emitWorker() captures
|
|
77
77
|
// options in the closure and passes it to `ts.getTransformers()`
|
|
78
78
|
originalCompilerOptions.module = moduleKindToEmit.moduleKind;
|
|
79
|
-
const flavorResult = program[INNER_EMIT_SYMBOL](targetSourceFile, writeFile && wrapWriteFile(writeFile, moduleKindToEmit.jsExtensionOverride), cancellationToken, emitOnlyDtsFiles, customTransformers);
|
|
79
|
+
const flavorResult = program[INNER_EMIT_SYMBOL](targetSourceFile, writeFile && wrapWriteFile(writeFile, moduleKindToEmit.jsExtensionOverride), cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit);
|
|
80
80
|
emitSkipped = emitSkipped || flavorResult.emitSkipped;
|
|
81
81
|
// Need to aggregate diagnostics because some are impacted by the target module type
|
|
82
82
|
for (const diagnostic of flavorResult.diagnostics) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configureProgramForMultiEmit.js","sourceRoot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AiB,EAC9B,WAAW,IACX;SACH;gBAAS;YACR,yEAAyE;YACzE,OAAO,CAAC,kBAAkB,GAAG,OAAO,CAAC,iCAAiC,CAAE,CAAC;YACzE,uBAAuB,CAAC,MAAM,GAAG,iBAAiB,CAAC;SACpD;IACH,CAAC,CAAC;IACF,OAAO,EAAE,YAAY,EAAE,CAAC;AAC1B,CAAC;AA7ID,oEA6IC","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 * as TTypescript from 'typescript';\nimport { InternalError } from '@rushstack/node-core-library';\n\nimport type { ExtendedTypeScript } from './internalTypings/TypeScriptInternals';\nimport type { ICachedEmitModuleKind } from './types';\n\n// symbols for attaching hidden metadata to ts.Program instances.\nconst INNER_GET_COMPILER_OPTIONS_SYMBOL: unique symbol = Symbol('getCompilerOptions');\nconst INNER_EMIT_SYMBOL: unique symbol = Symbol('emit');\n\nconst JS_EXTENSION_REGEX: RegExp = /\\.js(\\.map)?$/;\n\nfunction wrapWriteFile(\n this: void,\n baseWriteFile: TTypescript.WriteFileCallback,\n jsExtensionOverride: string | undefined\n): TTypescript.WriteFileCallback {\n if (!jsExtensionOverride) {\n return baseWriteFile;\n }\n\n const replacementExtension: string = `${jsExtensionOverride}$1`;\n return (\n fileName: string,\n data: string,\n writeBOM: boolean,\n onError?: ((message: string) => void) | undefined,\n sourceFiles?: readonly TTypescript.SourceFile[] | undefined\n ) => {\n return baseWriteFile(\n fileName.replace(JS_EXTENSION_REGEX, replacementExtension),\n data,\n writeBOM,\n onError,\n sourceFiles\n );\n };\n}\n\nexport function configureProgramForMultiEmit(\n this: void,\n innerProgram: TTypescript.Program,\n ts: ExtendedTypeScript,\n moduleKindsToEmit: ICachedEmitModuleKind[],\n mode: 'transpile' | 'declaration' | 'both'\n): { changedFiles: Set<TTypescript.SourceFile> } {\n interface IProgramWithMultiEmit extends TTypescript.Program {\n // Attach the originals to the Program instance to avoid modifying the same Program twice.\n // Don't use WeakMap because this Program could theoretically get a { ... } applied to it.\n [INNER_GET_COMPILER_OPTIONS_SYMBOL]?: TTypescript.Program['getCompilerOptions'];\n [INNER_EMIT_SYMBOL]?: TTypescript.Program['emit'];\n }\n\n const program: IProgramWithMultiEmit = innerProgram;\n\n // Check to see if this Program has already been modified.\n let { [INNER_EMIT_SYMBOL]: innerEmit, [INNER_GET_COMPILER_OPTIONS_SYMBOL]: innerGetCompilerOptions } =\n program;\n\n if (!innerGetCompilerOptions) {\n program[INNER_GET_COMPILER_OPTIONS_SYMBOL] = innerGetCompilerOptions = program.getCompilerOptions;\n }\n\n if (!innerEmit) {\n program[INNER_EMIT_SYMBOL] = innerEmit = program.emit;\n }\n\n let foundPrimary: boolean = false;\n let defaultModuleKind: TTypescript.ModuleKind;\n\n const multiEmitMap: Map<ICachedEmitModuleKind, TTypescript.CompilerOptions> = new Map();\n for (const moduleKindToEmit of moduleKindsToEmit) {\n const kindCompilerOptions: TTypescript.CompilerOptions = moduleKindToEmit.isPrimary\n ? {\n ...innerGetCompilerOptions()\n }\n : {\n ...innerGetCompilerOptions(),\n module: moduleKindToEmit.moduleKind,\n outDir: moduleKindToEmit.outFolderPath,\n\n // Don't emit declarations for secondary module kinds\n declaration: false,\n declarationMap: false\n };\n if (!kindCompilerOptions.outDir) {\n throw new InternalError('Expected compilerOptions.outDir to be assigned');\n }\n if (mode === 'transpile') {\n kindCompilerOptions.declaration = false;\n kindCompilerOptions.declarationMap = false;\n } else if (mode === 'declaration') {\n kindCompilerOptions.emitDeclarationOnly = true;\n }\n\n if (moduleKindToEmit.isPrimary || mode !== 'declaration') {\n multiEmitMap.set(moduleKindToEmit, kindCompilerOptions);\n }\n\n if (moduleKindToEmit.isPrimary) {\n if (foundPrimary) {\n throw new Error('Multiple primary module emit kinds encountered.');\n } else {\n foundPrimary = true;\n }\n\n defaultModuleKind = moduleKindToEmit.moduleKind;\n }\n }\n\n const changedFiles: Set<TTypescript.SourceFile> = new Set();\n\n program.emit = (\n targetSourceFile?: TTypescript.SourceFile,\n writeFile?: TTypescript.WriteFileCallback,\n cancellationToken?: TTypescript.CancellationToken,\n emitOnlyDtsFiles?: boolean,\n customTransformers?: TTypescript.CustomTransformers\n ) => {\n if (emitOnlyDtsFiles) {\n return program[INNER_EMIT_SYMBOL]!(\n targetSourceFile,\n writeFile,\n cancellationToken,\n emitOnlyDtsFiles,\n customTransformers\n );\n }\n\n if (targetSourceFile && changedFiles) {\n changedFiles.add(targetSourceFile);\n }\n\n const originalCompilerOptions: TTypescript.CompilerOptions =\n program[INNER_GET_COMPILER_OPTIONS_SYMBOL]!();\n\n let defaultModuleKindResult: TTypescript.EmitResult;\n const diagnostics: TTypescript.Diagnostic[] = [];\n let emitSkipped: boolean = false;\n try {\n for (const [moduleKindToEmit, kindCompilerOptions] of multiEmitMap) {\n program.getCompilerOptions = () => kindCompilerOptions;\n // Need to mutate the compiler options for the `module` field specifically, because emitWorker() captures\n // options in the closure and passes it to `ts.getTransformers()`\n originalCompilerOptions.module = moduleKindToEmit.moduleKind;\n const flavorResult: TTypescript.EmitResult = program[INNER_EMIT_SYMBOL]!(\n targetSourceFile,\n writeFile && wrapWriteFile(writeFile, moduleKindToEmit.jsExtensionOverride),\n cancellationToken,\n emitOnlyDtsFiles,\n customTransformers\n );\n\n emitSkipped = emitSkipped || flavorResult.emitSkipped;\n // Need to aggregate diagnostics because some are impacted by the target module type\n for (const diagnostic of flavorResult.diagnostics) {\n diagnostics.push(diagnostic);\n }\n\n if (moduleKindToEmit.moduleKind === defaultModuleKind) {\n defaultModuleKindResult = flavorResult;\n }\n }\n\n const mergedDiagnostics: readonly TTypescript.Diagnostic[] =\n ts.sortAndDeduplicateDiagnostics(diagnostics);\n\n return {\n ...defaultModuleKindResult!,\n changedSourceFiles: changedFiles,\n diagnostics: mergedDiagnostics,\n emitSkipped\n };\n } finally {\n // Restore the original compiler options and module kind for future calls\n program.getCompilerOptions = program[INNER_GET_COMPILER_OPTIONS_SYMBOL]!;\n originalCompilerOptions.module = defaultModuleKind;\n }\n };\n return { changedFiles };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"configureProgramForMultiEmit.js","sourceRoot":"","sources":["../src/configureProgramForMultiEmit.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AAG3D,oEAA6D;AAK7D,iEAAiE;AACjE,MAAM,iCAAiC,GAAkB,MAAM,CAAC,oBAAoB,CAAC,CAAC;AACtF,MAAM,iBAAiB,GAAkB,MAAM,CAAC,MAAM,CAAC,CAAC;AAExD,MAAM,kBAAkB,GAAW,eAAe,CAAC;AAEnD,SAAS,aAAa,CAEpB,aAA4C,EAC5C,mBAAuC;IAEvC,IAAI,CAAC,mBAAmB,EAAE;QACxB,OAAO,aAAa,CAAC;KACtB;IAED,MAAM,oBAAoB,GAAW,GAAG,mBAAmB,IAAI,CAAC;IAChE,OAAO,CACL,QAAgB,EAChB,IAAY,EACZ,QAAiB,EACjB,OAAiD,EACjD,WAA2D,EAC3D,EAAE;QACF,OAAO,aAAa,CAClB,QAAQ,CAAC,OAAO,CAAC,kBAAkB,EAAE,oBAAoB,CAAC,EAC1D,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,WAAW,CACZ,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAED,SAAgB,4BAA4B,CAE1C,YAAiC,EACjC,EAAsB,EACtB,iBAA0C,EAC1C,IAA0C;IAW1C,MAAM,OAAO,GAA0B,YAAY,CAAC;IAEpD,0DAA0D;IAC1D,IAAI,EAAE,CAAC,iBAAiB,CAAC,EAAE,SAAS,EAAE,CAAC,iCAAiC,CAAC,EAAE,uBAAuB,EAAE,GAClG,OAAO,CAAC;IAEV,IAAI,CAAC,uBAAuB,EAAE;QAC5B,OAAO,CAAC,iCAAiC,CAAC,GAAG,uBAAuB,GAAG,OAAO,CAAC,kBAAkB,CAAC;KACnG;IAED,IAAI,CAAC,SAAS,EAAE;QACd,OAAO,CAAC,iBAAiB,CAAC,GAAG,SAAS,GAAG,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AAM,iBAAiB,GACrB,EAAE,CAAC,6BAA6B,CAAC,WAAW,CAAC,CAAC;YAEhD,uCACK,uBAAwB,KAC3B,kBAAkB,EAAE,YAAY,EAChC,WAAW,EAAE,iBAAiB,EAC9B,WAAW,IACX;SACH;gBAAS;YACR,yEAAyE;YACzE,OAAO,CAAC,kBAAkB,GAAG,OAAO,CAAC,iCAAiC,CAAE,CAAC;YACzE,uBAAuB,CAAC,MAAM,GAAG,iBAAiB,CAAC;SACpD;IACH,CAAC,CAAC;IACF,OAAO,EAAE,YAAY,EAAE,CAAC;AAC1B,CAAC;AAlJD,oEAkJC","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 * as TTypescript from 'typescript';\nimport { InternalError } from '@rushstack/node-core-library';\n\nimport type { ExtendedTypeScript } from './internalTypings/TypeScriptInternals';\nimport type { ICachedEmitModuleKind } from './types';\n\n// symbols for attaching hidden metadata to ts.Program instances.\nconst INNER_GET_COMPILER_OPTIONS_SYMBOL: unique symbol = Symbol('getCompilerOptions');\nconst INNER_EMIT_SYMBOL: unique symbol = Symbol('emit');\n\nconst JS_EXTENSION_REGEX: RegExp = /\\.js(\\.map)?$/;\n\nfunction wrapWriteFile(\n this: void,\n baseWriteFile: TTypescript.WriteFileCallback,\n jsExtensionOverride: string | undefined\n): TTypescript.WriteFileCallback {\n if (!jsExtensionOverride) {\n return baseWriteFile;\n }\n\n const replacementExtension: string = `${jsExtensionOverride}$1`;\n return (\n fileName: string,\n data: string,\n writeBOM: boolean,\n onError?: ((message: string) => void) | undefined,\n sourceFiles?: readonly TTypescript.SourceFile[] | undefined\n ) => {\n return baseWriteFile(\n fileName.replace(JS_EXTENSION_REGEX, replacementExtension),\n data,\n writeBOM,\n onError,\n sourceFiles\n );\n };\n}\n\nexport function configureProgramForMultiEmit(\n this: void,\n innerProgram: TTypescript.Program,\n ts: ExtendedTypeScript,\n moduleKindsToEmit: ICachedEmitModuleKind[],\n mode: 'transpile' | 'declaration' | 'both'\n): { changedFiles: Set<TTypescript.SourceFile> } {\n interface IProgramWithMultiEmit extends TTypescript.Program {\n // Attach the originals to the Program instance to avoid modifying the same Program twice.\n // Don't use WeakMap because this Program could theoretically get a { ... } applied to it.\n [INNER_GET_COMPILER_OPTIONS_SYMBOL]?: TTypescript.Program['getCompilerOptions'];\n [INNER_EMIT_SYMBOL]?: // https://github.com/microsoft/TypeScript/blob/88cb76d314a93937ce8d9543114ccbad993be6d1/src/compiler/program.ts#L2697-L2698\n // There is a \"forceDtsEmit\" parameter that is not on the published types.\n (...args: [...Parameters<TTypescript.Program['emit']>, boolean | undefined]) => TTypescript.EmitResult;\n }\n\n const program: IProgramWithMultiEmit = innerProgram;\n\n // Check to see if this Program has already been modified.\n let { [INNER_EMIT_SYMBOL]: innerEmit, [INNER_GET_COMPILER_OPTIONS_SYMBOL]: innerGetCompilerOptions } =\n program;\n\n if (!innerGetCompilerOptions) {\n program[INNER_GET_COMPILER_OPTIONS_SYMBOL] = innerGetCompilerOptions = program.getCompilerOptions;\n }\n\n if (!innerEmit) {\n program[INNER_EMIT_SYMBOL] = innerEmit = program.emit;\n }\n\n let foundPrimary: boolean = false;\n let defaultModuleKind: TTypescript.ModuleKind;\n\n const multiEmitMap: Map<ICachedEmitModuleKind, TTypescript.CompilerOptions> = new Map();\n for (const moduleKindToEmit of moduleKindsToEmit) {\n const kindCompilerOptions: TTypescript.CompilerOptions = moduleKindToEmit.isPrimary\n ? {\n ...innerGetCompilerOptions()\n }\n : {\n ...innerGetCompilerOptions(),\n module: moduleKindToEmit.moduleKind,\n outDir: moduleKindToEmit.outFolderPath,\n\n // Don't emit declarations for secondary module kinds\n declaration: false,\n declarationMap: false\n };\n if (!kindCompilerOptions.outDir) {\n throw new InternalError('Expected compilerOptions.outDir to be assigned');\n }\n if (mode === 'transpile') {\n kindCompilerOptions.declaration = false;\n kindCompilerOptions.declarationMap = false;\n } else if (mode === 'declaration') {\n kindCompilerOptions.emitDeclarationOnly = true;\n }\n\n if (moduleKindToEmit.isPrimary || mode !== 'declaration') {\n multiEmitMap.set(moduleKindToEmit, kindCompilerOptions);\n }\n\n if (moduleKindToEmit.isPrimary) {\n if (foundPrimary) {\n throw new Error('Multiple primary module emit kinds encountered.');\n } else {\n foundPrimary = true;\n }\n\n defaultModuleKind = moduleKindToEmit.moduleKind;\n }\n }\n\n const changedFiles: Set<TTypescript.SourceFile> = new Set();\n\n program.emit = (\n targetSourceFile?: TTypescript.SourceFile,\n writeFile?: TTypescript.WriteFileCallback,\n cancellationToken?: TTypescript.CancellationToken,\n emitOnlyDtsFiles?: boolean,\n customTransformers?: TTypescript.CustomTransformers,\n forceDtsEmit?: boolean\n ) => {\n if (emitOnlyDtsFiles) {\n return program[INNER_EMIT_SYMBOL]!(\n targetSourceFile,\n writeFile,\n cancellationToken,\n emitOnlyDtsFiles,\n customTransformers,\n forceDtsEmit\n );\n }\n\n if (targetSourceFile && changedFiles) {\n changedFiles.add(targetSourceFile);\n }\n\n const originalCompilerOptions: TTypescript.CompilerOptions =\n program[INNER_GET_COMPILER_OPTIONS_SYMBOL]!();\n\n let defaultModuleKindResult: TTypescript.EmitResult;\n const diagnostics: TTypescript.Diagnostic[] = [];\n let emitSkipped: boolean = false;\n try {\n for (const [moduleKindToEmit, kindCompilerOptions] of multiEmitMap) {\n program.getCompilerOptions = () => kindCompilerOptions;\n // Need to mutate the compiler options for the `module` field specifically, because emitWorker() captures\n // options in the closure and passes it to `ts.getTransformers()`\n originalCompilerOptions.module = moduleKindToEmit.moduleKind;\n const flavorResult: TTypescript.EmitResult = program[INNER_EMIT_SYMBOL]!(\n targetSourceFile,\n writeFile && wrapWriteFile(writeFile, moduleKindToEmit.jsExtensionOverride),\n cancellationToken,\n emitOnlyDtsFiles,\n customTransformers,\n forceDtsEmit\n );\n\n emitSkipped = emitSkipped || flavorResult.emitSkipped;\n // Need to aggregate diagnostics because some are impacted by the target module type\n for (const diagnostic of flavorResult.diagnostics) {\n diagnostics.push(diagnostic);\n }\n\n if (moduleKindToEmit.moduleKind === defaultModuleKind) {\n defaultModuleKindResult = flavorResult;\n }\n }\n\n const mergedDiagnostics: readonly TTypescript.Diagnostic[] =\n ts.sortAndDeduplicateDiagnostics(diagnostics);\n\n return {\n ...defaultModuleKindResult!,\n changedSourceFiles: changedFiles,\n diagnostics: mergedDiagnostics,\n emitSkipped\n };\n } finally {\n // Restore the original compiler options and module kind for future calls\n program.getCompilerOptions = program[INNER_GET_COMPILER_OPTIONS_SYMBOL]!;\n originalCompilerOptions.module = defaultModuleKind;\n }\n };\n return { changedFiles };\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rushstack/heft-typescript-plugin",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.16",
|
|
4
4
|
"description": "Heft plugin for TypeScript",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -12,22 +12,22 @@
|
|
|
12
12
|
"types": "dist/heft-typescript-plugin.d.ts",
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"peerDependencies": {
|
|
15
|
-
"@rushstack/heft": "0.63.
|
|
15
|
+
"@rushstack/heft": "0.63.6"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@types/tapable": "1.0.6",
|
|
19
19
|
"semver": "~7.5.4",
|
|
20
20
|
"tapable": "1.1.3",
|
|
21
|
-
"@rushstack/
|
|
22
|
-
"@rushstack/
|
|
21
|
+
"@rushstack/node-core-library": "3.63.0",
|
|
22
|
+
"@rushstack/heft-config-file": "0.14.4"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@rushstack/heft-node-rig": "2.3.2",
|
|
26
26
|
"@types/node": "18.17.15",
|
|
27
27
|
"@types/semver": "7.5.0",
|
|
28
28
|
"typescript": "~5.0.4",
|
|
29
|
-
"
|
|
30
|
-
"
|
|
29
|
+
"@rushstack/heft": "0.63.6",
|
|
30
|
+
"local-eslint-config": "1.0.0"
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|
|
33
33
|
"build": "heft test --clean",
|