| import type * as ts from 'typescript'; | ||
| import type { CustomTransformers, Diagnostic, Program } from 'typescript'; | ||
| export interface TypeScriptCompilationOptions { | ||
| outputPath: string; | ||
| projectName: string; | ||
| projectRoot: string; | ||
| tsConfig: string; | ||
| deleteOutputPath?: boolean; | ||
| rootDir?: string; | ||
| watch?: boolean; | ||
| getCustomTransformers?(program: Program): CustomTransformers; | ||
| } | ||
| export interface TypescriptWatchChangeEvent { | ||
| diagnostic: ts.Diagnostic; | ||
| newLine: string; | ||
| options: ts.CompilerOptions; | ||
| errorCount: number; | ||
| } | ||
| export declare function compileTypeScript(options: TypeScriptCompilationOptions): { | ||
| success: boolean; | ||
| }; | ||
| export declare function compileTypeScriptWatcher(options: TypeScriptCompilationOptions, callback: (diagnostic: Diagnostic, newLine: string, options: ts.CompilerOptions, errorCount: number) => void | Promise<void>): ts.WatchOfFilesAndCompilerOptions<ts.BuilderProgram>; | ||
| //# sourceMappingURL=compilation.d.ts.map |
| {"version":3,"file":"compilation.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/utils/typescript/compilation.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,EAAE,kBAAkB,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAM1E,MAAM,WAAW,4BAA4B;IAC3C,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,qBAAqB,CAAC,CAAC,OAAO,EAAE,OAAO,GAAG,kBAAkB,CAAC;CAC9D;AAED,MAAM,WAAW,0BAA0B;IACzC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,EAAE,CAAC,eAAe,CAAC;IAC5B,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,4BAA4B,GAAG;IACxE,OAAO,EAAE,OAAO,CAAC;CAClB,CASA;AAED,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,4BAA4B,EACrC,QAAQ,EAAE,CACR,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,EAAE,CAAC,eAAe,EAC3B,UAAU,EAAE,MAAM,KACf,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,wDAwD1B"} |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.compileTypeScript = compileTypeScript; | ||
| exports.compileTypeScriptWatcher = compileTypeScriptWatcher; | ||
| const devkit_1 = require("@nx/devkit"); | ||
| const fs_1 = require("fs"); | ||
| const ts_config_1 = require("./ts-config"); | ||
| const ensure_typescript_1 = require("./ensure-typescript"); | ||
| let tsModule; | ||
| function compileTypeScript(options) { | ||
| const normalizedOptions = normalizeOptions(options); | ||
| const tsConfig = getNormalizedTsConfig(normalizedOptions); | ||
| if (normalizedOptions.deleteOutputPath) { | ||
| (0, fs_1.rmSync)(normalizedOptions.outputPath, { recursive: true, force: true }); | ||
| } | ||
| return createProgram(tsConfig, normalizedOptions); | ||
| } | ||
| function compileTypeScriptWatcher(options, callback) { | ||
| if (!tsModule) { | ||
| tsModule = (0, ensure_typescript_1.ensureTypescript)(); | ||
| } | ||
| const normalizedOptions = normalizeOptions(options); | ||
| const tsConfig = getNormalizedTsConfig(normalizedOptions); | ||
| if (normalizedOptions.deleteOutputPath) { | ||
| (0, fs_1.rmSync)(normalizedOptions.outputPath, { recursive: true, force: true }); | ||
| } | ||
| const host = tsModule.createWatchCompilerHost(tsConfig.fileNames, tsConfig.options, tsModule.sys); | ||
| const originalAfterProgramCreate = host.afterProgramCreate; | ||
| host.afterProgramCreate = (builderProgram) => { | ||
| const originalProgramEmit = builderProgram.emit; | ||
| builderProgram.emit = (targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) => { | ||
| const consumerCustomTransformers = options.getCustomTransformers?.(builderProgram.getProgram()); | ||
| const mergedCustomTransformers = mergeCustomTransformers(customTransformers, consumerCustomTransformers); | ||
| return originalProgramEmit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, mergedCustomTransformers); | ||
| }; | ||
| if (originalAfterProgramCreate) | ||
| originalAfterProgramCreate(builderProgram); | ||
| }; | ||
| const originalOnWatchStatusChange = host.onWatchStatusChange; | ||
| host.onWatchStatusChange = async (a, b, c, d) => { | ||
| originalOnWatchStatusChange?.(a, b, c, d); | ||
| await callback?.(a, b, c, d); | ||
| }; | ||
| return tsModule.createWatchProgram(host); | ||
| } | ||
| function mergeCustomTransformers(originalCustomTransformers, consumerCustomTransformers) { | ||
| if (!consumerCustomTransformers) | ||
| return originalCustomTransformers; | ||
| const mergedCustomTransformers = {}; | ||
| if (consumerCustomTransformers.before) { | ||
| mergedCustomTransformers.before = originalCustomTransformers?.before | ||
| ? [ | ||
| ...originalCustomTransformers.before, | ||
| ...consumerCustomTransformers.before, | ||
| ] | ||
| : consumerCustomTransformers.before; | ||
| } | ||
| if (consumerCustomTransformers.after) { | ||
| mergedCustomTransformers.after = originalCustomTransformers?.after | ||
| ? [ | ||
| ...originalCustomTransformers.after, | ||
| ...consumerCustomTransformers.after, | ||
| ] | ||
| : consumerCustomTransformers.after; | ||
| } | ||
| if (consumerCustomTransformers.afterDeclarations) { | ||
| mergedCustomTransformers.afterDeclarations = | ||
| originalCustomTransformers?.afterDeclarations | ||
| ? [ | ||
| ...originalCustomTransformers.afterDeclarations, | ||
| ...consumerCustomTransformers.afterDeclarations, | ||
| ] | ||
| : consumerCustomTransformers.afterDeclarations; | ||
| } | ||
| return mergedCustomTransformers; | ||
| } | ||
| function getNormalizedTsConfig(options) { | ||
| const tsConfig = (0, ts_config_1.readTsConfig)(options.tsConfig); | ||
| tsConfig.options.outDir = options.outputPath; | ||
| tsConfig.options.noEmitOnError = true; | ||
| tsConfig.options.rootDir = options.rootDir; | ||
| if (tsConfig.options.incremental && !tsConfig.options.tsBuildInfoFile) { | ||
| tsConfig.options.tsBuildInfoFile = (0, devkit_1.joinPathFragments)(options.outputPath, 'tsconfig.tsbuildinfo'); | ||
| } | ||
| return tsConfig; | ||
| } | ||
| function createProgram(tsconfig, { projectName, getCustomTransformers }) { | ||
| if (!tsModule) { | ||
| tsModule = (0, ensure_typescript_1.ensureTypescript)(); | ||
| } | ||
| const host = tsModule.createCompilerHost(tsconfig.options); | ||
| const program = tsModule.createProgram({ | ||
| rootNames: tsconfig.fileNames, | ||
| options: tsconfig.options, | ||
| host, | ||
| }); | ||
| devkit_1.logger.info(`Compiling TypeScript files for project "${projectName}"...`); | ||
| const results = program.emit(undefined, undefined, undefined, undefined, getCustomTransformers?.(program)); | ||
| if (results.emitSkipped) { | ||
| const diagnostics = tsModule.formatDiagnosticsWithColorAndContext(results.diagnostics, { | ||
| getCurrentDirectory: () => tsModule.sys.getCurrentDirectory(), | ||
| getNewLine: () => tsModule.sys.newLine, | ||
| getCanonicalFileName: (name) => name, | ||
| }); | ||
| devkit_1.logger.error(diagnostics); | ||
| return { success: false }; | ||
| } | ||
| else { | ||
| devkit_1.logger.info(`Done compiling TypeScript files for project "${projectName}".`); | ||
| return { success: true }; | ||
| } | ||
| } | ||
| function normalizeOptions(options) { | ||
| return { | ||
| ...options, | ||
| deleteOutputPath: options.deleteOutputPath ?? true, | ||
| rootDir: options.rootDir ?? options.projectRoot, | ||
| }; | ||
| } |
+5
-5
| { | ||
| "name": "@nx/js", | ||
| "version": "23.0.0-beta.9", | ||
| "version": "23.0.0-beta.10", | ||
| "private": false, | ||
@@ -43,4 +43,4 @@ "description": "The JS plugin for Nx contains executors and generators that provide the best experience for developing JavaScript and TypeScript projects. ", | ||
| "@babel/runtime": "^7.22.6", | ||
| "@nx/devkit": "23.0.0-beta.9", | ||
| "@nx/workspace": "23.0.0-beta.9", | ||
| "@nx/devkit": "23.0.0-beta.10", | ||
| "@nx/workspace": "23.0.0-beta.10", | ||
| "@zkochan/js-yaml": "0.0.7", | ||
@@ -55,3 +55,3 @@ "babel-plugin-const-enum": "^1.0.1", | ||
| "js-tokens": "^4.0.0", | ||
| "jsonc-parser": "3.2.0", | ||
| "jsonc-parser": "^3.2.0", | ||
| "npm-run-path": "^4.0.1", | ||
@@ -66,3 +66,3 @@ "picocolors": "^1.1.0", | ||
| "devDependencies": { | ||
| "nx": "23.0.0-beta.9" | ||
| "nx": "23.0.0-beta.10" | ||
| }, | ||
@@ -69,0 +69,0 @@ "peerDependencies": { |
| import { ExecutorContext } from '@nx/devkit'; | ||
| import type { TypeScriptCompilationOptions } from '@nx/workspace/src/utilities/typescript/compilation'; | ||
| import type { TypeScriptCompilationOptions } from '../../utils/typescript/compilation'; | ||
| import { ExecutorOptions, NormalizedExecutorOptions } from '../../utils/schema'; | ||
@@ -4,0 +4,0 @@ export declare function determineModuleFormatFromTsConfig(absolutePathToTsConfig: string, projectRoot?: string, workspaceRoot?: string): 'cjs' | 'esm'; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"tsc.impl.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/executors/tsc/tsc.impl.ts"],"names":[],"mappings":"AACA,OAAO,EACL,eAAe,EAKhB,MAAM,YAAY,CAAC;AAGpB,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,oDAAoD,CAAC;AAQvG,OAAO,EAAE,eAAe,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAOhF,wBAAgB,iCAAiC,CAC/C,sBAAsB,EAAE,MAAM,EAC9B,WAAW,CAAC,EAAE,MAAM,EACpB,aAAa,CAAC,EAAE,MAAM,GACrB,KAAK,GAAG,KAAK,CAkCf;AAED,wBAAgB,kCAAkC,CAChD,iBAAiB,EAAE,yBAAyB,EAC5C,OAAO,EAAE,eAAe,GACvB,4BAA4B,CAa9B;AAED,wBAAuB,WAAW,CAChC,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,eAAe,mHAqHzB;AAED,eAAe,WAAW,CAAC"} | ||
| {"version":3,"file":"tsc.impl.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/executors/tsc/tsc.impl.ts"],"names":[],"mappings":"AACA,OAAO,EACL,eAAe,EAKhB,MAAM,YAAY,CAAC;AAGpB,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,oCAAoC,CAAC;AAQvF,OAAO,EAAE,eAAe,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAOhF,wBAAgB,iCAAiC,CAC/C,sBAAsB,EAAE,MAAM,EAC9B,WAAW,CAAC,EAAE,MAAM,EACpB,aAAa,CAAC,EAAE,MAAM,GACrB,KAAK,GAAG,KAAK,CAkCf;AAED,wBAAgB,kCAAkC,CAChD,iBAAiB,EAAE,yBAAyB,EAC5C,OAAO,EAAE,eAAe,GACvB,4BAA4B,CAa9B;AAED,wBAAuB,WAAW,CAChC,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,eAAe,mHAqHzB;AAED,eAAe,WAAW,CAAC"} |
@@ -1,2 +0,2 @@ | ||
| import { TypeScriptCompilationOptions } from '@nx/workspace/src/utilities/typescript/compilation'; | ||
| import { TypeScriptCompilationOptions } from './compilation'; | ||
| import { NormalizedExecutorOptions } from '../schema'; | ||
@@ -3,0 +3,0 @@ export interface TypescriptCompilationResult { |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"compile-typescript-files.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/utils/typescript/compile-typescript-files.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,4BAA4B,EAC7B,MAAM,oDAAoD,CAAC;AAE5D,OAAO,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AAWtD,MAAM,WAAW,2BAA2B;IAC1C,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,sBAAsB,CACpC,iBAAiB,EAAE,yBAAyB,EAC5C,UAAU,EAAE,4BAA4B,EACxC,uBAAuB,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAClD;IACD,QAAQ,EAAE,aAAa,CAAC,2BAA2B,CAAC,CAAC;IACrD,KAAK,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACnC,CA0CA"} | ||
| {"version":3,"file":"compile-typescript-files.d.ts","sourceRoot":"","sources":["../../../../../../packages/js/src/utils/typescript/compile-typescript-files.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,4BAA4B,EAC7B,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AAWtD,MAAM,WAAW,2BAA2B;IAC1C,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,sBAAsB,CACpC,iBAAiB,EAAE,yBAAyB,EAC5C,UAAU,EAAE,4BAA4B,EACxC,uBAAuB,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAClD;IACD,QAAQ,EAAE,aAAa,CAAC,2BAA2B,CAAC,CAAC;IACrD,KAAK,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACnC,CA0CA"} |
@@ -5,3 +5,3 @@ "use strict"; | ||
| const internal_1 = require("@nx/devkit/internal"); | ||
| const compilation_1 = require("@nx/workspace/src/utilities/typescript/compilation"); | ||
| const compilation_1 = require("./compilation"); | ||
| const TYPESCRIPT_FOUND_N_ERRORS_WATCHING_FOR_FILE_CHANGES = 6194; | ||
@@ -8,0 +8,0 @@ // Typescript diagnostic message for 6194: Found {0} errors. Watching for file changes. |
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 20 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 20 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
664810
1.1%374
0.81%13375
1.07%64
1.59%+ Added
+ Added
+ Added
- Removed
- Removed
Updated
Updated
Updated