jsii 6.0.22-dev.1 → 7.1.0-dev.2

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.
Files changed (107) hide show
  1. package/lib/assembler.d.ts +254 -196
  2. package/lib/assembler.js +2105 -2327
  3. package/lib/assembler.js.map +1 -1
  4. package/lib/case.js.map +1 -1
  5. package/lib/common/find-utils.js.map +1 -1
  6. package/lib/common/index.d.ts +1 -1
  7. package/lib/common/index.js +2 -1
  8. package/lib/common/index.js.map +1 -1
  9. package/lib/common/symbol-id.d.ts +23 -4
  10. package/lib/common/symbol-id.js +13 -9
  11. package/lib/common/symbol-id.js.map +1 -1
  12. package/lib/compiler-host.d.ts +60 -0
  13. package/lib/compiler-host.js +201 -0
  14. package/lib/compiler-host.js.map +1 -0
  15. package/lib/compiler.d.ts +74 -62
  16. package/lib/compiler.js +332 -254
  17. package/lib/compiler.js.map +1 -1
  18. package/lib/diagnostic.d.ts +34 -0
  19. package/lib/diagnostic.js +141 -0
  20. package/lib/diagnostic.js.map +1 -0
  21. package/lib/emitter.d.ts +40 -10
  22. package/lib/emitter.js +188 -0
  23. package/lib/emitter.js.map +1 -1
  24. package/lib/helpers.d.ts +1 -1
  25. package/lib/helpers.js +2 -2
  26. package/lib/helpers.js.map +1 -1
  27. package/lib/index.js.map +1 -1
  28. package/lib/jsii-diagnostic.d.ts +27 -22
  29. package/lib/jsii-diagnostic.js +22 -38
  30. package/lib/jsii-diagnostic.js.map +1 -1
  31. package/lib/literate.js.map +1 -1
  32. package/lib/main.js +3 -2
  33. package/lib/main.js.map +1 -1
  34. package/lib/project-info.d.ts +23 -4
  35. package/lib/project-info.js +5 -5
  36. package/lib/project-info.js.map +1 -1
  37. package/lib/support-types.d.ts +2 -0
  38. package/lib/support-types.js +3 -0
  39. package/lib/support-types.js.map +1 -0
  40. package/lib/support.js.map +1 -1
  41. package/lib/tsconfig/compiler-options.d.ts +12 -46
  42. package/lib/tsconfig/compiler-options.js +45 -87
  43. package/lib/tsconfig/compiler-options.js.map +1 -1
  44. package/lib/tsconfig/index.d.ts +24 -5
  45. package/lib/tsconfig/index.js.map +1 -1
  46. package/lib/tsconfig/read.d.ts +15 -0
  47. package/lib/tsconfig/read.js +196 -0
  48. package/lib/tsconfig/read.js.map +1 -0
  49. package/lib/tsconfig/rule-set-format.js.map +1 -1
  50. package/lib/tsconfig/rulesets/configurable-options.js.map +1 -1
  51. package/lib/tsconfig/rulesets/deprecated-options.js.map +1 -1
  52. package/lib/tsconfig/rulesets/generated.public.js.map +1 -1
  53. package/lib/tsconfig/rulesets/incompatible-options.js.map +1 -1
  54. package/lib/tsconfig/rulesets/jsii-configured-options.js.map +1 -1
  55. package/lib/tsconfig/rulesets/minimal.public.js.map +1 -1
  56. package/lib/tsconfig/rulesets/strict-family-options.js.map +1 -1
  57. package/lib/tsconfig/rulesets/strict.public.js.map +1 -1
  58. package/lib/tsconfig/tsconfig-validator.js +2 -50
  59. package/lib/tsconfig/tsconfig-validator.js.map +1 -1
  60. package/lib/tsconfig/validator.js.map +1 -1
  61. package/lib/type-analysis.js.map +1 -1
  62. package/lib/type-reference.js.map +1 -1
  63. package/lib/type-visitor.js.map +1 -1
  64. package/lib/utils.d.ts +6 -6
  65. package/lib/utils.js +8 -13
  66. package/lib/utils.js.map +1 -1
  67. package/lib/version.d.ts +3 -3
  68. package/lib/version.js +4 -4
  69. package/lib/version.js.map +1 -1
  70. package/lib/warnings.d.ts +2 -2
  71. package/lib/warnings.js +3 -77
  72. package/lib/warnings.js.map +1 -1
  73. package/package.json +15 -11
  74. package/scripts/ts7-compare-jsii.mjs +101 -0
  75. package/lib/directives.d.ts +0 -24
  76. package/lib/directives.js +0 -139
  77. package/lib/directives.js.map +0 -1
  78. package/lib/docs.d.ts +0 -64
  79. package/lib/docs.js +0 -293
  80. package/lib/docs.js.map +0 -1
  81. package/lib/node-bindings.d.ts +0 -19
  82. package/lib/node-bindings.js +0 -49
  83. package/lib/node-bindings.js.map +0 -1
  84. package/lib/reserved-words.d.ts +0 -6
  85. package/lib/reserved-words.js +0 -258
  86. package/lib/reserved-words.js.map +0 -1
  87. package/lib/sets.d.ts +0 -16
  88. package/lib/sets.js +0 -41
  89. package/lib/sets.js.map +0 -1
  90. package/lib/transforms/deprecated-remover.d.ts +0 -44
  91. package/lib/transforms/deprecated-remover.js +0 -545
  92. package/lib/transforms/deprecated-remover.js.map +0 -1
  93. package/lib/transforms/deprecation-warnings.d.ts +0 -37
  94. package/lib/transforms/deprecation-warnings.js +0 -616
  95. package/lib/transforms/deprecation-warnings.js.map +0 -1
  96. package/lib/transforms/runtime-info.d.ts +0 -39
  97. package/lib/transforms/runtime-info.js +0 -128
  98. package/lib/transforms/runtime-info.js.map +0 -1
  99. package/lib/transforms/utils.d.ts +0 -11
  100. package/lib/transforms/utils.js +0 -31
  101. package/lib/transforms/utils.js.map +0 -1
  102. package/lib/type-tracker.d.ts +0 -13
  103. package/lib/type-tracker.js +0 -67
  104. package/lib/type-tracker.js.map +0 -1
  105. package/lib/validator.d.ts +0 -19
  106. package/lib/validator.js +0 -602
  107. package/lib/validator.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"compiler.js","sourceRoot":"","sources":["../src/compiler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAA8B;AAC9B,gDAAkC;AAClC,kDAA0B;AAC1B,+CAAiC;AACjC,+CAAiC;AAEjC,2CAAwC;AACxC,oDAA8D;AAE9D,uDAAmD;AAEnD,4EAA2E;AAC3E,yCAAiF;AACjF,kEAAoF;AACpF,sEAA0E;AAC1E,oDAAuD;AACvD,+CAAiC;AACjC,yCAAwC;AAExC,MAAM,GAAG,GAAG,MAAM,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;AACjC,QAAA,WAAW,GAAG,aAAa,CAAC;AAC5B,QAAA,qBAAqB,GAAG,IAAI,CAAC;AA0C1C,MAAa,QAAQ;IASiB;IARnB,MAAM,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CAAC;QACzE,CAAC;QACD,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;QACjC,yBAAyB,EAAE,IAAI,CAAC,yBAAyB,EAAE;QAC3D,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,KAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS;KACtD,CAAC;AACJ,CAAC","sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport chalk from 'chalk';\nimport * as log4js from 'log4js';\nimport * as ts from 'typescript';\n\nimport { Assembler } from './assembler';\nimport { findDependencyDirectory } from './common/find-utils';\nimport { Emitter } from './emitter';\nimport { JsiiDiagnostic } from './jsii-diagnostic';\nimport { ProjectInfo } from './project-info';\nimport { WARNINGSCODE_FILE_NAME } from './transforms/deprecation-warnings';\nimport { TypeScriptConfig, TypeScriptConfigValidationRuleSet } from './tsconfig';\nimport { BASE_COMPILER_OPTIONS, convertForJson } from './tsconfig/compiler-options';\nimport { TypeScriptConfigValidator } from './tsconfig/tsconfig-validator';\nimport { ValidationError } from './tsconfig/validator';\nimport * as utils from './utils';\nimport { isSilenced } from './warnings';\n\nconst LOG = log4js.getLogger('jsii/compiler');\nexport const DIAGNOSTICS = 'diagnostics';\nexport const JSII_DIAGNOSTICS_CODE = 9999;\n\nexport interface CompilerOptions {\n /** The information about the project to be built */\n projectInfo: ProjectInfo;\n /** Whether the compiler should watch for changes or just compile once */\n watch?: boolean;\n /** Whether to detect and generate TypeScript project references */\n projectReferences?: boolean;\n /** Whether to fail when a warning is emitted */\n failOnWarnings?: boolean;\n /** Whether to strip deprecated members from emitted artifacts */\n stripDeprecated?: boolean;\n /** The path to an allowlist of FQNs to strip if stripDeprecated is set */\n stripDeprecatedAllowListFile?: string;\n /** Whether to add warnings for deprecated elements */\n addDeprecationWarnings?: boolean;\n /**\n * The name of the tsconfig file to generate.\n * Cannot be used at the same time as `typeScriptConfig`.\n * @default \"tsconfig.json\"\n */\n generateTypeScriptConfig?: string;\n /**\n * The name of the tsconfig file to use.\n * Cannot be used at the same time as `generateTypeScriptConfig`.\n * @default - generate the tsconfig file\n */\n typeScriptConfig?: string;\n /**\n * The ruleset to validate the provided tsconfig file against.\n * Can only be used when `typeScriptConfig` is provided.\n * @default TypeScriptConfigValidationRuleSet.STRICT - if `typeScriptConfig` is provided\n */\n validateTypeScriptConfig?: TypeScriptConfigValidationRuleSet;\n /**\n * Whether to compress the assembly\n * @default false\n */\n compressAssembly?: boolean;\n}\n\nexport class Compiler implements Emitter {\n private readonly system: ts.System;\n private readonly compilerHost: ts.CompilerHost;\n private readonly userProvidedTypeScriptConfig: boolean;\n private readonly tsconfig: TypeScriptConfig;\n private rootFiles: string[] = [];\n private readonly configPath: string;\n private readonly projectRoot: string;\n\n public constructor(private readonly options: CompilerOptions) {\n if (options.generateTypeScriptConfig != null && options.typeScriptConfig != null) {\n throw new utils.JsiiError(\n 'Cannot use `generateTypeScriptConfig` and `typeScriptConfig` together. Provide only one of them.',\n );\n }\n\n this.projectRoot = this.options.projectInfo.projectRoot;\n const configFileName = options.typeScriptConfig ?? options.generateTypeScriptConfig ?? 'tsconfig.json';\n this.configPath = path.join(this.projectRoot, configFileName);\n this.userProvidedTypeScriptConfig = Boolean(options.typeScriptConfig);\n\n this.system = {\n ...ts.sys,\n getCurrentDirectory: () => this.projectRoot,\n createDirectory: (pth) => ts.sys.createDirectory(path.resolve(this.projectRoot, pth)),\n deleteFile: ts.sys.deleteFile && ((pth) => ts.sys.deleteFile!(path.join(this.projectRoot, pth))),\n fileExists: (pth) => ts.sys.fileExists(path.resolve(this.projectRoot, pth)),\n getFileSize: ts.sys.getFileSize && ((pth) => ts.sys.getFileSize!(path.resolve(this.projectRoot, pth))),\n readFile: (pth, encoding) => ts.sys.readFile(path.resolve(this.projectRoot, pth), encoding),\n watchFile:\n ts.sys.watchFile &&\n ((pth, callback, pollingInterval, watchOptions) =>\n ts.sys.watchFile!(path.resolve(this.projectRoot, pth), callback, pollingInterval, watchOptions)),\n writeFile: (pth, data, writeByteOrderMark) =>\n ts.sys.writeFile(path.resolve(this.projectRoot, pth), data, writeByteOrderMark),\n };\n\n this.tsconfig = this.configureTypeScript();\n this.compilerHost = ts.createIncrementalCompilerHost(this.tsconfig.compilerOptions, this.system);\n }\n\n /**\n * Compiles the configured program.\n *\n * @param files can be specified to override the standard source code location logic. Useful for example when testing \"negatives\".\n */\n public emit(...files: string[]): ts.EmitResult {\n this.prepareForBuild(...files);\n return this.buildOnce();\n }\n\n /**\n * Watches for file-system changes and dynamically recompiles the project as needed. In non-blocking mode, this\n * returns the TypeScript watch handle for the application to use.\n *\n * @internal\n */\n public async watch(opts: NonBlockingWatchOptions): Promise<ts.Watch<ts.BuilderProgram>>;\n /**\n * Watches for file-system changes and dynamically recompiles the project as needed. In blocking mode, this results\n * in a never-resolving promise.\n */\n public async watch(): Promise<never>;\n public async watch(opts?: NonBlockingWatchOptions): Promise<ts.Watch<ts.BuilderProgram> | never> {\n this.prepareForBuild();\n\n const host = ts.createWatchCompilerHost(\n this.configPath,\n {\n ...this.tsconfig.compilerOptions,\n noEmitOnError: false,\n },\n this.system,\n ts.createEmitAndSemanticDiagnosticsBuilderProgram,\n opts?.reportDiagnostics,\n opts?.reportWatchStatus,\n this.tsconfig.watchOptions,\n );\n if (!host.getDefaultLibLocation) {\n throw new Error('No default library location was found on the TypeScript compiler host!');\n }\n const orig = host.afterProgramCreate;\n // This is a callback cascade, so it's \"okay\" to return an unhandled promise there. This may\n // cause an unhandled promise rejection warning, but that's not a big deal.\n //\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n host.afterProgramCreate = (builderProgram) => {\n const startTime = Date.now();\n const emitResult = this.consumeProgram(builderProgram.getProgram(), host.getDefaultLibLocation!());\n\n for (const diag of emitResult.diagnostics.filter((d) => d.code === JSII_DIAGNOSTICS_CODE)) {\n utils.logDiagnostic(diag, this.projectRoot);\n }\n\n console.log(\n utils.formatCompilationSummary(emitResult.diagnostics, emitResult.emitSkipped, Date.now() - startTime),\n );\n\n if (orig) {\n orig.call(host, builderProgram);\n }\n if (opts?.compilationComplete) {\n opts.compilationComplete(emitResult);\n }\n };\n const watch = ts.createWatchProgram(host);\n\n if (opts?.nonBlocking) {\n // In non-blocking mode, returns the handle to the TypeScript watch interface.\n return watch;\n }\n // In blocking mode, returns a never-resolving promise.\n return new Promise<never>(() => null);\n }\n\n /**\n * Prepares the project for build, by creating the necessary configuration\n * file(s), and assigning the relevant root file(s).\n *\n * @param files the files that were specified as input in the CLI invocation.\n */\n private configureTypeScript(): TypeScriptConfig {\n if (this.userProvidedTypeScriptConfig) {\n const config = this.readTypeScriptConfig();\n\n // emit a warning if validation is disabled\n const rules = this.options.validateTypeScriptConfig ?? TypeScriptConfigValidationRuleSet.NONE;\n if (rules === TypeScriptConfigValidationRuleSet.NONE) {\n utils.logDiagnostic(\n JsiiDiagnostic.JSII_4009_DISABLED_TSCONFIG_VALIDATION.create(undefined, this.configPath),\n this.projectRoot,\n );\n }\n\n // validate the user provided config\n if (rules !== TypeScriptConfigValidationRuleSet.NONE) {\n const configName = path.relative(this.projectRoot, this.configPath);\n try {\n const validator = new TypeScriptConfigValidator(rules);\n validator.validate({\n ...config,\n // convert the internal format to the user format which is what the validator operates on\n compilerOptions: convertForJson(config.compilerOptions),\n });\n } catch (error: unknown) {\n if (error instanceof ValidationError) {\n utils.logDiagnostic(\n JsiiDiagnostic.JSII_4000_FAILED_TSCONFIG_VALIDATION.create(\n undefined,\n configName,\n rules,\n error.violations,\n ),\n this.projectRoot,\n );\n }\n\n throw new utils.JsiiError(\n `Failed validation of tsconfig \"compilerOptions\" in \"${configName}\" against rule set \"${rules}\"!`,\n );\n }\n }\n\n return config;\n }\n\n // generated config if none is provided by the user\n return this.buildTypeScriptConfig();\n }\n\n /**\n * Final preparations of the project for build.\n *\n * These are preparations that either\n * - must happen immediately before the build, or\n * - can be different for every build like assigning the relevant root file(s).\n *\n * @param files the files that were specified as input in the CLI invocation.\n */\n private prepareForBuild(...files: string[]) {\n if (!this.userProvidedTypeScriptConfig) {\n this.writeTypeScriptConfig();\n }\n\n this.rootFiles = this.determineSources(files);\n }\n\n /**\n * Do a single build\n */\n private buildOnce(): ts.EmitResult {\n if (!this.compilerHost.getDefaultLibLocation) {\n throw new Error('No default library location was found on the TypeScript compiler host!');\n }\n\n const tsconf = this.tsconfig!;\n\n const prog = ts.createIncrementalProgram({\n rootNames: this.rootFiles.concat(_pathOfLibraries(tsconf.compilerOptions, this.compilerHost)),\n options: tsconf.compilerOptions,\n // Make the references absolute for the compiler\n projectReferences: tsconf.references?.map((ref) => ({\n path: path.resolve(path.dirname(this.configPath), ref.path),\n })),\n host: this.compilerHost,\n });\n\n return this.consumeProgram(prog.getProgram(), this.compilerHost.getDefaultLibLocation());\n }\n\n private consumeProgram(program: ts.Program, stdlib: string): ts.EmitResult {\n const diagnostics = [...ts.getPreEmitDiagnostics(program)];\n let hasErrors = false;\n\n if (!hasErrors && this.diagsHaveAbortableErrors(diagnostics)) {\n hasErrors = true;\n LOG.error('Compilation errors prevented the JSII assembly from being created');\n }\n\n // Do the \"Assembler\" part first because we need some of the analysis done in there\n // to post-process the AST\n const assembler = new Assembler(this.options.projectInfo, this.system, program, stdlib, {\n stripDeprecated: this.options.stripDeprecated,\n stripDeprecatedAllowListFile: this.options.stripDeprecatedAllowListFile,\n addDeprecationWarnings: this.options.addDeprecationWarnings,\n compressAssembly: this.options.compressAssembly,\n });\n\n try {\n const assmEmit = assembler.emit();\n if (!hasErrors && (assmEmit.emitSkipped || this.diagsHaveAbortableErrors(assmEmit.diagnostics))) {\n hasErrors = true;\n LOG.error('Type model errors prevented the JSII assembly from being created');\n }\n\n diagnostics.push(...assmEmit.diagnostics);\n } catch (e: any) {\n diagnostics.push(JsiiDiagnostic.JSII_9997_UNKNOWN_ERROR.createDetached(e));\n hasErrors = true;\n }\n\n // Do the emit, but add in transformers which are going to replace real\n // comments with synthetic ones.\n const emit = program.emit(\n undefined, // targetSourceFile\n undefined, // writeFile\n undefined, // cancellationToken\n undefined, // emitOnlyDtsFiles\n assembler.customTransformers,\n );\n diagnostics.push(...emit.diagnostics);\n\n if (!hasErrors && (emit.emitSkipped || this.diagsHaveAbortableErrors(emit.diagnostics))) {\n hasErrors = true;\n LOG.error('Compilation errors prevented the JSII assembly from being created');\n }\n\n // Some extra validation on the config.\n // Make sure that { \"./.warnings.jsii.js\": \"./.warnings.jsii.js\" } is in the set of\n // exports, if they are specified.\n if (this.options.addDeprecationWarnings && this.options.projectInfo.exports !== undefined) {\n const expected = `./${WARNINGSCODE_FILE_NAME}`;\n const warningsExport = Object.entries(this.options.projectInfo.exports).filter(\n ([k, v]) => k === expected && v === expected,\n );\n\n if (warningsExport.length === 0) {\n hasErrors = true;\n diagnostics.push(JsiiDiagnostic.JSII_0007_MISSING_WARNINGS_EXPORT.createDetached());\n }\n }\n\n return {\n emitSkipped: hasErrors,\n diagnostics: ts.sortAndDeduplicateDiagnostics(diagnostics),\n emittedFiles: emit.emittedFiles,\n };\n }\n\n /**\n * Build the TypeScript config object from jsii config\n *\n * This is the object that will be written to disk\n * unless an existing tsconfig was provided.\n */\n private buildTypeScriptConfig(): TypeScriptConfig {\n let references: string[] | undefined;\n\n const isComposite =\n this.options.projectReferences !== undefined\n ? this.options.projectReferences\n : this.options.projectInfo.projectReferences !== undefined\n ? this.options.projectInfo.projectReferences\n : false;\n if (isComposite) {\n references = this.findProjectReferences();\n }\n\n const pi = this.options.projectInfo;\n\n return {\n compilerOptions: {\n ...pi.tsc,\n ...BASE_COMPILER_OPTIONS,\n // Enable composite mode if project references are enabled\n composite: isComposite,\n // When incremental, configure a tsbuildinfo file\n tsBuildInfoFile: path.join(pi.tsc?.outDir ?? '.', 'tsconfig.tsbuildinfo'),\n },\n include: [pi.tsc?.rootDir != null ? path.join(pi.tsc.rootDir, '**', '*.ts') : path.join('**', '*.ts')],\n exclude: [\n 'node_modules',\n ...(pi.excludeTypescript ?? []),\n ...(pi.tsc?.outDir != null &&\n (pi.tsc?.rootDir == null || path.resolve(pi.tsc.outDir).startsWith(path.resolve(pi.tsc.rootDir) + path.sep))\n ? [path.join(pi.tsc.outDir, '**', '*.ts')]\n : []),\n ],\n // Change the references a little. We write 'originalpath' to the\n // file under the 'path' key, which is the same as what the\n // TypeScript compiler does. Make it relative so that the files are\n // movable. Not strictly required but looks better.\n references: references?.map((p) => ({ path: p })),\n };\n }\n\n /**\n * Load the TypeScript config object from a provided file\n */\n private readTypeScriptConfig(): TypeScriptConfig {\n const projectRoot = this.options.projectInfo.projectRoot;\n const { config, error } = ts.readConfigFile(this.configPath, ts.sys.readFile);\n if (error) {\n utils.logDiagnostic(error, projectRoot);\n throw new utils.JsiiError(`Failed to load tsconfig at ${this.configPath}`);\n }\n const extended = ts.parseJsonConfigFileContent(config, ts.sys, projectRoot);\n // the tsconfig parser adds this in, but it is not an expected compilerOption\n delete extended.options.configFilePath;\n\n return {\n compilerOptions: extended.options,\n watchOptions: extended.watchOptions,\n include: extended.fileNames,\n };\n }\n\n /**\n * Creates a `tsconfig.json` file to improve the IDE experience.\n *\n * @return the fully qualified path to the `tsconfig.json` file\n */\n private writeTypeScriptConfig(): void {\n const commentKey = '_generated_by_jsii_';\n const commentValue = 'Generated by jsii - safe to delete, and ideally should be in .gitignore';\n\n (this.tsconfig as any)[commentKey] = commentValue;\n\n if (fs.existsSync(this.configPath)) {\n const { config: currentConfig } = ts.readConfigFile(this.configPath, ts.sys.readFile);\n if (currentConfig && !(commentKey in currentConfig)) {\n throw new utils.JsiiError(\n `A '${this.configPath}' file that was not generated by jsii is in ${this.options.projectInfo.projectRoot}. Aborting instead of overwriting.`,\n );\n }\n }\n\n const outputConfig = {\n ...this.tsconfig,\n compilerOptions: convertForJson(this.tsconfig?.compilerOptions),\n };\n\n LOG.debug(`Creating or updating ${chalk.blue(this.configPath)}`);\n fs.writeFileSync(this.configPath, JSON.stringify(outputConfig, null, 2), 'utf8');\n }\n\n /**\n * Find all dependencies that look like TypeScript projects.\n *\n * Enumerate all dependencies, if they have a tsconfig.json file with\n * \"composite: true\" we consider them project references.\n *\n * (Note: TypeScript seems to only correctly find transitive project references\n * if there's an \"index\" tsconfig.json of all projects somewhere up the directory\n * tree)\n */\n private findProjectReferences(): string[] {\n const pkg = this.options.projectInfo.packageJson;\n\n const ret = new Array<string>();\n\n const dependencyNames = new Set<string>();\n for (const dependencyMap of [pkg.dependencies, pkg.devDependencies, pkg.peerDependencies]) {\n if (dependencyMap === undefined) {\n continue;\n }\n for (const name of Object.keys(dependencyMap)) {\n dependencyNames.add(name);\n }\n }\n\n for (const tsconfigFile of Array.from(dependencyNames).map((depName) => this.findMonorepoPeerTsconfig(depName))) {\n if (!tsconfigFile) {\n continue;\n }\n\n const { config: tsconfig } = ts.readConfigFile(tsconfigFile, this.system.readFile);\n\n // Add references to any TypeScript package we find that is 'composite' enabled.\n // Make it relative.\n if (tsconfig.compilerOptions?.composite) {\n ret.push(path.relative(this.options.projectInfo.projectRoot, path.dirname(tsconfigFile)));\n } else {\n // Not a composite package--if this package is in a node_modules directory, that is most\n // likely correct, otherwise it is most likely an error (heuristic here, I don't know how to\n // properly check this).\n if (tsconfigFile.includes('node_modules')) {\n LOG.warn('%s: not a composite TypeScript package, but it probably should be', path.dirname(tsconfigFile));\n }\n }\n }\n\n return ret;\n }\n\n /**\n * Find source files using the same mechanism that the TypeScript compiler itself uses.\n *\n * Respects includes/excludes/etc.\n *\n * This makes it so that running 'typescript' and running 'jsii' has the same behavior.\n */\n private determineSources(files: string[]): string[] {\n // explicitly requested files\n if (files.length > 0) {\n return [...files];\n }\n\n // for user provided config we already have parsed the full list of files\n if (this.userProvidedTypeScriptConfig) {\n return [...(this.tsconfig.include ?? [])];\n }\n\n // finally get the file list for the generated config\n const parseConfigHost = parseConfigHostFromCompilerHost(this.compilerHost);\n const parsed = ts.parseJsonConfigFileContent(this.tsconfig, parseConfigHost, this.options.projectInfo.projectRoot);\n return [...parsed.fileNames];\n }\n\n /**\n * Resolve the given dependency name from the current package, and find the associated tsconfig.json location\n *\n * Because we have the following potential directory layout:\n *\n * package/node_modules/some_dependency\n * package/tsconfig.json\n *\n * We resolve symlinks and only find a \"TypeScript\" dependency if doesn't have 'node_modules' in\n * the path after resolving symlinks (i.e., if it's a peer package in the same monorepo).\n *\n * Returns undefined if no such tsconfig could be found.\n */\n private findMonorepoPeerTsconfig(depName: string): string | undefined {\n // eslint-disable-next-line @typescript-eslint/no-require-imports,@typescript-eslint/no-var-requires\n const { builtinModules } = require('node:module');\n if ((builtinModules ?? []).includes(depName)) {\n // Can happen for modules like 'punycode' which are declared as dependency for polyfill purposes\n return undefined;\n }\n\n try {\n const depDir = findDependencyDirectory(depName, this.options.projectInfo.projectRoot);\n\n const dep = path.join(depDir, 'tsconfig.json');\n if (!fs.existsSync(dep)) {\n return undefined;\n }\n\n // Resolve symlinks, to check if this is a monorepo peer\n const dependencyRealPath = fs.realpathSync(dep);\n if (dependencyRealPath.split(path.sep).includes('node_modules')) {\n return undefined;\n }\n\n return dependencyRealPath;\n } catch (e: any) {\n // @types modules cannot be required, for example\n if (['MODULE_NOT_FOUND', 'ERR_PACKAGE_PATH_NOT_EXPORTED'].includes(e.code)) {\n return undefined;\n }\n throw e;\n }\n }\n\n private diagsHaveAbortableErrors(diags: readonly ts.Diagnostic[]) {\n return diags.some(\n (d) =>\n d.category === ts.DiagnosticCategory.Error ||\n (this.options.failOnWarnings && d.category === ts.DiagnosticCategory.Warning && !isSilenced(d)),\n );\n }\n}\n\n/**\n * Options for Watch in non-blocking mode.\n *\n * @internal\n */\nexport interface NonBlockingWatchOptions {\n /**\n * Signals non-blocking execution\n */\n readonly nonBlocking: true;\n\n /**\n * Configures the diagnostics reporter\n */\n readonly reportDiagnostics: ts.DiagnosticReporter;\n\n /**\n * Configures the watch status reporter\n */\n readonly reportWatchStatus: ts.WatchStatusReporter;\n\n /**\n * This hook gets invoked when a compilation cycle (complete with Assembler execution) completes.\n */\n readonly compilationComplete: (emitResult: ts.EmitResult) => void;\n}\n\nfunction _pathOfLibraries(options: ts.CompilerOptions, host: ts.CompilerHost | ts.WatchCompilerHost<any>): string[] {\n // Prefer user libraries, falling back to a library based on the target if not supplied by the user.\n // This matches tsc behavior.\n const libs = options.lib ?? [ts.getDefaultLibFileName(options)];\n if (libs.length === 0) {\n return [];\n }\n\n const libDir = host.getDefaultLibLocation?.();\n if (!libDir) {\n throw new Error(`Compiler host doesn't have a default library directory available for ${libs.join(', ')}`);\n }\n return libs.map((name) => path.join(libDir, name));\n}\n\nfunction parseConfigHostFromCompilerHost(host: ts.CompilerHost): ts.ParseConfigHost {\n // Copied from upstream\n // https://github.com/Microsoft/TypeScript/blob/9e05abcfd3f8bb3d6775144ede807daceab2e321/src/compiler/program.ts#L3105\n return {\n fileExists: (f) => host.fileExists(f),\n readDirectory(root, extensions, excludes, includes, depth) {\n if (host.readDirectory === undefined) {\n throw new Error(\"'CompilerHost.readDirectory' must be implemented to correctly process 'projectReferences'\");\n }\n return host.readDirectory(root, extensions, excludes, includes, depth);\n },\n readFile: (f) => host.readFile(f),\n useCaseSensitiveFileNames: host.useCaseSensitiveFileNames(),\n trace: host.trace ? (s) => host.trace!(s) : undefined,\n };\n}\n"]}
1
+ {"version":3,"file":"compiler.js","sources":["../src/compiler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,MAAY,MAAM,wCAAoB;AACtC,MAAY,EAAE,oCAAgB;AAC9B,MAAY,IAAI,sCAAkB;AAElC,qCAA2C;AAC3C,kDAA0B;AAC1B,MAAY,MAAM,mCAAe;AAEjC,2CAAwC;AACxC,oDAA8D;AAC9D,mDAA+C;AAC/C,6CAA8D;AAC9D,uCAAwC;AACxC,uDAAmD;AACnD,MAAY,QAAQ,uCAAmB;AAEvC,yCAAiF;AACjF,kEAAoE;AACpE,0CAA8E;AAC9E,sEAA0E;AA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rC,MAAM,MAAM,GAAG,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAClC,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACzF,OAAO,EAAE,GAAG,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;AAC1C,CAAC","sourcesContent":["import * as crypto from 'node:crypto';\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport * as spec from '@jsii/spec';\nimport { writeAssembly } from '@jsii/spec';\nimport chalk from 'chalk';\nimport * as log4js from 'log4js';\n\nimport { Assembler } from './assembler';\nimport { findDependencyDirectory } from './common/find-utils';\nimport { CompilerHost } from './compiler-host';\nimport { Diagnostic, DiagnosticCategory } from './diagnostic';\nimport { emitProject } from './emitter';\nimport { JsiiDiagnostic } from './jsii-diagnostic';\nimport * as literate from './literate';\nimport { ProjectInfo } from './project-info';\nimport { TypeScriptConfig, TypeScriptConfigValidationRuleSet } from './tsconfig';\nimport { BASE_COMPILER_OPTIONS } from './tsconfig/compiler-options';\nimport { parseTsconfigJson, readTypeScriptConfigFile } from './tsconfig/read';\nimport { TypeScriptConfigValidator } from './tsconfig/tsconfig-validator';\nimport { ValidationError } from './tsconfig/validator';\nimport * as utils from './utils';\n\nconst LOG = log4js.getLogger('jsii/compiler');\nexport const DIAGNOSTICS = 'diagnostics';\nexport const JSII_DIAGNOSTICS_CODE = 9999;\n\nexport interface CompilerOptions {\n /** The information about the project to be built */\n projectInfo: ProjectInfo;\n /**\n * Whether the compiler should watch for changes or just compile once.\n *\n * Watch mode is not available on the TypeScript 7 backend; setting this to\n * `true` makes `emit()` fail with an explicit error.\n */\n watch?: boolean;\n /** Whether to detect and generate TypeScript project references */\n projectReferences?: boolean;\n /** Whether to fail when a warning is emitted */\n failOnWarnings?: boolean;\n /** Whether to strip deprecated members from emitted artifacts */\n stripDeprecated?: boolean;\n /** The path to an allowlist of FQNs to strip if stripDeprecated is set */\n stripDeprecatedAllowListFile?: string;\n /**\n * Whether to add warnings for deprecated elements.\n *\n * Not implemented on the TypeScript 7 backend yet; requesting it fails with\n * an explicit error instead of silently producing an assembly without the\n * `.warnings.jsii.js` module.\n */\n addDeprecationWarnings?: boolean;\n /**\n * The name of the tsconfig file to generate.\n * Cannot be used at the same time as `typeScriptConfig`.\n * @default \"tsconfig.json\"\n */\n generateTypeScriptConfig?: string;\n /**\n * The name of the tsconfig file to use.\n * Cannot be used at the same time as `generateTypeScriptConfig`.\n * @default - generate the tsconfig file\n */\n typeScriptConfig?: string;\n /**\n * The ruleset to validate the provided tsconfig file against.\n * Can only be used when `typeScriptConfig` is provided.\n * @default TypeScriptConfigValidationRuleSet.STRICT - if `typeScriptConfig` is provided\n */\n validateTypeScriptConfig?: TypeScriptConfigValidationRuleSet;\n /**\n * Whether to compress the assembly\n * @default false\n */\n compressAssembly?: boolean;\n}\n\nexport interface EmitResult {\n readonly emitSkipped: boolean;\n readonly diagnostics: readonly Diagnostic[];\n /** The files written by the compiler (absolute paths). */\n readonly emittedFiles?: readonly string[];\n}\n\n/**\n * Compiles a jsii project with the TypeScript 7 programmatic API.\n *\n * The compiler owns the `tsconfig.json` handling (generating one from the\n * project's `package.json`, or validating a user-provided one) and delegates the\n * type analysis, assembly generation and emit to `buildProject`, which drives the\n * out-of-process TypeScript 7 compiler.\n */\nexport class Compiler {\n private readonly userProvidedTypeScriptConfig: boolean;\n private readonly tsconfig: TypeScriptConfig;\n private readonly configPath: string;\n private readonly projectRoot: string;\n\n public constructor(private readonly options: CompilerOptions) {\n if (options.generateTypeScriptConfig != null && options.typeScriptConfig != null) {\n throw new utils.JsiiError(\n 'Cannot use `generateTypeScriptConfig` and `typeScriptConfig` together. Provide only one of them.',\n );\n }\n\n this.projectRoot = this.options.projectInfo.projectRoot;\n const configFileName = options.typeScriptConfig ?? options.generateTypeScriptConfig ?? 'tsconfig.json';\n this.configPath = path.join(this.projectRoot, configFileName);\n this.userProvidedTypeScriptConfig = Boolean(options.typeScriptConfig);\n this.tsconfig = this.configureTypeScript();\n }\n\n /** The name of the tsconfig file this compiler builds from (relative to the project root). */\n public get configFileName(): string {\n return path.relative(this.projectRoot, this.configPath);\n }\n\n /**\n * Compiles the configured project once.\n */\n /**\n * Compiles the configured project once.\n *\n * @param files can be specified to override the standard source code location\n * logic (the generated tsconfig then lists exactly these files).\n * Useful for example when testing \"negatives\".\n */\n public emit(...files: string[]): EmitResult {\n if (this.options.watch) {\n throw new utils.JsiiError('--watch is not supported by the TypeScript 7 based compiler', true);\n }\n if (this.options.addDeprecationWarnings) {\n throw new utils.JsiiError('--add-deprecation-warnings is not supported by the TypeScript 7 based compiler yet');\n }\n if (files.length > 0 && this.userProvidedTypeScriptConfig) {\n throw new utils.JsiiError('Explicit source files cannot be combined with a user-provided tsconfig');\n }\n if (!this.userProvidedTypeScriptConfig) {\n this.writeTypeScriptConfig(files);\n }\n\n const result = buildProject({\n projectRoot: this.projectRoot,\n projectInfo: this.options.projectInfo,\n tsconfigFileName: this.configFileName,\n generatedTsconfig: !this.userProvidedTypeScriptConfig,\n stripDeprecated: this.options.stripDeprecated,\n stripDeprecatedAllowListFile: this.options.stripDeprecatedAllowListFile,\n compressAssembly: this.options.compressAssembly,\n });\n\n if (!result.emitSkipped) {\n LOG.info(`assembled ${result.typeCount} types, emitted ${result.emittedFiles.length} files`);\n }\n\n const hasWarnings = result.diagnostics.some((d) => d.category === 0 /* Warning */);\n return {\n emitSkipped: result.emitSkipped || (this.options.failOnWarnings === true && hasWarnings),\n diagnostics: result.diagnostics,\n emittedFiles: result.emittedFiles,\n };\n }\n\n private configureTypeScript(): TypeScriptConfig {\n if (this.userProvidedTypeScriptConfig) {\n const config = readTypeScriptConfigFile(this.configPath);\n\n // emit a warning if validation is disabled\n const rules = this.options.validateTypeScriptConfig ?? TypeScriptConfigValidationRuleSet.NONE;\n if (rules === TypeScriptConfigValidationRuleSet.NONE) {\n utils.logDiagnostic(\n JsiiDiagnostic.JSII_4009_DISABLED_TSCONFIG_VALIDATION.create(undefined, this.configPath),\n this.projectRoot,\n );\n }\n\n // validate the user provided config\n if (rules !== TypeScriptConfigValidationRuleSet.NONE) {\n const configName = path.relative(this.projectRoot, this.configPath);\n try {\n const validator = new TypeScriptConfigValidator(rules);\n validator.validate(config);\n } catch (error: unknown) {\n if (error instanceof ValidationError) {\n utils.logDiagnostic(\n JsiiDiagnostic.JSII_4000_FAILED_TSCONFIG_VALIDATION.create(\n undefined,\n configName,\n rules,\n error.violations,\n ),\n this.projectRoot,\n );\n }\n\n throw new utils.JsiiError(\n `Failed validation of tsconfig \"compilerOptions\" in \"${configName}\" against rule set \"${rules}\"!`,\n );\n }\n }\n\n return config;\n }\n\n // generated config if none is provided by the user\n return this.buildTypeScriptConfig();\n }\n\n /**\n * Builds the TypeScript config object from jsii config.\n *\n * This is the object that will be written to disk unless an existing tsconfig\n * is passed in.\n */\n private buildTypeScriptConfig(): TypeScriptConfig {\n let references: string[] | undefined;\n\n const isComposite =\n this.options.projectReferences !== undefined\n ? this.options.projectReferences\n : this.options.projectInfo.projectReferences !== undefined\n ? this.options.projectInfo.projectReferences\n : false;\n\n if (isComposite) {\n references = this.findProjectReferences();\n }\n\n const pi = this.options.projectInfo;\n\n return {\n compilerOptions: {\n ...pi.tsc,\n ...BASE_COMPILER_OPTIONS,\n // Enable composite mode if project references are enabled\n composite: isComposite,\n // When incremental, configure a tsbuildinfo file\n tsBuildInfoFile: path.join(pi.tsc?.outDir ?? '.', 'tsconfig.tsbuildinfo'),\n },\n include: [pi.tsc?.rootDir != null ? path.join(pi.tsc.rootDir, '**', '*.ts') : path.join('**', '*.ts')],\n exclude: [\n 'node_modules',\n ...(pi.excludeTypescript ?? []),\n ...(pi.tsc?.outDir != null &&\n (pi.tsc?.rootDir == null || path.resolve(pi.tsc.outDir).startsWith(path.resolve(pi.tsc.rootDir) + path.sep))\n ? [path.join(pi.tsc.outDir, '**', '*.ts')]\n : []),\n ],\n // Change the references a little. We write 'originalpath' to the\n // file under the 'path' key, which is the same as what the\n // TypeScript compiler does. Make it relative so that the files are\n // movable. Not strictly required but looks better.\n references: references?.map((p) => ({ path: p })),\n };\n }\n\n /**\n * Creates a `tsconfig.json` file to improve the IDE experience.\n */\n private writeTypeScriptConfig(files: string[] = []): void {\n const commentKey = '_generated_by_jsii_';\n const commentValue = 'Generated by jsii - safe to delete, and ideally should be in .gitignore';\n\n (this.tsconfig as any)[commentKey] = commentValue;\n\n if (fs.existsSync(this.configPath)) {\n const currentConfig = parseTsconfigJson(fs.readFileSync(this.configPath, 'utf8'), this.configPath);\n if (currentConfig && !(commentKey in currentConfig)) {\n throw new utils.JsiiError(\n `A '${this.configPath}' file that was not generated by jsii is in ${this.options.projectInfo.projectRoot}. Aborting instead of overwriting.`,\n );\n }\n }\n\n const config: TypeScriptConfig =\n files.length > 0\n ? {\n ...this.tsconfig,\n files: files.map((f) => path.relative(this.projectRoot, path.resolve(this.projectRoot, f))),\n include: undefined,\n }\n : this.tsconfig;\n LOG.debug(`Creating or updating ${chalk.blue(this.configPath)}`);\n fs.writeFileSync(this.configPath, JSON.stringify(config, null, 2), 'utf8');\n }\n\n /**\n * Find all dependencies that look like TypeScript projects.\n *\n * Enumerate all dependencies, if they have a tsconfig.json file with\n * \"composite: true\" we consider them project references.\n *\n * (Note: TypeScript seems to only correctly find transitive project references\n * if there's an \"index\" tsconfig.json of all projects somewhere up the directory\n * tree)\n */\n private findProjectReferences(): string[] {\n const pkg = this.options.projectInfo.packageJson;\n\n const ret = new Array<string>();\n\n const dependencyNames = new Set<string>();\n for (const dependencyMap of [pkg.dependencies, pkg.devDependencies, pkg.peerDependencies]) {\n if (dependencyMap === undefined) {\n continue;\n }\n for (const name of Object.keys(dependencyMap)) {\n dependencyNames.add(name);\n }\n }\n\n for (const tsconfigFile of Array.from(dependencyNames).map((depName) => this.findMonorepoPeerTsconfig(depName))) {\n if (!tsconfigFile) {\n continue;\n }\n\n const tsconfig = parseTsconfigJson(fs.readFileSync(tsconfigFile, 'utf8'), tsconfigFile);\n\n // Add references to any TypeScript package we find that is 'composite' enabled.\n // Make it relative.\n if (tsconfig.compilerOptions?.composite) {\n ret.push(path.relative(this.options.projectInfo.projectRoot, path.dirname(tsconfigFile)));\n } else {\n // Not a composite package--if this package is in a 'node_modules' directory, that is most\n // likely correct, otherwise it is most likely an error (heuristic).\n if (tsconfigFile.includes('node_modules')) {\n LOG.warn('%s: not a composite TypeScript package, but it probably should be', path.dirname(tsconfigFile));\n }\n }\n }\n\n return ret;\n }\n\n /**\n * Find source files for a dependency that is also a sibling in a monorepo.\n *\n * This method is used to find project references.\n */\n private findMonorepoPeerTsconfig(depName: string): string | undefined {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const { builtinModules } = require('node:module');\n if ((builtinModules ?? []).includes(depName)) {\n // Can happen for modules like 'punycode' which are declared as dependency for polyfill purposes\n return undefined;\n }\n\n try {\n const depDir = findDependencyDirectory(depName, this.options.projectInfo.projectRoot);\n\n const dep = path.join(depDir, 'tsconfig.json');\n if (!fs.existsSync(dep)) {\n return undefined;\n }\n\n // Resolve symlinks, to get a correct relative path\n const dependencyRealPath = fs.realpathSync(dep);\n if (dependencyRealPath.split(path.sep).includes('node_modules')) {\n return undefined;\n }\n\n return dependencyRealPath;\n } catch (e: any) {\n // @types modules cannot be required, for example\n if (['MODULE_NOT_FOUND', 'ERR_PACKAGE_PATH_NOT_EXPORTED'].includes(e.code)) {\n return undefined;\n }\n throw e;\n }\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires\nconst sortJson = require('sort-json');\n\nexport interface BuildProjectOptions {\n readonly projectRoot: string;\n readonly projectInfo: ProjectInfo;\n /** The tsconfig file to open, relative to `projectRoot` (default `tsconfig.json`). */\n readonly tsconfigFileName?: string;\n /**\n * Whether the tsconfig was generated by jsii (as opposed to user-provided).\n * A generated config may be amended with an inferred `rootDir`.\n */\n readonly generatedTsconfig?: boolean;\n readonly stripDeprecated?: boolean;\n readonly stripDeprecatedAllowListFile?: string;\n readonly compressAssembly?: boolean;\n}\n\nexport interface BuildProjectResult {\n readonly assembly?: spec.Assembly;\n readonly typeCount: number;\n readonly emittedFiles: string[];\n readonly emitSkipped: boolean;\n readonly diagnostics: readonly Diagnostic[];\n}\n\n/**\n * Derive the entrypoint .ts from the project's declared `types` entry.\n *\n * Mirrors the classic Assembler's `mainFile` computation: start from the\n * declared `types`, turn the `.d.ts`/`.js` into `.ts`, then — if an\n * out-of-source build is configured (tsc `outDir`) — re-root the path from the\n * `outDir` into the `rootDir`. This correctly handles both conventional\n * `src`->`lib` layouts and in-place (`rootDir === outDir`) layouts.\n */\nfunction deriveEntry(projectRoot: string, projectInfo: ProjectInfo, rootDir?: string, outDir?: string): string {\n const dts: string = projectInfo.types ?? 'index.d.ts';\n let mainFile = dts.replace(/\\.d\\.ts(x?)$/, '.ts$1').replace(/\\.js$/, '.ts');\n\n if (outDir != null) {\n // strip the outDir prefix, then prepend rootDir (if any)\n const rel = path.relative(outDir, mainFile);\n mainFile = rootDir != null ? path.join(rootDir, rel) : rel;\n }\n return path.resolve(projectRoot, mainFile);\n}\n\n/**\n * Run the ts backend for a package: produce and write the `.jsii` assembly.\n */\nexport function buildProject(options: BuildProjectOptions): BuildProjectResult {\n const { projectRoot, projectInfo } = options;\n\n let host = CompilerHost.open(options.projectRoot, options.tsconfigFileName);\n let project = host.getProject();\n let tsDiagnostics = collectTsDiagnostics(project.program);\n let tscRootDir = projectInfo.tsc?.rootDir;\n const tscOutDir = projectInfo.tsc?.outDir;\n\n // TypeScript 7 no longer infers `rootDir` from the common directory of the\n // sources when `outDir` is set (TS5011). The classic compiler relied on that\n // inference for the output layout and recorded the inferred directory as\n // `metadata.tscRootDir`; do the same for generated configs: infer it from the\n // program's root files, write it into the tsconfig and open the project again.\n if (options.generatedTsconfig && tscRootDir == null && tsDiagnostics.some((d) => d.code === 5011)) {\n const inferred = inferRootDir(project.rootFileNames, projectRoot);\n if (inferred != null) {\n const tsconfigPath = path.join(projectRoot, options.tsconfigFileName ?? 'tsconfig.json');\n const tsconfig = JSON.parse(fs.readFileSync(tsconfigPath, 'utf8'));\n tsconfig.compilerOptions = { ...tsconfig.compilerOptions, rootDir: inferred };\n fs.writeFileSync(tsconfigPath, JSON.stringify(tsconfig, null, 2), 'utf8');\n host.close();\n host = CompilerHost.open(options.projectRoot, options.tsconfigFileName);\n project = host.getProject();\n tsDiagnostics = collectTsDiagnostics(project.program);\n tscRootDir = inferred;\n }\n }\n\n const entry = deriveEntry(projectRoot, projectInfo, tscRootDir, tscOutDir);\n\n try {\n // Surface TypeScript compilation errors BEFORE assembling, with the same\n // reject-on-error behaviour as the default backend: a program that does not\n // compile must not produce an assembly.\n if (tsDiagnostics.some((d) => d.category === DiagnosticCategory.Error)) {\n return { typeCount: 0, emittedFiles: [], emitSkipped: true, diagnostics: tsDiagnostics };\n }\n\n const assembler = new Assembler(host.ts, project, {\n packageJson: projectInfo.packageJson,\n projectInfo,\n projectRoot,\n entry,\n assemblyName: projectInfo.name,\n defaultStability: projectInfo.stability,\n stripDeprecated: options.stripDeprecated ?? !!(projectInfo.packageJson as any)['cdk-build']?.stripDeprecated,\n stripDeprecatedAllowListFile: options.stripDeprecatedAllowListFile,\n tscRootDir,\n tscOutDir,\n readme: loadReadme(projectRoot),\n });\n\n let assembly: spec.Assembly;\n try {\n assembly = assembler.assemble();\n } catch (e: any) {\n // Same contract as the classic compiler: a failure while assembling is\n // reported as a JSII9997 error diagnostic rather than crashing the build.\n return {\n typeCount: 0,\n emittedFiles: [],\n emitSkipped: true,\n diagnostics: [\n ...tsDiagnostics,\n ...assembler.diagnostics,\n JsiiDiagnostic.JSII_9997_UNKNOWN_ERROR.createDetached(e),\n ],\n };\n }\n const jsiiDiagnostics = assembler.diagnostics;\n if (jsiiDiagnostics.some((d) => d.category === DiagnosticCategory.Error)) {\n return {\n typeCount: 0,\n emittedFiles: [],\n emitSkipped: true,\n diagnostics: [...tsDiagnostics, ...jsiiDiagnostics],\n };\n }\n\n if (process.env.JSII_TS7_TIMING) {\n LOG.info(`ts doc-cache hits (RPCs avoided): ${assembler.docCacheHits}`);\n }\n\n // Write the assembly first (the parity artifact), reusing @jsii/spec's writer\n // so the on-disk format (incl. the compressed file-redirect variant) matches\n // the strada path exactly.\n writeAssembly(projectRoot, fingerprint(assembly), { compress: options.compressAssembly ?? false });\n\n // Then emit JS/d.ts and inject jsii rtti (post-emit pass). An emit failure\n // fails the build (emitSkipped + a synthetic diagnostic); the assembly file\n // is left on disk to aid debugging, but the exit status reflects the error.\n let emittedFiles: string[] = [];\n try {\n ({ emittedFiles } = emitProject(project, {\n projectRoot,\n assembly,\n outDir: tscOutDir,\n rootDir: tscRootDir,\n }));\n } catch (err) {\n LOG.error(`ts backend: emit pipeline failed: ${(err as Error).stack ?? (err as Error).message}`);\n return {\n assembly,\n typeCount: Object.keys(assembly.types ?? {}).length,\n emittedFiles: [],\n emitSkipped: true,\n diagnostics: [syntheticErrorDiagnostic(`ts backend: emit pipeline failed: ${(err as Error).message}`)],\n };\n }\n\n return {\n assembly,\n typeCount: Object.keys(assembly.types ?? {}).length,\n emittedFiles,\n emitSkipped: false,\n diagnostics: [...tsDiagnostics, ...jsiiDiagnostics], // non-error diagnostics (warnings/suggestions) pass through\n };\n } finally {\n if (process.env.JSII_TS7_TIMING) {\n const t = host.getTimingInfo?.();\n if (t?.totals) {\n LOG.info(\n `ts timing: requests=${t.totals.requestCount} roundTripMs=${Math.round(t.totals.roundTripMs)} ` +\n `serverTimeMs=${Math.round(t.totals.serverTimeMs ?? 0)} transportOverheadMs=${Math.round(\n t.totals.transportOverheadMs ?? 0,\n )} ` +\n `sent=${t.totals.bytesSent} recv=${t.totals.bytesReceived}`,\n );\n }\n }\n host.close();\n }\n}\n\n/**\n * Collect the program's pre-emit diagnostics (options, global, syntactic and\n * semantic) from the program and map them to jsii's `Diagnostic` for the\n * standard reporting pipeline.\n */\nfunction collectTsDiagnostics(program: any): Diagnostic[] {\n const call = (name: string): any[] => (typeof program[name] === 'function' ? program[name]() ?? [] : []);\n const raw: any[] = [\n ...call('getProgramDiagnostics'),\n ...call('getGlobalDiagnostics'),\n ...call('getSyntacticDiagnostics'),\n ...call('getSemanticDiagnostics'),\n ];\n const texts = new Map<string, string | undefined>();\n const readSource = (fileName: string): string | undefined => {\n if (!texts.has(fileName)) {\n try {\n texts.set(fileName, fs.readFileSync(fileName, 'utf8'));\n } catch {\n texts.set(fileName, undefined);\n }\n }\n return texts.get(fileName);\n };\n return raw.map((d) => toDiagnostic(d, readSource));\n}\n\n/**\n * Map one TypeScript 7 API diagnostic (`{ fileName, pos, end, code, category, text }`)\n * to jsii's `Diagnostic`. The file text is attached so the formatter renders the\n * same `file:line:col - error TSxxxx:` layout, with source context, that the\n * classic compiler produced. Exported for unit tests.\n */\nexport function toDiagnostic(d: any, readSource: (fileName: string) => string | undefined): Diagnostic {\n const category = Object.values(DiagnosticCategory).includes(d.category)\n ? (d.category as DiagnosticCategory)\n : DiagnosticCategory.Error;\n const fileName: string | undefined = typeof d.fileName === 'string' ? d.fileName : undefined;\n const file = fileName != null ? { fileName, text: readSource(fileName) } : undefined;\n const hasRange = file != null && typeof d.pos === 'number' && typeof d.end === 'number' && d.end >= d.pos;\n return {\n category,\n code: typeof d.code === 'number' ? d.code : 0,\n file,\n start: hasRange ? d.pos : undefined,\n length: hasRange ? d.end - d.pos : undefined,\n messageText: typeof d.text === 'string' ? d.text : d.messageText ?? d.message ?? String(d),\n };\n}\n\n/** An error diagnostic with no source location. */\nfunction syntheticErrorDiagnostic(messageText: string): Diagnostic {\n return {\n category: DiagnosticCategory.Error,\n code: 0,\n file: undefined,\n start: undefined,\n length: undefined,\n messageText,\n };\n}\n\n/**\n * Load and render the package README the same way the default backend does\n * (including literate example inclusion), so `assembly.readme` matches.\n */\nfunction loadReadme(projectRoot: string): spec.ReadMe | undefined {\n const fileName = fs.readdirSync(projectRoot).find((file) => file.toLocaleLowerCase() === 'readme.md');\n if (fileName == null) {\n return undefined;\n }\n const readmePath = path.join(projectRoot, fileName);\n return {\n markdown: literate\n .includeAndRenderExamples(literate.loadFromFile(readmePath), literate.fileSystemLoader(projectRoot), projectRoot)\n .join('\\n'),\n };\n}\n\n/**\n * Port of the classic `inferRootDir`: the longest directory (relative to the\n * project root) shared by all root files of the configuration, or `undefined`\n * when they only share the project root itself.\n */\nfunction inferRootDir(rootFileNames: readonly string[], projectRoot: string): string | undefined {\n const directories = rootFileNames\n .filter((fileName) => !fileName.split(path.sep).includes('node_modules'))\n .map((fileName) => path.relative(projectRoot, path.dirname(fileName)))\n .map(segmentPath);\n if (directories.length === 0) {\n return undefined;\n }\n const maxPrefix = Math.min(...directories.map((segments) => segments.length - 1));\n let commonIndex = -1;\n while (commonIndex < maxPrefix && new Set(directories.map((segments) => segments[commonIndex + 1])).size === 1) {\n commonIndex++;\n }\n if (commonIndex < 0) {\n return undefined;\n }\n return directories[0][commonIndex];\n\n function segmentPath(fileName: string): string[] {\n const result = new Array<string>();\n for (let parent = fileName; parent !== path.dirname(parent); parent = path.dirname(parent)) {\n result.unshift(parent);\n }\n return result;\n }\n}\n\n/** Mirror of strada `_fingerprint`: sort keys, hash, stamp `fingerprint`. */\nfunction fingerprint(assembly: spec.Assembly): spec.Assembly {\n delete (assembly as any).fingerprint;\n const sorted = sortJson(assembly);\n const hash = crypto.createHash('sha256').update(JSON.stringify(sorted)).digest('base64');\n return { ...sorted, fingerprint: hash };\n}\n"]}
@@ -0,0 +1,34 @@
1
+ export declare enum DiagnosticCategory {
2
+ Warning = 0,
3
+ Error = 1,
4
+ Suggestion = 2,
5
+ Message = 3
6
+ }
7
+ /** A source file a diagnostic points into. */
8
+ export interface DiagnosticSourceFile {
9
+ readonly fileName: string;
10
+ /** The full text of the file, when available (used to render source context). */
11
+ readonly text?: string;
12
+ }
13
+ export interface Diagnostic {
14
+ readonly category: DiagnosticCategory;
15
+ readonly code: number;
16
+ readonly messageText: string;
17
+ readonly file?: DiagnosticSourceFile;
18
+ /** Start offset (UTF-16 code units) within `file`. */
19
+ readonly start?: number;
20
+ readonly length?: number;
21
+ }
22
+ /** Converts an offset into a 0-based line/character pair. */
23
+ export declare function getLineAndCharacterOfPosition(text: string, position: number): {
24
+ line: number;
25
+ character: number;
26
+ };
27
+ /**
28
+ * Renders a diagnostic the way the classic compiler's
29
+ * `formatDiagnosticsWithColorAndContext` does: a `file:line:col - category
30
+ * TSxxxx: message` header followed, when the source is available, by the
31
+ * offending line and a squiggle under the reported range.
32
+ */
33
+ export declare function formatDiagnosticWithColorAndContext(diagnostic: Diagnostic, projectRoot: string): string;
34
+ //# sourceMappingURL=diagnostic.d.ts.map
@@ -0,0 +1,141 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.DiagnosticCategory = void 0;
40
+ exports.getLineAndCharacterOfPosition = getLineAndCharacterOfPosition;
41
+ exports.formatDiagnosticWithColorAndContext = formatDiagnosticWithColorAndContext;
42
+ /**
43
+ * The diagnostic model used throughout the compiler.
44
+ *
45
+ * TypeScript 7 no longer exposes the in-process `ts.Diagnostic` type (the
46
+ * `typescript` package's main entry point only carries the version), so jsii
47
+ * carries its own, deliberately minimal, equivalent. Category values match the
48
+ * numeric `ts.DiagnosticCategory` values so that user-facing configuration
49
+ * (`jsii.diagnostics` in `package.json`) keeps its meaning.
50
+ */
51
+ const fs = __importStar(require("node:fs"));
52
+ const path = __importStar(require("node:path"));
53
+ const chalk_1 = __importDefault(require("chalk"));
54
+ var DiagnosticCategory;
55
+ (function (DiagnosticCategory) {
56
+ DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning";
57
+ DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error";
58
+ DiagnosticCategory[DiagnosticCategory["Suggestion"] = 2] = "Suggestion";
59
+ DiagnosticCategory[DiagnosticCategory["Message"] = 3] = "Message";
60
+ })(DiagnosticCategory || (exports.DiagnosticCategory = DiagnosticCategory = {}));
61
+ /** Converts an offset into a 0-based line/character pair. */
62
+ function getLineAndCharacterOfPosition(text, position) {
63
+ let line = 0;
64
+ let lineStart = 0;
65
+ for (let i = 0; i < position && i < text.length; i++) {
66
+ if (text[i] === '\n') {
67
+ line++;
68
+ lineStart = i + 1;
69
+ }
70
+ }
71
+ return { line, character: position - lineStart };
72
+ }
73
+ function categoryName(category) {
74
+ switch (category) {
75
+ case DiagnosticCategory.Error:
76
+ return 'error';
77
+ case DiagnosticCategory.Warning:
78
+ return 'warning';
79
+ case DiagnosticCategory.Suggestion:
80
+ return 'suggestion';
81
+ default:
82
+ return 'message';
83
+ }
84
+ }
85
+ function categoryColor(category) {
86
+ switch (category) {
87
+ case DiagnosticCategory.Error:
88
+ return chalk_1.default.red;
89
+ case DiagnosticCategory.Warning:
90
+ return chalk_1.default.yellow;
91
+ case DiagnosticCategory.Suggestion:
92
+ return chalk_1.default.green;
93
+ default:
94
+ return chalk_1.default.blue;
95
+ }
96
+ }
97
+ /**
98
+ * Renders a diagnostic the way the classic compiler's
99
+ * `formatDiagnosticsWithColorAndContext` does: a `file:line:col - category
100
+ * TSxxxx: message` header followed, when the source is available, by the
101
+ * offending line and a squiggle under the reported range.
102
+ */
103
+ function formatDiagnosticWithColorAndContext(diagnostic, projectRoot) {
104
+ const color = categoryColor(diagnostic.category);
105
+ let out = '';
106
+ let text = diagnostic.file?.text;
107
+ if (text == null && diagnostic.file?.fileName && diagnostic.start != null) {
108
+ try {
109
+ text = fs.readFileSync(diagnostic.file.fileName, 'utf8');
110
+ }
111
+ catch {
112
+ text = undefined;
113
+ }
114
+ }
115
+ if (diagnostic.file) {
116
+ const relative = path.relative(projectRoot, diagnostic.file.fileName) || diagnostic.file.fileName;
117
+ out += chalk_1.default.cyan(relative);
118
+ if (text != null && diagnostic.start != null) {
119
+ const { line, character } = getLineAndCharacterOfPosition(text, diagnostic.start);
120
+ out += `:${chalk_1.default.yellow(line + 1)}:${chalk_1.default.yellow(character + 1)}`;
121
+ }
122
+ out += ' - ';
123
+ }
124
+ out += `${color(categoryName(diagnostic.category))}${chalk_1.default.grey(` TS${diagnostic.code}: `)}${diagnostic.messageText}\n`;
125
+ if (diagnostic.file && text != null && diagnostic.start != null) {
126
+ const start = getLineAndCharacterOfPosition(text, diagnostic.start);
127
+ const end = getLineAndCharacterOfPosition(text, diagnostic.start + Math.max(diagnostic.length ?? 1, 1));
128
+ const lines = text.split(/\r?\n/);
129
+ const gutterWidth = String(end.line + 1).length;
130
+ out += '\n';
131
+ for (let i = start.line; i <= end.line && i < lines.length; i++) {
132
+ const lineText = lines[i];
133
+ out += `${chalk_1.default.black.bgWhite(String(i + 1).padStart(gutterWidth))} ${lineText}\n`;
134
+ const from = i === start.line ? start.character : 0;
135
+ const to = i === end.line ? Math.max(end.character, from + 1) : lineText.length;
136
+ out += `${chalk_1.default.black.bgWhite(' '.repeat(gutterWidth))} ${' '.repeat(from)}${color('~'.repeat(Math.max(to - from, 1)))}\n`;
137
+ }
138
+ }
139
+ return out;
140
+ }
141
+ //# sourceMappingURL=diagnostic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diagnostic.js","sources":["../src/diagnostic.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;GAQG;AACH,MAAY,EAAE,oCAAgB;AAC9B,MAAY,IAAI,sCAAkB;AAClC,kDAA0B;AAE1B,IAAY,kBAKX;AALD,WAAY,kBAAkB;IAC5B,iEAAW,CAAA;IACX,6DAAS,CAAA;IACT,uEAAc,CAAA;IACd,iEAAW,CAAA;AACb,CAAC,EALW,kBAAkB,aAAlB,kBAAkB,GAAlB,kBAAkB,QAK7B;AAmBD,6DAA6D;AAC7D,uCAA8C,IAAY,EAAE,QAAgB;IAC1E,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,IAAI,SAAS,GAAG,CAAC,CAAC;IAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrD,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;YACrB,IAAI,EAAE,CAAC;YACP,SAAS,GAAG,CAAC,GAAG,CAAC,CAAC;QACpB,CAAC;IACH,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,GAAG,SAAS,EAAE,CAAC;AACnD,CAAC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,IAAI,CAAC;QACZ,KAAK,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI,GAAG,CAAC,IAAI,IAAI,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAChE,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YAC1B,GAAG,IAAI,GAAG,eAAK,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,IAAI,QAAQ,IAAI,CAAC;YACnF,MAAM,IAAI,GAAG,CAAC,KAAK,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;YACpD,MAAM,EAAE,GAAG,CAAC,KAAK,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC;YAChF,GAAG,IAAI,GAAG,eAAK,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,CAChF,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC,CACnC,IAAI,CAAC;QACR,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["/**\n * The diagnostic model used throughout the compiler.\n *\n * TypeScript 7 no longer exposes the in-process `ts.Diagnostic` type (the\n * `typescript` package's main entry point only carries the version), so jsii\n * carries its own, deliberately minimal, equivalent. Category values match the\n * numeric `ts.DiagnosticCategory` values so that user-facing configuration\n * (`jsii.diagnostics` in `package.json`) keeps its meaning.\n */\nimport * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport chalk from 'chalk';\n\nexport enum DiagnosticCategory {\n Warning = 0,\n Error = 1,\n Suggestion = 2,\n Message = 3,\n}\n\n/** A source file a diagnostic points into. */\nexport interface DiagnosticSourceFile {\n readonly fileName: string;\n /** The full text of the file, when available (used to render source context). */\n readonly text?: string;\n}\n\nexport interface Diagnostic {\n readonly category: DiagnosticCategory;\n readonly code: number;\n readonly messageText: string;\n readonly file?: DiagnosticSourceFile;\n /** Start offset (UTF-16 code units) within `file`. */\n readonly start?: number;\n readonly length?: number;\n}\n\n/** Converts an offset into a 0-based line/character pair. */\nexport function getLineAndCharacterOfPosition(text: string, position: number): { line: number; character: number } {\n let line = 0;\n let lineStart = 0;\n for (let i = 0; i < position && i < text.length; i++) {\n if (text[i] === '\\n') {\n line++;\n lineStart = i + 1;\n }\n }\n return { line, character: position - lineStart };\n}\n\nfunction categoryName(category: DiagnosticCategory): string {\n switch (category) {\n case DiagnosticCategory.Error:\n return 'error';\n case DiagnosticCategory.Warning:\n return 'warning';\n case DiagnosticCategory.Suggestion:\n return 'suggestion';\n default:\n return 'message';\n }\n}\n\nfunction categoryColor(category: DiagnosticCategory): (s: string) => string {\n switch (category) {\n case DiagnosticCategory.Error:\n return chalk.red;\n case DiagnosticCategory.Warning:\n return chalk.yellow;\n case DiagnosticCategory.Suggestion:\n return chalk.green;\n default:\n return chalk.blue;\n }\n}\n\n/**\n * Renders a diagnostic the way the classic compiler's\n * `formatDiagnosticsWithColorAndContext` does: a `file:line:col - category\n * TSxxxx: message` header followed, when the source is available, by the\n * offending line and a squiggle under the reported range.\n */\nexport function formatDiagnosticWithColorAndContext(diagnostic: Diagnostic, projectRoot: string): string {\n const color = categoryColor(diagnostic.category);\n let out = '';\n let text = diagnostic.file?.text;\n if (text == null && diagnostic.file?.fileName && diagnostic.start != null) {\n try {\n text = fs.readFileSync(diagnostic.file.fileName, 'utf8');\n } catch {\n text = undefined;\n }\n }\n if (diagnostic.file) {\n const relative = path.relative(projectRoot, diagnostic.file.fileName) || diagnostic.file.fileName;\n out += chalk.cyan(relative);\n if (text != null && diagnostic.start != null) {\n const { line, character } = getLineAndCharacterOfPosition(text, diagnostic.start);\n out += `:${chalk.yellow(line + 1)}:${chalk.yellow(character + 1)}`;\n }\n out += ' - ';\n }\n out += `${color(categoryName(diagnostic.category))}${chalk.grey(` TS${diagnostic.code}: `)}${\n diagnostic.messageText\n }\\n`;\n\n if (diagnostic.file && text != null && diagnostic.start != null) {\n const start = getLineAndCharacterOfPosition(text, diagnostic.start);\n const end = getLineAndCharacterOfPosition(text, diagnostic.start + Math.max(diagnostic.length ?? 1, 1));\n const lines = text.split(/\\r?\\n/);\n const gutterWidth = String(end.line + 1).length;\n out += '\\n';\n for (let i = start.line; i <= end.line && i < lines.length; i++) {\n const lineText = lines[i];\n out += `${chalk.black.bgWhite(String(i + 1).padStart(gutterWidth))} ${lineText}\\n`;\n const from = i === start.line ? start.character : 0;\n const to = i === end.line ? Math.max(end.character, from + 1) : lineText.length;\n out += `${chalk.black.bgWhite(' '.repeat(gutterWidth))} ${' '.repeat(from)}${color(\n '~'.repeat(Math.max(to - from, 1)),\n )}\\n`;\n }\n }\n return out;\n}\n"]}
package/lib/emitter.d.ts CHANGED
@@ -1,13 +1,43 @@
1
- import * as ts from 'typescript';
1
+ import * as spec from '@jsii/spec';
2
+ import { TypeScriptProject } from './compiler-host';
3
+ export interface EmitProjectOptions {
4
+ readonly projectRoot: string;
5
+ readonly assembly: spec.Assembly;
6
+ /** tsc `outDir` from the jsii config (for mapping source -> emitted js path). */
7
+ readonly outDir?: string;
8
+ /** tsc `rootDir` from the jsii config. */
9
+ readonly rootDir?: string;
10
+ }
11
+ export interface EmitProjectResult {
12
+ readonly emittedFiles: string[];
13
+ }
2
14
  /**
3
- * An object that is capable of emitting stuff.
15
+ * Emit JS/d.ts for the whole project in a SINGLE `program.emit()` call. The
16
+ * server writes every output file directly to disk and returns only file names,
17
+ * so the ~345MB emit payload (aws-cdk-lib) never crosses the RPC channel; jsii
18
+ * then reads back only the class-bearing `.js` files to append the jsii rtti
19
+ * marker.
20
+ *
21
+ * NOTE (perf/stability): emitting per source file would issue one round-trip
22
+ * per file and, at aws-cdk-lib scale (~thousands of files), was observed to
23
+ * destabilize the out-of-process session (EPIPE / process exit). The
24
+ * whole-project emit collapses this to one request.
4
25
  */
5
- export interface Emitter {
6
- /**
7
- * Attempts to emit stuff.
8
- *
9
- * @return the result of attempting to emit stuff.
10
- */
11
- emit(): ts.EmitResult;
12
- }
26
+ export declare function emitProject(project: TypeScriptProject, options: EmitProjectOptions): EmitProjectResult;
27
+ /**
28
+ * Insert the rtti snippet into emitted JS. When the file ends with a
29
+ * `//# sourceMappingURL=` comment, the snippet is inserted BEFORE it so the
30
+ * marker comment stays the last line of the file (tooling convention).
31
+ * Exported for unit tests.
32
+ */
33
+ export declare function injectRtti(source: string, snippet: string): string;
34
+ /**
35
+ * Build the post-emit rtti injection snippet for a set of classes, matching the
36
+ * shape the classic runtime-info transformer produces at runtime.
37
+ * Exported for unit tests.
38
+ */
39
+ export declare function rttiSnippet(classes: Array<{
40
+ name: string;
41
+ fqn: string;
42
+ }>, version: string): string;
13
43
  //# sourceMappingURL=emitter.d.ts.map
package/lib/emitter.js CHANGED
@@ -1,3 +1,191 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.emitProject = emitProject;
37
+ exports.injectRtti = injectRtti;
38
+ exports.rttiSnippet = rttiSnippet;
39
+ /*
40
+ * ---------------------------------------------------------------------------
41
+ * Emit: produce the JS / d.ts artifacts via the TypeScript 7 `program.emit()`,
42
+ * then inject the jsii runtime type information (the `Symbol.for("jsii.rtti")`
43
+ * marker on each exported class) into the emitted `.js`. The previous
44
+ * implementation did the injection with a `CustomTransformer` during emit; the
45
+ * TypeScript 7 API has no transformer hook, so this is a post-emit text pass
46
+ * (the injected code is the same).
47
+ * ---------------------------------------------------------------------------
48
+ */
49
+ /* eslint-disable @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-return */
50
+ const fs = __importStar(require("node:fs"));
51
+ const path = __importStar(require("node:path"));
52
+ const spec = __importStar(require("@jsii/spec"));
53
+ const log4js = __importStar(require("log4js"));
54
+ const LOG = log4js.getLogger('jsii/emitter');
55
+ /** The jsii runtime-type-information symbol key (see @jsii/runtime). */
56
+ const RTTI_SYMBOL = 'jsii.rtti';
57
+ /**
58
+ * Emit JS/d.ts for the whole project in a SINGLE `program.emit()` call. The
59
+ * server writes every output file directly to disk and returns only file names,
60
+ * so the ~345MB emit payload (aws-cdk-lib) never crosses the RPC channel; jsii
61
+ * then reads back only the class-bearing `.js` files to append the jsii rtti
62
+ * marker.
63
+ *
64
+ * NOTE (perf/stability): emitting per source file would issue one round-trip
65
+ * per file and, at aws-cdk-lib scale (~thousands of files), was observed to
66
+ * destabilize the out-of-process session (EPIPE / process exit). The
67
+ * whole-project emit collapses this to one request.
68
+ */
69
+ function emitProject(project, options) {
70
+ const { program } = project;
71
+ const root = options.projectRoot;
72
+ const assembly = options.assembly;
73
+ // Map the emitted `.js` path (relative to root, normalized) -> classes to stamp
74
+ // with rtti. Derive the emitted path from each class's source `locationInModule`
75
+ // via the tsc outDir/rootDir transform, so it is robust to duplicate basenames
76
+ // across modules (common at aws-cdk-lib scale). We also index by basename as a
77
+ // fallback for simple layouts.
78
+ const classesByJsRel = new Map();
79
+ // Basename fallback index: basename -> the set of jsRel paths that share it.
80
+ // The fallback is only safe when a basename is unambiguous (single jsRel).
81
+ const jsRelsByBasename = new Map();
82
+ for (const [fqn, type] of Object.entries(assembly.types ?? {})) {
83
+ if (type.kind !== spec.TypeKind.Class) {
84
+ continue;
85
+ }
86
+ const relSrc = type.locationInModule?.filename;
87
+ if (!relSrc) {
88
+ continue;
89
+ }
90
+ const entry = { name: type.name, fqn };
91
+ const jsRel = sourceRelToJsRel(relSrc, options.outDir, options.rootDir);
92
+ if (!classesByJsRel.has(jsRel)) {
93
+ classesByJsRel.set(jsRel, []);
94
+ }
95
+ classesByJsRel.get(jsRel).push(entry);
96
+ const base = path.basename(jsRel);
97
+ if (!jsRelsByBasename.has(base)) {
98
+ jsRelsByBasename.set(base, new Set());
99
+ }
100
+ jsRelsByBasename.get(base).add(jsRel);
101
+ }
102
+ const emittedFiles = [];
103
+ // Whole-project emit (see the function docblock for why this is one RPC).
104
+ // `program.emit()` writes to the host filesystem and returns
105
+ // { emitSkipped, diagnostics, emittedFiles } with absolute file names.
106
+ const result = program.emit();
107
+ if (result?.emitSkipped) {
108
+ const reasons = (result.diagnostics ?? []).map((d) => d.text ?? d.messageText ?? String(d)).slice(0, 5);
109
+ throw new Error(`TypeScript emit was skipped${reasons.length ? `: ${reasons.join('; ')}` : ''}`);
110
+ }
111
+ let outputNames = result?.emittedFiles;
112
+ if (outputNames === undefined) {
113
+ // emittedFiles may be omitted by the server; fall back to the class-bearing
114
+ // JS files we can derive locally (sufficient for rtti injection).
115
+ outputNames = [...classesByJsRel.keys()];
116
+ }
117
+ for (const name of outputNames) {
118
+ const outPath = path.resolve(root, name);
119
+ emittedFiles.push(outPath);
120
+ if (!/\.js$/.test(name)) {
121
+ continue; // non-JS (d.ts / maps): already written by the server, nothing to do
122
+ }
123
+ const jsRel = normalizeRel(path.relative(root, outPath));
124
+ let classesHere = classesByJsRel.get(jsRel);
125
+ if (!classesHere) {
126
+ // Fall back to basename matching ONLY when it is unambiguous (a single
127
+ // source file maps to this basename); otherwise skip and say so.
128
+ const candidates = jsRelsByBasename.get(path.basename(name));
129
+ if (candidates?.size === 1) {
130
+ classesHere = classesByJsRel.get([...candidates][0]);
131
+ }
132
+ else if (candidates && candidates.size > 1) {
133
+ LOG.warn(`ts backend: skipping rtti injection for ${jsRel} (ambiguous basename across ${candidates.size} files)`);
134
+ }
135
+ }
136
+ if (!classesHere || !classesHere.length) {
137
+ continue; // JS without exported classes: no rtti to inject, leave as written
138
+ }
139
+ // Read the server-written JS, inject the rtti snippet, write it back. Only a
140
+ // small fraction of files (those declaring exported classes) are touched.
141
+ const onDisk = fs.readFileSync(outPath, 'utf8');
142
+ fs.writeFileSync(outPath, injectRtti(onDisk, rttiSnippet(classesHere, assembly.version)), { encoding: 'utf8' });
143
+ }
144
+ return { emittedFiles };
145
+ }
146
+ /** Normalize a relative path for use as a map key (posix separators). */
147
+ function normalizeRel(p) {
148
+ return p.split(path.sep).join('/');
149
+ }
150
+ /**
151
+ * Transform a source path (relative to root, e.g. `src/foo.ts`) into the emitted
152
+ * JS path (relative to root, e.g. `lib/foo.js`) using the tsc outDir/rootDir.
153
+ */
154
+ function sourceRelToJsRel(relSrc, outDir, rootDir) {
155
+ let p = relSrc.replace(/\.tsx?$/, '.js');
156
+ if (rootDir != null && outDir != null) {
157
+ const rootRel = normalizeRel(path.relative(rootDir, p));
158
+ if (!rootRel.startsWith('..')) {
159
+ p = path.join(outDir, rootRel);
160
+ }
161
+ }
162
+ return normalizeRel(p);
163
+ }
164
+ /**
165
+ * Insert the rtti snippet into emitted JS. When the file ends with a
166
+ * `//# sourceMappingURL=` comment, the snippet is inserted BEFORE it so the
167
+ * marker comment stays the last line of the file (tooling convention).
168
+ * Exported for unit tests.
169
+ */
170
+ function injectRtti(source, snippet) {
171
+ const m = /\n\/\/# sourceMappingURL=[^\n]*\s*$/.exec(source);
172
+ if (m) {
173
+ return source.slice(0, m.index) + snippet.replace(/\n$/, '') + source.slice(m.index);
174
+ }
175
+ return source + snippet;
176
+ }
177
+ /**
178
+ * Build the post-emit rtti injection snippet for a set of classes, matching the
179
+ * shape the classic runtime-info transformer produces at runtime.
180
+ * Exported for unit tests.
181
+ */
182
+ function rttiSnippet(classes, version) {
183
+ let snippet = '\n// jsii runtime type information (injected after emit)\n';
184
+ for (const c of classes) {
185
+ snippet +=
186
+ `try { Object.defineProperty(exports.${c.name}, Symbol.for("${RTTI_SYMBOL}"), ` +
187
+ `{ value: { fqn: ${JSON.stringify(c.fqn)}, version: ${JSON.stringify(version)} }, configurable: true }); } catch (e) { }\n`;
188
+ }
189
+ return snippet;
190
+ }
3
191
  //# sourceMappingURL=emitter.js.map