jsii 5.4.32-dev.2 → 5.4.33-dev.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/compiler.js CHANGED
@@ -9,6 +9,7 @@ const ts = require("typescript");
9
9
  const assembler_1 = require("./assembler");
10
10
  const find_utils_1 = require("./common/find-utils");
11
11
  const downlevel_dts_1 = require("./downlevel-dts");
12
+ const helpers_1 = require("./helpers");
12
13
  const jsii_diagnostic_1 = require("./jsii-diagnostic");
13
14
  const deprecation_warnings_1 = require("./transforms/deprecation-warnings");
14
15
  const tsconfig_1 = require("./tsconfig");
@@ -199,7 +200,9 @@ class Compiler {
199
200
  LOG.error('Compilation errors prevented the JSII assembly from being created');
200
201
  }
201
202
  if (!hasErrors) {
202
- (0, downlevel_dts_1.emitDownleveledDeclarations)(this.options.projectInfo);
203
+ (0, downlevel_dts_1.emitDownleveledDeclarations)(this.projectRoot, this.options.projectInfo.packageJson,
204
+ // outDir might be absolute. Need to normalize it.
205
+ (0, helpers_1.normalizeConfigPath)(this.projectRoot, this.tsconfig.compilerOptions.outDir));
203
206
  }
204
207
  // Some extra validation on the config.
205
208
  // Make sure that { "./.warnings.jsii.js": "./.warnings.jsii.js" } is in the set of
@@ -235,6 +238,9 @@ class Compiler {
235
238
  references = this.findProjectReferences();
236
239
  }
237
240
  const pi = this.options.projectInfo;
241
+ const configDir = path.dirname(this.configPath);
242
+ const absoluteTypesCompat = path.resolve(configDir, pi.tsc?.outDir ?? '.', downlevel_dts_1.TYPES_COMPAT);
243
+ const relativeTypesCompat = path.relative(configDir, absoluteTypesCompat);
238
244
  return {
239
245
  compilerOptions: {
240
246
  ...pi.tsc,
@@ -247,7 +253,7 @@ class Compiler {
247
253
  include: [pi.tsc?.rootDir != null ? path.join(pi.tsc.rootDir, '**', '*.ts') : path.join('**', '*.ts')],
248
254
  exclude: [
249
255
  'node_modules',
250
- pi.tsc?.outDir != null ? path.resolve(pi.tsc.outDir, downlevel_dts_1.TYPES_COMPAT) : downlevel_dts_1.TYPES_COMPAT,
256
+ relativeTypesCompat,
251
257
  ...(pi.excludeTypescript ?? []),
252
258
  ...(pi.tsc?.outDir != null &&
253
259
  (pi.tsc?.rootDir == null || path.resolve(pi.tsc.outDir).startsWith(path.resolve(pi.tsc.rootDir) + path.sep))
@@ -1 +1 @@
1
- {"version":3,"file":"compiler.js","sourceRoot":"","sources":["../src/compiler.ts"],"names":[],"mappings":";;;AAAA,8BAA8B;AAC9B,kCAAkC;AAClC,+BAA+B;AAC/B,iCAAiC;AACjC,iCAAiC;AAEjC,2CAAwC;AACxC,oDAA8D;AAC9D,mDAA4E;AAE5E,uDAAmD;AAEnD,4EAA2E;AAC3E,yCAAiF;AACjF,kEAAoF;AACpF,sEAA0E;AAC1E,oDAAuD;AACvD,iCAAiC;AAEjC,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;IASnB,YAAoC,OAAwB;QAAxB,YAAO,GAAP,OAAO,CAAiB;QAJpD,cAAS,GAAa,EAAE,CAAC;QAK/B,IAAI,OAAO,CAAC,wBAAwB,IAAI,IAAI,IAAI,OAAO,CAAC,gBAAgB,IAAI,IAAI,EAAE,CAAC;YACjF,MAAM,IAAI,KAAK,CACb,kGAAkG,CACnG,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC;QACxD,MAAM,cAAc,GAAG,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,wBAAwB,IAAI,eAAe,CAAC;QACvG,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC;QAC9D,IAAI,CAAC,4BAA4B,GAAG,OAAO,CAAC,OAAO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IAC5D,uBAAuB;IACvB,sHAAsH;IACtH,OAAO;QACL,UAAU,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;QACrC,aAAa,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK;YACvD,IAAI,IAAI,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;gBACrC,MAAM,IAAI,KAAK,CAAC,2FAA2F,CAAC,CAAC;YAC/G,CAAC;YACD,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,CAAC,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 * as 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 { emitDownleveledDeclarations, TYPES_COMPAT } from './downlevel-dts';\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';\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 Error(\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 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 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 Error(\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(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 if (!hasErrors) {\n emitDownleveledDeclarations(this.options.projectInfo);\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.tsc?.outDir != null ? path.resolve(pi.tsc.outDir, TYPES_COMPAT) : TYPES_COMPAT,\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 Error(`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 currentConfig = JSON.parse(fs.readFileSync(this.configPath, 'utf-8'));\n if (!(commentKey in currentConfig)) {\n throw new Error(\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),\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(host: ts.CompilerHost | ts.WatchCompilerHost<any>): string[] {\n if (!BASE_COMPILER_OPTIONS.lib || BASE_COMPILER_OPTIONS.lib.length === 0) {\n return [];\n }\n const lib = host.getDefaultLibLocation?.();\n if (!lib) {\n throw new Error(\n `Compiler host doesn't have a default library directory available for ${BASE_COMPILER_OPTIONS.lib.join(', ')}`,\n );\n }\n return BASE_COMPILER_OPTIONS.lib.map((name) => path.join(lib, 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","s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AI,CAAC,CAAC,CAAC;AACvE,CAAC;AAED,SAAS,+BAA+B,CAAC,IAAqB;IAC5D,uBAAuB;IACvB,sHAAsH;IACtH,OAAO;QACL,UAAU,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;QACrC,aAAa,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK;YACvD,IAAI,IAAI,CAAC,aAAa,KAAK,SAAS,EAAE,CAAC;gBACrC,MAAM,IAAI,KAAK,CAAC,2FAA2F,CAAC,CAAC;YAC/G,CAAC;YACD,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,CAAC,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 * as 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 { emitDownleveledDeclarations, TYPES_COMPAT } from './downlevel-dts';\nimport { Emitter } from './emitter';\nimport { normalizeConfigPath } from './helpers';\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';\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 Error(\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 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 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 Error(\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(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 if (!hasErrors) {\n emitDownleveledDeclarations(\n this.projectRoot,\n this.options.projectInfo.packageJson,\n // outDir might be absolute. Need to normalize it.\n normalizeConfigPath(this.projectRoot, this.tsconfig.compilerOptions.outDir),\n );\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 const configDir = path.dirname(this.configPath);\n const absoluteTypesCompat = path.resolve(configDir, pi.tsc?.outDir ?? '.', TYPES_COMPAT);\n const relativeTypesCompat = path.relative(configDir, absoluteTypesCompat);\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 relativeTypesCompat,\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 Error(`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 currentConfig = JSON.parse(fs.readFileSync(this.configPath, 'utf-8'));\n if (!(commentKey in currentConfig)) {\n throw new Error(\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),\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(host: ts.CompilerHost | ts.WatchCompilerHost<any>): string[] {\n if (!BASE_COMPILER_OPTIONS.lib || BASE_COMPILER_OPTIONS.lib.length === 0) {\n return [];\n }\n const lib = host.getDefaultLibLocation?.();\n if (!lib) {\n throw new Error(\n `Compiler host doesn't have a default library directory available for ${BASE_COMPILER_OPTIONS.lib.join(', ')}`,\n );\n }\n return BASE_COMPILER_OPTIONS.lib.map((name) => path.join(lib, 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,12 +1,12 @@
1
- import type { ProjectInfo } from './project-info';
1
+ import type { PackageJson } from './project-info';
2
2
  export declare const TYPES_COMPAT = ".types-compat";
3
3
  /**
4
4
  * Produces down-leveled declaration files to ensure compatibility with previous
5
- * compiler releases (macthing TypeScript's `major.minor` versioning scheme).
5
+ * compiler releases (matching TypeScript's `major.minor` versioning scheme).
6
6
  * This is necessary in order to ensure a package change compiler release lines
7
7
  * does not force all it's consumers to do the same (and vice-versa).
8
8
  *
9
9
  * @returns the `typesVersions` object that should be recorded in `package.json`
10
10
  */
11
- export declare function emitDownleveledDeclarations({ packageJson, projectRoot, tsc }: ProjectInfo): void;
11
+ export declare function emitDownleveledDeclarations(projectRoot: string, packageJson: PackageJson, outDir?: string): void;
12
12
  //# sourceMappingURL=downlevel-dts.d.ts.map
@@ -25,14 +25,14 @@ const TS_VERSION = new semver_1.SemVer(`${ts.versionMajorMinor}.0`);
25
25
  const DOWNLEVEL_BREAKPOINTS = ['3.9'].map((ver) => new semver_1.SemVer(`${ver}.0`));
26
26
  /**
27
27
  * Produces down-leveled declaration files to ensure compatibility with previous
28
- * compiler releases (macthing TypeScript's `major.minor` versioning scheme).
28
+ * compiler releases (matching TypeScript's `major.minor` versioning scheme).
29
29
  * This is necessary in order to ensure a package change compiler release lines
30
30
  * does not force all it's consumers to do the same (and vice-versa).
31
31
  *
32
32
  * @returns the `typesVersions` object that should be recorded in `package.json`
33
33
  */
34
- function emitDownleveledDeclarations({ packageJson, projectRoot, tsc }) {
35
- const compatRoot = (0, node_path_1.join)(projectRoot, ...(tsc?.outDir != null ? [tsc?.outDir] : []), exports.TYPES_COMPAT);
34
+ function emitDownleveledDeclarations(projectRoot, packageJson, outDir) {
35
+ const compatRoot = (0, node_path_1.join)(projectRoot, ...(outDir != null ? [outDir] : []), exports.TYPES_COMPAT);
36
36
  (0, node_fs_1.rmSync)(compatRoot, { force: true, recursive: true });
37
37
  const rewrites = new Set();
38
38
  for (const breakpoint of DOWNLEVEL_BREAKPOINTS) {
@@ -47,8 +47,8 @@ function emitDownleveledDeclarations({ packageJson, projectRoot, tsc }) {
47
47
  const workdir = (0, node_fs_1.mkdtempSync)((0, node_path_1.join)((0, node_os_1.tmpdir)(), `downlevel-dts-${breakpoint}-${(0, node_path_1.basename)(projectRoot)}-`));
48
48
  try {
49
49
  (0, downlevel_dts_1.main)(projectRoot, workdir, breakpoint.version);
50
- const projectOutDir = tsc?.outDir != null ? (0, node_path_1.join)(projectRoot, tsc.outDir) : projectRoot;
51
- const workOutDir = tsc?.outDir != null ? (0, node_path_1.join)(workdir, tsc.outDir) : workdir;
50
+ const projectOutDir = outDir != null ? (0, node_path_1.join)(projectRoot, outDir) : projectRoot;
51
+ const workOutDir = outDir != null ? (0, node_path_1.join)(workdir, outDir) : workdir;
52
52
  for (const dts of walkDirectory(workOutDir)) {
53
53
  const original = (0, node_fs_1.readFileSync)((0, node_path_1.join)(projectOutDir, dts), 'utf-8');
54
54
  const downleveledPath = (0, node_path_1.join)(workOutDir, dts);
@@ -87,8 +87,11 @@ function emitDownleveledDeclarations({ packageJson, projectRoot, tsc }) {
87
87
  }
88
88
  }
89
89
  }
90
+ catch (error) {
91
+ LOG.error(error);
92
+ }
90
93
  finally {
91
- // Clean up after outselves...
94
+ // Clean up after ourselves...
92
95
  (0, node_fs_1.rmSync)(workdir, { force: true, recursive: true });
93
96
  }
94
97
  }
@@ -96,8 +99,8 @@ function emitDownleveledDeclarations({ packageJson, projectRoot, tsc }) {
96
99
  for (const version of rewrites) {
97
100
  // Register the type redirect in the typesVersions configuration
98
101
  typesVersions ?? (typesVersions = {});
99
- const from = [...(tsc?.outDir != null ? [tsc?.outDir] : []), '*'].join('/');
100
- const to = [...(tsc?.outDir != null ? [tsc?.outDir] : []), exports.TYPES_COMPAT, `ts${version}`, '*'].join('/');
102
+ const from = [...(outDir != null ? [outDir] : []), '*'].join('/');
103
+ const to = [...(outDir != null ? [outDir] : []), exports.TYPES_COMPAT, `ts${version}`, '*'].join('/');
101
104
  // We put 2 candidate redirects (first match wins), so that it works for nested imports, too (see: https://github.com/microsoft/TypeScript/issues/43133)
102
105
  typesVersions[`<=${version}`] = { [from]: [to, `${to}/index.d.ts`] };
103
106
  }
@@ -1 +1 @@
1
- {"version":3,"file":"downlevel-dts.js","sourceRoot":"","sources":["../src/downlevel-dts.ts"],"names":[],"mappings":";;;AAAA,qCAUiB;AACjB,qCAAiC;AACjC,yCAA8D;AAC9D,iDAAkD;AAClD,iCAAiC;AACjC,mCAAgC;AAChC,iCAAiC;AAIpB,QAAA,YAAY,GAAG,eAAe,CAAC;AAE5C,MAAM,GAAG,GAAG,MAAM,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;AAE9C,MAAM,UAAU,GAAG,IAAI,eAAM,CAAC,GAAG,EAAE,CAAC,iBAAiB,IAAI,CAAC,CAAC;AAE3D;;;;;;;;;;GAUG;AACH,MAAM,qBAAqB,GAAsB,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,eAAM,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC;AAE9F;;;;;;;GAOG;AACH,SAAgB,2BAA2B,CAAC,EAAE,WAAW,EAAE,WAAW,EAAE,GAAG,EAAe;IACxF,MAAM,UAAU,GAAG,IAAA,gBAAI,EAAC,WAAW,EAAE,GAAG,CAAC,GAAG,EAAE,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,oBAAY,CAAC,CAAC;IAClG,IAAA,gBAAM,EA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AC,EAAE,CAAC;QACpC,MAAM,QAAQ,GAAG,IAAA,gBAAI,EAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QACjC,IAAI,IAAA,kBAAQ,EAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC;YACrC,uCAAuC;YACvC,KAAK,CAAC,CAAC,aAAa,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QACvC,CAAC;aAAM,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YAChD,0CAA0C;YAC1C,MAAM,IAAA,oBAAQ,EAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QACjC,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import {\n copyFileSync,\n existsSync,\n mkdirSync,\n mkdtempSync,\n readdirSync,\n readFileSync,\n rmSync,\n statSync,\n writeFileSync,\n} from 'node:fs';\nimport { tmpdir } from 'node:os';\nimport { basename, dirname, join, relative } from 'node:path';\nimport { main as downlevel } from 'downlevel-dts';\nimport * as log4js from 'log4js';\nimport { SemVer } from 'semver';\nimport * as ts from 'typescript';\nimport type { PackageJson, ProjectInfo } from './project-info';\nimport type { Mutable } from './utils';\n\nexport const TYPES_COMPAT = '.types-compat';\n\nconst LOG = log4js.getLogger('jsii/compiler');\n\nconst TS_VERSION = new SemVer(`${ts.versionMajorMinor}.0`);\n\n/**\n * Declares what versions of the TypeScript language will be supported by the\n * declarations files (and `typesVersions` entries) produced by this compiler\n * release.\n *\n * This should contain only `major.minor` specifiers, similar to the value of\n * the `ts.versionMajorMinor` property, and must be sorted in ascending version\n * order, as this dictates the order of entries in the `typesVersions` redirects\n * which has a direct impact on resolution (first match wins), and we don't want\n * to have to perform a sort pass on this list.\n */\nconst DOWNLEVEL_BREAKPOINTS: readonly SemVer[] = ['3.9'].map((ver) => new SemVer(`${ver}.0`));\n\n/**\n * Produces down-leveled declaration files to ensure compatibility with previous\n * compiler releases (macthing TypeScript's `major.minor` versioning scheme).\n * This is necessary in order to ensure a package change compiler release lines\n * does not force all it's consumers to do the same (and vice-versa).\n *\n * @returns the `typesVersions` object that should be recorded in `package.json`\n */\nexport function emitDownleveledDeclarations({ packageJson, projectRoot, tsc }: ProjectInfo) {\n const compatRoot = join(projectRoot, ...(tsc?.outDir != null ? [tsc?.outDir] : []), TYPES_COMPAT);\n rmSync(compatRoot, { force: true, recursive: true });\n\n const rewrites = new Set<`${number}.${number}`>();\n\n for (const breakpoint of DOWNLEVEL_BREAKPOINTS) {\n if (TS_VERSION.compare(breakpoint) <= 0) {\n // This TypeScript release is older or same as the breakpoint, so no need\n // for down-leveling here.\n continue;\n }\n\n const rewriteSet = new Map<string, string>();\n let needed = false;\n\n // We'll emit down-leveled declarations in a temporary directory...\n const workdir = mkdtempSync(join(tmpdir(), `downlevel-dts-${breakpoint}-${basename(projectRoot)}-`));\n try {\n downlevel(projectRoot, workdir, breakpoint.version);\n const projectOutDir = tsc?.outDir != null ? join(projectRoot, tsc.outDir) : projectRoot;\n const workOutDir = tsc?.outDir != null ? join(workdir, tsc.outDir) : workdir;\n for (const dts of walkDirectory(workOutDir)) {\n const original = readFileSync(join(projectOutDir, dts), 'utf-8');\n const downleveledPath = join(workOutDir, dts);\n const downleveled = readFileSync(downleveledPath, 'utf-8');\n needed ||= !semanticallyEqualDeclarations(original, downleveled);\n rewriteSet.set(dts, downleveledPath);\n }\n\n // If none of the declarations files changed during the down-level, then\n // we don't need to actually write it out & cause a redirect. This would\n // be wasteful. Most codebases won't incur any rewrite at all, since the\n // declarations files only reference \"visible\" members, and `jsii`\n // actually does not allow most of the unsupported syntaxes to be used\n // anyway.\n if (needed) {\n rewrites.add(`${breakpoint.major}.${breakpoint.minor}`);\n\n const versionSuffix = `ts${breakpoint.major}.${breakpoint.minor}`;\n const compatDir = join(compatRoot, versionSuffix);\n if (!existsSync(compatDir)) {\n mkdirSync(compatDir, { recursive: true });\n try {\n // Write an empty .npmignore file so that npm pack doesn't use the .gitignore file...\n writeFileSync(join(compatRoot, '.npmignore'), '\\n', 'utf-8');\n // Make sure all of this is gitignored, out of courtesy...\n writeFileSync(join(compatRoot, '.gitignore'), '*\\n', 'utf-8');\n } catch {\n // Ignore any error here... This is inconsequential.\n }\n }\n\n for (const [dts, downleveledPath] of rewriteSet) {\n const rewritten = join(compatDir, dts);\n // Make sure the parent directory exists (dts might be nested)\n mkdirSync(dirname(rewritten), { recursive: true });\n // Write the re-written declarations file there...\n copyFileSync(downleveledPath, rewritten);\n }\n }\n } finally {\n // Clean up after outselves...\n rmSync(workdir, { force: true, recursive: true });\n }\n }\n\n let typesVersions: Mutable<PackageJson['typesVersions']>;\n\n for (const version of rewrites) {\n // Register the type redirect in the typesVersions configuration\n typesVersions ??= {};\n const from = [...(tsc?.outDir != null ? [tsc?.outDir] : []), '*'].join('/');\n const to = [...(tsc?.outDir != null ? [tsc?.outDir] : []), TYPES_COMPAT, `ts${version}`, '*'].join('/');\n // We put 2 candidate redirects (first match wins), so that it works for nested imports, too (see: https://github.com/microsoft/TypeScript/issues/43133)\n typesVersions[`<=${version}`] = { [from]: [to, `${to}/index.d.ts`] };\n }\n\n // Compare JSON stringifications, as the order of keys is important here...\n if (JSON.stringify(packageJson.typesVersions) === JSON.stringify(typesVersions)) {\n // The existing configuration matches the new one. We're done here.\n return;\n }\n\n LOG.info('The required `typesVersions` configuration has changed. Updating \"package.json\" accordingly...');\n\n // Prepare the new contents of `PackageJson`.\n const newPackageJson = Object.entries(packageJson).reduce((obj, [key, value]) => {\n // NB: \"as any\" below are required becuase we must ignore `readonly` attributes from the source.\n if (key === 'typesVersions') {\n if (typesVersions != null) {\n obj[key] = typesVersions as any;\n }\n } else {\n obj[key] = value as any;\n // If there isn't currently a `typesVersions` entry, but there is a `types` entry,\n // we'll insert `typesVersions` right after `types`.\n if (key === 'types' && typesVersions != null && !('typesVersions' in packageJson)) {\n obj.typesVersions = typesVersions as any;\n }\n }\n return obj;\n }, {} as Mutable<PackageJson>);\n // If there was neither `types` nor `typesVersions` in the original `package.json`, we'll\n // add `typesVersions` at the end of it.\n if (!('typesVersions' in newPackageJson)) {\n newPackageJson.typesVersions = typesVersions as any;\n }\n\n const packageJsonFile = join(projectRoot, 'package.json');\n\n // We try \"hard\" to preserve the existing indent in the `package.json` file when updating it.\n const [, indent] = readFileSync(packageJsonFile, 'utf-8').match(/^(\\s*)\"/m) ?? [null, 2];\n\n writeFileSync(packageJsonFile, `${JSON.stringify(newPackageJson, undefined, indent)}\\n`, 'utf-8');\n}\n\n/**\n * Compares the contents of two declaration files semantically.\n *\n * @param left the first string.\n * @param right the second string.\n *\n * @returns `true` if `left` and `right` contain the same declarations.\n */\nfunction semanticallyEqualDeclarations(left: string, right: string): boolean {\n // We normalize declarations largely by parsing & re-printing them.\n const normalizeDeclarations = (code: string): string => {\n const sourceFile = ts.createSourceFile('index.d.ts', code, ts.ScriptTarget.Latest, false, ts.ScriptKind.TS);\n const printer = ts.createPrinter({\n newLine: ts.NewLineKind.LineFeed,\n noEmitHelpers: true,\n omitTrailingSemicolon: false,\n removeComments: true,\n });\n let normalized = printer.printFile(sourceFile);\n\n // TypeScript may emit duplicated reference declarations... which are absent from Downlevel-DTS' output...\n // https://github.com/microsoft/TypeScript/issues/48143\n const REFERENCES_TYPES_NODE = '/// <reference types=\"node\" />';\n while (normalized.startsWith(`${REFERENCES_TYPES_NODE}\\n${REFERENCES_TYPES_NODE}`)) {\n normalized = normalized.slice(REFERENCES_TYPES_NODE.length + 1);\n }\n\n return normalized;\n };\n\n left = normalizeDeclarations(left);\n right = normalizeDeclarations(right);\n\n return left === right;\n}\n\n/**\n * Recursively traverse the provided directory and yield the relative (to the\n * specified `root`) paths of all the `.d.ts` files found there.\n *\n * @param dir the directory to be walked.\n * @param root the root to which paths should be relative.\n */\nfunction* walkDirectory(dir: string, root: string = dir): Generator<string, void, void> {\n for (const file of readdirSync(dir)) {\n const filePath = join(dir, file);\n if (statSync(filePath).isDirectory()) {\n // This is a directory, recurse down...\n yield* walkDirectory(filePath, root);\n } else if (file.toLowerCase().endsWith('.d.ts')) {\n // This is a declaration file, yield it...\n yield relative(root, filePath);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"downlevel-dts.js","sourceRoot":"","sources":["../src/downlevel-dts.ts"],"names":[],"mappings":";;;AAAA,qCAUiB;AACjB,qCAAiC;AACjC,yCAA8D;AAC9D,iDAAkD;AAClD,iCAAiC;AACjC,mCAAgC;AAChC,iCAAiC;AAIpB,QAAA,YAAY,GAAG,eAAe,CAAC;AAE5C,MAAM,GAAG,GAAG,MAAM,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;AAE9C,MAAM,UAAU,GAAG,IAAI,eAAM,CAAC,GAAG,EAAE,CAAC,iBAAiB,IAAI,CAAC,CAAC;AAE3D;;;;;;;;;;GAUG;AACH,MAAM,qBAAqB,GAAsB,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,eAAM,CAAC,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC;AAE9F;;;;;;;GAOG;AACH,SAAgB,2BAA2B,CAAC,WAAmB,EAAE,WAAwB,EAAE,MAAe;IACxG,MAAM,UAAU,GAAG,IAAA,gBAAI,EAAC,WAAW,EAAE,GAAG,CAAC,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,oBAAY,CAAC,CAAC;IACxF,IAAA,gBAAM,EAAC,UAAU,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAErD,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAyB,CAAC;IAElD,KAAK,MAAM,UAAU,IAAI,qBAAqB,EAAE,CAAC;QAC/C,IAAI,UAAU,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;YACxC,yEAAyE;YACzE,0BAA0B;YAC1B,SAAS;QACX,CAAC;QAED,M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AC,EAAE,CAAC;YAChD,0CAA0C;YAC1C,MAAM,IAAA,oBAAQ,EAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QACjC,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import {\n copyFileSync,\n existsSync,\n mkdirSync,\n mkdtempSync,\n readdirSync,\n readFileSync,\n rmSync,\n statSync,\n writeFileSync,\n} from 'node:fs';\nimport { tmpdir } from 'node:os';\nimport { basename, dirname, join, relative } from 'node:path';\nimport { main as downlevel } from 'downlevel-dts';\nimport * as log4js from 'log4js';\nimport { SemVer } from 'semver';\nimport * as ts from 'typescript';\nimport type { PackageJson } from './project-info';\nimport type { Mutable } from './utils';\n\nexport const TYPES_COMPAT = '.types-compat';\n\nconst LOG = log4js.getLogger('jsii/compiler');\n\nconst TS_VERSION = new SemVer(`${ts.versionMajorMinor}.0`);\n\n/**\n * Declares what versions of the TypeScript language will be supported by the\n * declarations files (and `typesVersions` entries) produced by this compiler\n * release.\n *\n * This should contain only `major.minor` specifiers, similar to the value of\n * the `ts.versionMajorMinor` property, and must be sorted in ascending version\n * order, as this dictates the order of entries in the `typesVersions` redirects\n * which has a direct impact on resolution (first match wins), and we don't want\n * to have to perform a sort pass on this list.\n */\nconst DOWNLEVEL_BREAKPOINTS: readonly SemVer[] = ['3.9'].map((ver) => new SemVer(`${ver}.0`));\n\n/**\n * Produces down-leveled declaration files to ensure compatibility with previous\n * compiler releases (matching TypeScript's `major.minor` versioning scheme).\n * This is necessary in order to ensure a package change compiler release lines\n * does not force all it's consumers to do the same (and vice-versa).\n *\n * @returns the `typesVersions` object that should be recorded in `package.json`\n */\nexport function emitDownleveledDeclarations(projectRoot: string, packageJson: PackageJson, outDir?: string) {\n const compatRoot = join(projectRoot, ...(outDir != null ? [outDir] : []), TYPES_COMPAT);\n rmSync(compatRoot, { force: true, recursive: true });\n\n const rewrites = new Set<`${number}.${number}`>();\n\n for (const breakpoint of DOWNLEVEL_BREAKPOINTS) {\n if (TS_VERSION.compare(breakpoint) <= 0) {\n // This TypeScript release is older or same as the breakpoint, so no need\n // for down-leveling here.\n continue;\n }\n\n const rewriteSet = new Map<string, string>();\n let needed = false;\n\n // We'll emit down-leveled declarations in a temporary directory...\n const workdir = mkdtempSync(join(tmpdir(), `downlevel-dts-${breakpoint}-${basename(projectRoot)}-`));\n try {\n downlevel(projectRoot, workdir, breakpoint.version);\n const projectOutDir = outDir != null ? join(projectRoot, outDir) : projectRoot;\n const workOutDir = outDir != null ? join(workdir, outDir) : workdir;\n for (const dts of walkDirectory(workOutDir)) {\n const original = readFileSync(join(projectOutDir, dts), 'utf-8');\n const downleveledPath = join(workOutDir, dts);\n const downleveled = readFileSync(downleveledPath, 'utf-8');\n needed ||= !semanticallyEqualDeclarations(original, downleveled);\n rewriteSet.set(dts, downleveledPath);\n }\n\n // If none of the declarations files changed during the down-level, then\n // we don't need to actually write it out & cause a redirect. This would\n // be wasteful. Most codebases won't incur any rewrite at all, since the\n // declarations files only reference \"visible\" members, and `jsii`\n // actually does not allow most of the unsupported syntaxes to be used\n // anyway.\n if (needed) {\n rewrites.add(`${breakpoint.major}.${breakpoint.minor}`);\n\n const versionSuffix = `ts${breakpoint.major}.${breakpoint.minor}`;\n const compatDir = join(compatRoot, versionSuffix);\n if (!existsSync(compatDir)) {\n mkdirSync(compatDir, { recursive: true });\n try {\n // Write an empty .npmignore file so that npm pack doesn't use the .gitignore file...\n writeFileSync(join(compatRoot, '.npmignore'), '\\n', 'utf-8');\n // Make sure all of this is gitignored, out of courtesy...\n writeFileSync(join(compatRoot, '.gitignore'), '*\\n', 'utf-8');\n } catch {\n // Ignore any error here... This is inconsequential.\n }\n }\n\n for (const [dts, downleveledPath] of rewriteSet) {\n const rewritten = join(compatDir, dts);\n // Make sure the parent directory exists (dts might be nested)\n mkdirSync(dirname(rewritten), { recursive: true });\n // Write the re-written declarations file there...\n copyFileSync(downleveledPath, rewritten);\n }\n }\n } catch (error) {\n LOG.error(error);\n } finally {\n // Clean up after ourselves...\n rmSync(workdir, { force: true, recursive: true });\n }\n }\n\n let typesVersions: Mutable<PackageJson['typesVersions']>;\n\n for (const version of rewrites) {\n // Register the type redirect in the typesVersions configuration\n typesVersions ??= {};\n const from = [...(outDir != null ? [outDir] : []), '*'].join('/');\n const to = [...(outDir != null ? [outDir] : []), TYPES_COMPAT, `ts${version}`, '*'].join('/');\n // We put 2 candidate redirects (first match wins), so that it works for nested imports, too (see: https://github.com/microsoft/TypeScript/issues/43133)\n typesVersions[`<=${version}`] = { [from]: [to, `${to}/index.d.ts`] };\n }\n\n // Compare JSON stringifications, as the order of keys is important here...\n if (JSON.stringify(packageJson.typesVersions) === JSON.stringify(typesVersions)) {\n // The existing configuration matches the new one. We're done here.\n return;\n }\n\n LOG.info('The required `typesVersions` configuration has changed. Updating \"package.json\" accordingly...');\n\n // Prepare the new contents of `PackageJson`.\n const newPackageJson = Object.entries(packageJson).reduce((obj, [key, value]) => {\n // NB: \"as any\" below are required becuase we must ignore `readonly` attributes from the source.\n if (key === 'typesVersions') {\n if (typesVersions != null) {\n obj[key] = typesVersions as any;\n }\n } else {\n obj[key] = value as any;\n // If there isn't currently a `typesVersions` entry, but there is a `types` entry,\n // we'll insert `typesVersions` right after `types`.\n if (key === 'types' && typesVersions != null && !('typesVersions' in packageJson)) {\n obj.typesVersions = typesVersions as any;\n }\n }\n return obj;\n }, {} as Mutable<PackageJson>);\n // If there was neither `types` nor `typesVersions` in the original `package.json`, we'll\n // add `typesVersions` at the end of it.\n if (!('typesVersions' in newPackageJson)) {\n newPackageJson.typesVersions = typesVersions as any;\n }\n\n const packageJsonFile = join(projectRoot, 'package.json');\n\n // We try \"hard\" to preserve the existing indent in the `package.json` file when updating it.\n const [, indent] = readFileSync(packageJsonFile, 'utf-8').match(/^(\\s*)\"/m) ?? [null, 2];\n\n writeFileSync(packageJsonFile, `${JSON.stringify(newPackageJson, undefined, indent)}\\n`, 'utf-8');\n}\n\n/**\n * Compares the contents of two declaration files semantically.\n *\n * @param left the first string.\n * @param right the second string.\n *\n * @returns `true` if `left` and `right` contain the same declarations.\n */\nfunction semanticallyEqualDeclarations(left: string, right: string): boolean {\n // We normalize declarations largely by parsing & re-printing them.\n const normalizeDeclarations = (code: string): string => {\n const sourceFile = ts.createSourceFile('index.d.ts', code, ts.ScriptTarget.Latest, false, ts.ScriptKind.TS);\n const printer = ts.createPrinter({\n newLine: ts.NewLineKind.LineFeed,\n noEmitHelpers: true,\n omitTrailingSemicolon: false,\n removeComments: true,\n });\n let normalized = printer.printFile(sourceFile);\n\n // TypeScript may emit duplicated reference declarations... which are absent from Downlevel-DTS' output...\n // https://github.com/microsoft/TypeScript/issues/48143\n const REFERENCES_TYPES_NODE = '/// <reference types=\"node\" />';\n while (normalized.startsWith(`${REFERENCES_TYPES_NODE}\\n${REFERENCES_TYPES_NODE}`)) {\n normalized = normalized.slice(REFERENCES_TYPES_NODE.length + 1);\n }\n\n return normalized;\n };\n\n left = normalizeDeclarations(left);\n right = normalizeDeclarations(right);\n\n return left === right;\n}\n\n/**\n * Recursively traverse the provided directory and yield the relative (to the\n * specified `root`) paths of all the `.d.ts` files found there.\n *\n * @param dir the directory to be walked.\n * @param root the root to which paths should be relative.\n */\nfunction* walkDirectory(dir: string, root: string = dir): Generator<string, void, void> {\n for (const file of readdirSync(dir)) {\n const filePath = join(dir, file);\n if (statSync(filePath).isDirectory()) {\n // This is a directory, recurse down...\n yield* walkDirectory(filePath, root);\n } else if (file.toLowerCase().endsWith('.d.ts')) {\n // This is a declaration file, yield it...\n yield relative(root, filePath);\n }\n }\n}\n"]}
package/lib/helpers.d.ts CHANGED
@@ -107,4 +107,13 @@ export declare class TestWorkspace {
107
107
  cleanup(): void;
108
108
  }
109
109
  export type PackageInfo = PackageJson;
110
+ /**
111
+ * TSConfig paths can either be relative to the project or absolute.
112
+ * This function normalizes paths to be relative to the provided root.
113
+ * After normalization, code using these paths can be much simpler.
114
+ *
115
+ * @param root the project root
116
+ * @param pathToNormalize the path to normalize, might be empty
117
+ */
118
+ export declare function normalizeConfigPath(root: string, pathToNormalize?: string): string | undefined;
110
119
  //# sourceMappingURL=helpers.d.ts.map
package/lib/helpers.js CHANGED
@@ -7,7 +7,7 @@
7
7
  * well put it in one reusable place.
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.TestWorkspace = exports.compileJsiiForTest = exports.sourceToAssemblyHelper = void 0;
10
+ exports.normalizeConfigPath = exports.TestWorkspace = exports.compileJsiiForTest = exports.sourceToAssemblyHelper = void 0;
11
11
  const fs = require("node:fs");
12
12
  const os = require("node:os");
13
13
  const path = require("node:path");
@@ -220,4 +220,19 @@ class TestWorkspace {
220
220
  }
221
221
  }
222
222
  exports.TestWorkspace = TestWorkspace;
223
+ /**
224
+ * TSConfig paths can either be relative to the project or absolute.
225
+ * This function normalizes paths to be relative to the provided root.
226
+ * After normalization, code using these paths can be much simpler.
227
+ *
228
+ * @param root the project root
229
+ * @param pathToNormalize the path to normalize, might be empty
230
+ */
231
+ function normalizeConfigPath(root, pathToNormalize) {
232
+ if (pathToNormalize == null || !path.isAbsolute(pathToNormalize)) {
233
+ return pathToNormalize;
234
+ }
235
+ return path.relative(root, pathToNormalize);
236
+ }
237
+ exports.normalizeConfigPath = normalizeConfigPath;
223
238
  //# sourceMappingURL=helpers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,8BAA8B;AAC9B,8BAA8B;AAC9B,kCAAkC;AAClC,qCAA8E;AAE9E,2CAAgD;AAEhD,yCAAuD;AACvD,iDAA8D;AAC9D,mCAA2C;AAU3C;;;;;;;;;GASG;AACH,SAAgB,sBAAsB,CACpC,MAAoC,EACpC,OAA+D;IAE/D,OAAO,kBAAkB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC;AACtD,CAAC;AALD,wDAKC;AAwBD;;;;;;;;;GASG;AACH,SAAgB,kBAAkB,CAChC,MAA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for testing, but all projects that need to exercise\n * the JSII compiler to test something need to share this code, so might as\n * well put it in one reusable place.\n */\n\nimport * as fs from 'node:fs';\nimport * as os from 'node:os';\nimport * as path from 'node:path';\nimport { PackageJson, loadAssemblyFromPath, writeAssembly } from '@jsii/spec';\nimport * as spec from '@jsii/spec';\nimport { DiagnosticCategory } from 'typescript';\n\nimport { Compiler, CompilerOptions } from './compiler';\nimport { loadProjectInfo, ProjectInfo } from './project-info';\nimport { formatDiagnostic } from './utils';\n\n/**\n * A set of source files for `sourceToAssemblyHelper`, at least containing 'index.ts'\n */\nexport type MultipleSourceFiles = {\n 'index.ts': string;\n [name: string]: string;\n};\n\n/**\n * Compile a piece of source and return the JSII assembly for it\n *\n * Only usable for trivial cases and tests.\n *\n * @param source can either be a single `string` (the content of `index.ts`), or\n * a map of fileName to content, which *must* include `index.ts`.\n * @param options accepts a callback for historical reasons but really expects to\n * take an options object.\n */\nexport function sourceToAssemblyHelper(\n source: string | MultipleSourceFiles,\n options?: TestCompilationOptions | ((obj: PackageJson) => void),\n): spec.Assembly {\n return compileJsiiForTest(source, options).assembly;\n}\n\nexport interface HelperCompilationResult {\n /**\n * The generated assembly\n */\n readonly assembly: spec.Assembly;\n\n /**\n * Generated .js/.d.ts file(s)\n */\n readonly files: Record<string, string>;\n\n /**\n * The packageInfo used\n */\n readonly packageJson: PackageJson;\n\n /**\n * Whether to compress the assembly file\n */\n readonly compressAssembly: boolean;\n}\n\n/**\n * Compile a piece of source and return the assembly and compiled sources for it\n *\n * Only usable for trivial cases and tests.\n *\n * @param source can either be a single `string` (the content of `index.ts`), or\n * a map of fileName to content, which *must* include `index.ts`.\n * @param options accepts a callback for historical reasons but really expects to\n * take an options object.\n */\nexport function compileJsiiForTest(\n source: string | { 'index.ts': string; [name: string]: string },\n options?: TestCompilationOptions | ((obj: PackageJson) => void),\n compilerOptions?: Omit<CompilerOptions, 'projectInfo' | 'watch'>,\n): HelperCompilationResult {\n if (typeof source === 'string') {\n source = { 'index.ts': source };\n }\n\n const inSomeLocation =\n isOptionsObject(options) && options.compilationDirectory ? inOtherDir(options.compilationDirectory) : inTempDir;\n\n // Easiest way to get the source into the compiler is to write it to disk somewhere.\n // I guess we could make an in-memory compiler host but that seems like work...\n return inSomeLocation(() => {\n for (const [fileName, content] of Object.entries(source)) {\n fs.mkdirSync(path.dirname(fileName), { recursive: true });\n fs.writeFileSync(fileName, content, { encoding: 'utf-8' });\n }\n const { projectInfo, packageJson } = makeProjectInfo(\n 'index.ts',\n typeof options === 'function'\n ? options\n : (pi) => {\n Object.assign(pi, options?.packageJson ?? options?.projectInfo ?? {});\n },\n );\n const compiler = new Compiler({\n projectInfo,\n ...compilerOptions,\n });\n const emitResult = compiler.emit();\n\n const errors = emitResult.diagnostics.filter((d) => d.category === DiagnosticCategory.Error);\n for (const error of errors) {\n console.error(formatDiagnostic(error, projectInfo.projectRoot));\n // logDiagnostic() doesn't work out of the box, so console.error() it is.\n }\n if (errors.length > 0 || emitResult.emitSkipped) {\n throw new Error('There were compiler errors');\n }\n const assembly = loadAssemblyFromPath(process.cwd(), false);\n const files: Record<string, string> = {};\n\n for (const filename of Object.keys(source)) {\n let jsFile = filename.replace(/\\.ts$/, '.js');\n let dtsFile = filename.replace(/\\.ts$/, '.d.ts');\n if (projectInfo.tsc?.outDir && filename !== 'README.md') {\n jsFile = path.join(projectInfo.tsc.outDir, jsFile);\n dtsFile = path.join(projectInfo.tsc.outDir, dtsFile);\n }\n\n // eslint-disable-next-line no-await-in-loop\n files[jsFile] = fs.readFileSync(jsFile, { encoding: 'utf-8' });\n // eslint-disable-next-line no-await-in-loop\n files[dtsFile] = fs.readFileSync(dtsFile, { encoding: 'utf-8' });\n\n const warningsFileName = '.warnings.jsii.js';\n if (fs.existsSync(warningsFileName)) {\n // eslint-disable-next-line no-await-in-loop\n files[warningsFileName] = fs.readFileSync(warningsFileName, {\n encoding: 'utf-8',\n });\n }\n }\n\n return {\n assembly,\n files,\n packageJson,\n compressAssembly: isOptionsObject(options) && options.compressAssembly ? true : false,\n } as HelperCompilationResult;\n });\n}\n\nfunction inTempDir<T>(block: () => T): T {\n const origDir = process.cwd();\n const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'jsii'));\n process.chdir(tmpDir);\n const ret = block();\n process.chdir(origDir);\n fs.rmSync(tmpDir, { force: true, recursive: true });\n return ret;\n}\n\nfunction inOtherDir(dir: string) {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint\n return <T extends unknown>(block: () => T): T => {\n const origDir = process.cwd();\n process.chdir(dir);\n try {\n return block();\n } finally {\n process.chdir(origDir);\n }\n };\n}\n\n/**\n * Obtain project info so we can call the compiler\n *\n * Creating this directly in-memory leads to slightly different behavior from calling\n * jsii from the command-line, and I don't want to figure out right now.\n *\n * Most consistent behavior seems to be to write a package.json to disk and\n * then calling the same functions as the CLI would.\n */\nfunction makeProjectInfo(\n types: string,\n cb?: (obj: PackageJson) => void,\n): { projectInfo: ProjectInfo; packageJson: PackageJson } {\n const packageJson: PackageJson = {\n types,\n main: types.replace(/(?:\\.d)?\\.ts(x?)/, '.js$1'),\n name: 'testpkg', // That's what package.json would tell if we look up...\n version: '0.0.1',\n license: 'Apache-2.0',\n author: { name: 'John Doe' },\n repository: { type: 'git', url: 'https://github.com/aws/jsii.git' },\n jsii: {},\n };\n\n if (cb) {\n cb(packageJson);\n }\n\n fs.writeFileSync(\n 'package.json',\n JSON.stringify(packageJson, (_: string, v: any) => v, 2),\n 'utf-8',\n );\n\n const { projectInfo } = loadProjectInfo(path.resolve(process.cwd(), '.'));\n return { projectInfo, packageJson };\n}\n\nexport interface TestCompilationOptions {\n /**\n * The directory in which we write and compile the files\n */\n readonly compilationDirectory?: string;\n\n /**\n * Parts of projectInfo to override (package name etc)\n *\n * @deprecated Prefer using `packageJson` instead.\n */\n readonly projectInfo?: Partial<PackageJson>;\n\n /**\n * Parts of projectInfo to override (package name etc)\n *\n * @default - Use some default values\n */\n readonly packageJson?: Partial<PackageJson>;\n\n /**\n * Whether to compress the assembly file.\n *\n * @default false\n */\n readonly compressAssembly?: boolean;\n}\n\nfunction isOptionsObject(\n x: TestCompilationOptions | ((obj: PackageJson) => void) | undefined,\n): x is TestCompilationOptions {\n return x ? typeof x === 'object' : false;\n}\n\n/**\n * An NPM-ready workspace where we can install test-compile dependencies and compile new assemblies\n */\nexport class TestWorkspace {\n /**\n * Create a new workspace.\n *\n * Creates a temporary directory, don't forget to call cleanUp\n */\n public static create(): TestWorkspace {\n const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'jsii-testworkspace'));\n fs.mkdirSync(tmpDir, { recursive: true });\n return new TestWorkspace(tmpDir);\n }\n\n /**\n * Execute a block with a temporary workspace\n */\n public static withWorkspace<A>(block: (ws: TestWorkspace) => A): A {\n const ws = TestWorkspace.create();\n try {\n return block(ws);\n } finally {\n ws.cleanup();\n }\n }\n\n private readonly installed = new Set<string>();\n\n private constructor(public readonly rootDirectory: string) {}\n\n /**\n * Add a test-compiled jsii assembly as a dependency\n */\n public addDependency(dependencyAssembly: HelperCompilationResult) {\n if (this.installed.has(dependencyAssembly.assembly.name)) {\n throw new Error(\n `A dependency with name '${dependencyAssembly.assembly.name}' was already installed. Give one a different name.`,\n );\n }\n this.installed.add(dependencyAssembly.assembly.name);\n\n // The following is silly, however: the helper has compiled the given source to\n // an assembly, and output files, and then removed their traces from disk.\n // We need those files back on disk, so write them back out again.\n //\n // We will drop them in 'node_modules/<name>' so they can be imported\n // as if they were installed.\n const modDir = path.join(this.rootDirectory, 'node_modules', dependencyAssembly.assembly.name);\n fs.mkdirSync(modDir, { recursive: true });\n\n writeAssembly(modDir, dependencyAssembly.assembly, {\n compress: dependencyAssembly.compressAssembly,\n });\n fs.writeFileSync(\n path.join(modDir, 'package.json'),\n JSON.stringify(dependencyAssembly.packageJson, null, 2),\n 'utf-8',\n );\n\n for (const [fileName, fileContents] of Object.entries(dependencyAssembly.files)) {\n fs.mkdirSync(path.dirname(path.join(modDir, fileName)), {\n recursive: true,\n });\n fs.writeFileSync(path.join(modDir, fileName), fileContents);\n }\n }\n\n public dependencyDir(name: string) {\n if (!this.installed.has(name)) {\n throw new Error(`No dependency with name '${name}' has been installed`);\n }\n return path.join(this.rootDirectory, 'node_modules', name);\n }\n\n public cleanup() {\n fs.rmSync(this.rootDirectory, { force: true, recursive: true });\n }\n}\n\n// Alias for backwards compatibility\nexport type PackageInfo = PackageJson;\n"]}
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,8BAA8B;AAC9B,8BAA8B;AAC9B,kCAAkC;AAClC,qCAA8E;AAE9E,2CAAgD;AAEhD,yCAAuD;AACvD,iDAA8D;AAC9D,mCAA2C;AAU3C;;;;;;;;;GASG;AACH,SAAgB,sBAAsB,CACpC,MAAoC,EACpC,OAA+D;IAE/D,OAAO,kBAAkB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC;AACtD,CAAC;AALD,wDAKC;AAwBD;;;;;;;;;GASG;AACH,SAAgB,kBAAkB,CAChC,MAA+D,EAC/D,OAA+D,EAC/D,eAAgE;IAEhE,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC/B,MAAM,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC;IAClC,CAAC;IAED,MAAM,cAAc,GAClB,eAAe,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAElH,oFAAoF;IACpF,+EAA+E;IAC/E,OAAO,cAAc,CAAC,GAAG,EAAE;QACzB,KAAK,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YACzD,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EA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C,CAAC,EAAE;gBACtD,SAAS,EAAE,IAAI;aAChB,CAAC,CAAC;YACH,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,YAAY,CAAC,CAAC;QAC9D,CAAC;IACH,CAAC;IAEM,aAAa,CAAC,IAAY;QAC/B,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CAAC,4BAA4B,IAAI,sBAAsB,CAAC,CAAC;QAC1E,CAAC;QACD,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,cAAc,EAAE,IAAI,CAAC,CAAC;IAC7D,CAAC;IAEM,OAAO;QACZ,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAClE,CAAC;CACF;AA3ED,sCA2EC;AAKD;;;;;;;GAOG;AACH,SAAgB,mBAAmB,CAAC,IAAY,EAAE,eAAwB;IACxE,IAAI,eAAe,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE,CAAC;QACjE,OAAO,eAAe,CAAC;IACzB,CAAC;IACD,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;AAC9C,CAAC;AALD,kDAKC","sourcesContent":["/**\n * Helper routines for use with the jsii compiler\n *\n * These are mostly used for testing, but all projects that need to exercise\n * the JSII compiler to test something need to share this code, so might as\n * well put it in one reusable place.\n */\n\nimport * as fs from 'node:fs';\nimport * as os from 'node:os';\nimport * as path from 'node:path';\nimport { PackageJson, loadAssemblyFromPath, writeAssembly } from '@jsii/spec';\nimport * as spec from '@jsii/spec';\nimport { DiagnosticCategory } from 'typescript';\n\nimport { Compiler, CompilerOptions } from './compiler';\nimport { loadProjectInfo, ProjectInfo } from './project-info';\nimport { formatDiagnostic } from './utils';\n\n/**\n * A set of source files for `sourceToAssemblyHelper`, at least containing 'index.ts'\n */\nexport type MultipleSourceFiles = {\n 'index.ts': string;\n [name: string]: string;\n};\n\n/**\n * Compile a piece of source and return the JSII assembly for it\n *\n * Only usable for trivial cases and tests.\n *\n * @param source can either be a single `string` (the content of `index.ts`), or\n * a map of fileName to content, which *must* include `index.ts`.\n * @param options accepts a callback for historical reasons but really expects to\n * take an options object.\n */\nexport function sourceToAssemblyHelper(\n source: string | MultipleSourceFiles,\n options?: TestCompilationOptions | ((obj: PackageJson) => void),\n): spec.Assembly {\n return compileJsiiForTest(source, options).assembly;\n}\n\nexport interface HelperCompilationResult {\n /**\n * The generated assembly\n */\n readonly assembly: spec.Assembly;\n\n /**\n * Generated .js/.d.ts file(s)\n */\n readonly files: Record<string, string>;\n\n /**\n * The packageInfo used\n */\n readonly packageJson: PackageJson;\n\n /**\n * Whether to compress the assembly file\n */\n readonly compressAssembly: boolean;\n}\n\n/**\n * Compile a piece of source and return the assembly and compiled sources for it\n *\n * Only usable for trivial cases and tests.\n *\n * @param source can either be a single `string` (the content of `index.ts`), or\n * a map of fileName to content, which *must* include `index.ts`.\n * @param options accepts a callback for historical reasons but really expects to\n * take an options object.\n */\nexport function compileJsiiForTest(\n source: string | { 'index.ts': string; [name: string]: string },\n options?: TestCompilationOptions | ((obj: PackageJson) => void),\n compilerOptions?: Omit<CompilerOptions, 'projectInfo' | 'watch'>,\n): HelperCompilationResult {\n if (typeof source === 'string') {\n source = { 'index.ts': source };\n }\n\n const inSomeLocation =\n isOptionsObject(options) && options.compilationDirectory ? inOtherDir(options.compilationDirectory) : inTempDir;\n\n // Easiest way to get the source into the compiler is to write it to disk somewhere.\n // I guess we could make an in-memory compiler host but that seems like work...\n return inSomeLocation(() => {\n for (const [fileName, content] of Object.entries(source)) {\n fs.mkdirSync(path.dirname(fileName), { recursive: true });\n fs.writeFileSync(fileName, content, { encoding: 'utf-8' });\n }\n const { projectInfo, packageJson } = makeProjectInfo(\n 'index.ts',\n typeof options === 'function'\n ? options\n : (pi) => {\n Object.assign(pi, options?.packageJson ?? options?.projectInfo ?? {});\n },\n );\n const compiler = new Compiler({\n projectInfo,\n ...compilerOptions,\n });\n const emitResult = compiler.emit();\n\n const errors = emitResult.diagnostics.filter((d) => d.category === DiagnosticCategory.Error);\n for (const error of errors) {\n console.error(formatDiagnostic(error, projectInfo.projectRoot));\n // logDiagnostic() doesn't work out of the box, so console.error() it is.\n }\n if (errors.length > 0 || emitResult.emitSkipped) {\n throw new Error('There were compiler errors');\n }\n const assembly = loadAssemblyFromPath(process.cwd(), false);\n const files: Record<string, string> = {};\n\n for (const filename of Object.keys(source)) {\n let jsFile = filename.replace(/\\.ts$/, '.js');\n let dtsFile = filename.replace(/\\.ts$/, '.d.ts');\n if (projectInfo.tsc?.outDir && filename !== 'README.md') {\n jsFile = path.join(projectInfo.tsc.outDir, jsFile);\n dtsFile = path.join(projectInfo.tsc.outDir, dtsFile);\n }\n\n // eslint-disable-next-line no-await-in-loop\n files[jsFile] = fs.readFileSync(jsFile, { encoding: 'utf-8' });\n // eslint-disable-next-line no-await-in-loop\n files[dtsFile] = fs.readFileSync(dtsFile, { encoding: 'utf-8' });\n\n const warningsFileName = '.warnings.jsii.js';\n if (fs.existsSync(warningsFileName)) {\n // eslint-disable-next-line no-await-in-loop\n files[warningsFileName] = fs.readFileSync(warningsFileName, {\n encoding: 'utf-8',\n });\n }\n }\n\n return {\n assembly,\n files,\n packageJson,\n compressAssembly: isOptionsObject(options) && options.compressAssembly ? true : false,\n } as HelperCompilationResult;\n });\n}\n\nfunction inTempDir<T>(block: () => T): T {\n const origDir = process.cwd();\n const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'jsii'));\n process.chdir(tmpDir);\n const ret = block();\n process.chdir(origDir);\n fs.rmSync(tmpDir, { force: true, recursive: true });\n return ret;\n}\n\nfunction inOtherDir(dir: string) {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-constraint\n return <T extends unknown>(block: () => T): T => {\n const origDir = process.cwd();\n process.chdir(dir);\n try {\n return block();\n } finally {\n process.chdir(origDir);\n }\n };\n}\n\n/**\n * Obtain project info so we can call the compiler\n *\n * Creating this directly in-memory leads to slightly different behavior from calling\n * jsii from the command-line, and I don't want to figure out right now.\n *\n * Most consistent behavior seems to be to write a package.json to disk and\n * then calling the same functions as the CLI would.\n */\nfunction makeProjectInfo(\n types: string,\n cb?: (obj: PackageJson) => void,\n): { projectInfo: ProjectInfo; packageJson: PackageJson } {\n const packageJson: PackageJson = {\n types,\n main: types.replace(/(?:\\.d)?\\.ts(x?)/, '.js$1'),\n name: 'testpkg', // That's what package.json would tell if we look up...\n version: '0.0.1',\n license: 'Apache-2.0',\n author: { name: 'John Doe' },\n repository: { type: 'git', url: 'https://github.com/aws/jsii.git' },\n jsii: {},\n };\n\n if (cb) {\n cb(packageJson);\n }\n\n fs.writeFileSync(\n 'package.json',\n JSON.stringify(packageJson, (_: string, v: any) => v, 2),\n 'utf-8',\n );\n\n const { projectInfo } = loadProjectInfo(path.resolve(process.cwd(), '.'));\n return { projectInfo, packageJson };\n}\n\nexport interface TestCompilationOptions {\n /**\n * The directory in which we write and compile the files\n */\n readonly compilationDirectory?: string;\n\n /**\n * Parts of projectInfo to override (package name etc)\n *\n * @deprecated Prefer using `packageJson` instead.\n */\n readonly projectInfo?: Partial<PackageJson>;\n\n /**\n * Parts of projectInfo to override (package name etc)\n *\n * @default - Use some default values\n */\n readonly packageJson?: Partial<PackageJson>;\n\n /**\n * Whether to compress the assembly file.\n *\n * @default false\n */\n readonly compressAssembly?: boolean;\n}\n\nfunction isOptionsObject(\n x: TestCompilationOptions | ((obj: PackageJson) => void) | undefined,\n): x is TestCompilationOptions {\n return x ? typeof x === 'object' : false;\n}\n\n/**\n * An NPM-ready workspace where we can install test-compile dependencies and compile new assemblies\n */\nexport class TestWorkspace {\n /**\n * Create a new workspace.\n *\n * Creates a temporary directory, don't forget to call cleanUp\n */\n public static create(): TestWorkspace {\n const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'jsii-testworkspace'));\n fs.mkdirSync(tmpDir, { recursive: true });\n return new TestWorkspace(tmpDir);\n }\n\n /**\n * Execute a block with a temporary workspace\n */\n public static withWorkspace<A>(block: (ws: TestWorkspace) => A): A {\n const ws = TestWorkspace.create();\n try {\n return block(ws);\n } finally {\n ws.cleanup();\n }\n }\n\n private readonly installed = new Set<string>();\n\n private constructor(public readonly rootDirectory: string) {}\n\n /**\n * Add a test-compiled jsii assembly as a dependency\n */\n public addDependency(dependencyAssembly: HelperCompilationResult) {\n if (this.installed.has(dependencyAssembly.assembly.name)) {\n throw new Error(\n `A dependency with name '${dependencyAssembly.assembly.name}' was already installed. Give one a different name.`,\n );\n }\n this.installed.add(dependencyAssembly.assembly.name);\n\n // The following is silly, however: the helper has compiled the given source to\n // an assembly, and output files, and then removed their traces from disk.\n // We need those files back on disk, so write them back out again.\n //\n // We will drop them in 'node_modules/<name>' so they can be imported\n // as if they were installed.\n const modDir = path.join(this.rootDirectory, 'node_modules', dependencyAssembly.assembly.name);\n fs.mkdirSync(modDir, { recursive: true });\n\n writeAssembly(modDir, dependencyAssembly.assembly, {\n compress: dependencyAssembly.compressAssembly,\n });\n fs.writeFileSync(\n path.join(modDir, 'package.json'),\n JSON.stringify(dependencyAssembly.packageJson, null, 2),\n 'utf-8',\n );\n\n for (const [fileName, fileContents] of Object.entries(dependencyAssembly.files)) {\n fs.mkdirSync(path.dirname(path.join(modDir, fileName)), {\n recursive: true,\n });\n fs.writeFileSync(path.join(modDir, fileName), fileContents);\n }\n }\n\n public dependencyDir(name: string) {\n if (!this.installed.has(name)) {\n throw new Error(`No dependency with name '${name}' has been installed`);\n }\n return path.join(this.rootDirectory, 'node_modules', name);\n }\n\n public cleanup() {\n fs.rmSync(this.rootDirectory, { force: true, recursive: true });\n }\n}\n\n// Alias for backwards compatibility\nexport type PackageInfo = PackageJson;\n\n/**\n * TSConfig paths can either be relative to the project or absolute.\n * This function normalizes paths to be relative to the provided root.\n * After normalization, code using these paths can be much simpler.\n *\n * @param root the project root\n * @param pathToNormalize the path to normalize, might be empty\n */\nexport function normalizeConfigPath(root: string, pathToNormalize?: string): string | undefined {\n if (pathToNormalize == null || !path.isAbsolute(pathToNormalize)) {\n return pathToNormalize;\n }\n return path.relative(root, pathToNormalize);\n}\n"]}
@@ -7,5 +7,6 @@ const incompatibleOptions = new validator_1.RuleSet();
7
7
  incompatibleOptions.shouldFail('noEmit', validator_1.Match.TRUE);
8
8
  incompatibleOptions.shouldFail('noLib', validator_1.Match.TRUE);
9
9
  incompatibleOptions.shouldFail('declaration', validator_1.Match.FALSE);
10
+ incompatibleOptions.shouldFail('emitDeclarationOnly', validator_1.Match.TRUE);
10
11
  exports.default = incompatibleOptions;
11
12
  //# sourceMappingURL=incompatible-options.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"incompatible-options.js","sourceRoot":"","sources":["../../../src/tsconfig/rulesets/incompatible-options.ts"],"names":[],"mappings":";;AAAA,4CAA8C;AAE9C,iGAAiG;AACjG,qEAAqE;AACrE,MAAM,mBAAmB,GAAG,IAAI,mBAAO,EAAE,CAAC;AAC1C,mBAAmB,CAAC,UAAU,CAAC,QAAQ,EAAE,iBAAK,CAAC,IAAI,CAAC,CAAC;AACrD,mBAAmB,CAAC,UAAU,CAAC,OAAO,EAAE,iBAAK,CAAC,IAAI,CAAC,CAAC;AACpD,mBAAmB,CAAC,UAAU,CAAC,aAAa,EAAE,iBAAK,CAAC,KAAK,CAAC,CAAC;AAE3D,kBAAe,mBAAmB,CAAC","sourcesContent":["import { Match, RuleSet } from '../validator';\n\n// A rule set defining all compilerOptions that are explicitly known to be incompatible with jsii\n// This is an internal rule set, that may be used by other rule sets.\nconst incompatibleOptions = new RuleSet();\nincompatibleOptions.shouldFail('noEmit', Match.TRUE);\nincompatibleOptions.shouldFail('noLib', Match.TRUE);\nincompatibleOptions.shouldFail('declaration', Match.FALSE);\n\nexport default incompatibleOptions;\n"]}
1
+ {"version":3,"file":"incompatible-options.js","sourceRoot":"","sources":["../../../src/tsconfig/rulesets/incompatible-options.ts"],"names":[],"mappings":";;AAAA,4CAA8C;AAE9C,iGAAiG;AACjG,qEAAqE;AACrE,MAAM,mBAAmB,GAAG,IAAI,mBAAO,EAAE,CAAC;AAC1C,mBAAmB,CAAC,UAAU,CAAC,QAAQ,EAAE,iBAAK,CAAC,IAAI,CAAC,CAAC;AACrD,mBAAmB,CAAC,UAAU,CAAC,OAAO,EAAE,iBAAK,CAAC,IAAI,CAAC,CAAC;AACpD,mBAAmB,CAAC,UAAU,CAAC,aAAa,EAAE,iBAAK,CAAC,KAAK,CAAC,CAAC;AAC3D,mBAAmB,CAAC,UAAU,CAAC,qBAAqB,EAAE,iBAAK,CAAC,IAAI,CAAC,CAAC;AAElE,kBAAe,mBAAmB,CAAC","sourcesContent":["import { Match, RuleSet } from '../validator';\n\n// A rule set defining all compilerOptions that are explicitly known to be incompatible with jsii\n// This is an internal rule set, that may be used by other rule sets.\nconst incompatibleOptions = new RuleSet();\nincompatibleOptions.shouldFail('noEmit', Match.TRUE);\nincompatibleOptions.shouldFail('noLib', Match.TRUE);\nincompatibleOptions.shouldFail('declaration', Match.FALSE);\nincompatibleOptions.shouldFail('emitDeclarationOnly', Match.TRUE);\n\nexport default incompatibleOptions;\n"]}
@@ -27,6 +27,7 @@ strict.shouldPass('esModuleInterop', validator_1.Match.TRUE);
27
27
  strict.shouldPass('skipLibCheck', validator_1.Match.TRUE);
28
28
  strict.shouldPass('stripInternal', validator_1.Match.optional(validator_1.Match.FALSE));
29
29
  strict.shouldPass('noEmitOnError', validator_1.Match.TRUE);
30
+ strict.shouldPass('declaration', validator_1.Match.TRUE);
30
31
  // Deprecated ts options that should not be used with jsii
31
32
  strict.import(deprecated_options_1.default);
32
33
  exports.default = strict;
@@ -1 +1 @@
1
- {"version":3,"file":"strict.public.js","sourceRoot":"","sources":["../../../src/tsconfig/rulesets/strict.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AAe,EAAE,iBAAK,CAAC,IAAI,CAAC,CAAC;AAE/C,0DAA0D;AAC1D,MAAM,CAAC,MAAM,CAAC,4BAAiB,CAAC,CAAC;AAEjC,kBAAe,MAAM,CAAC","sourcesContent":["import configurableOptions from './configurable-options';\nimport deprecatedOptions from './deprecated-options';\nimport incompatibleOptions from './incompatible-options';\nimport strictFamilyOptions from './strict-family-options';\nimport { Match, RuleSet, RuleType } from '../validator';\n\n// The public rule set used for the \"strict\" tsconfig validation setting.\n// The goal of this rule set is to ensure a tsconfig that is following best practices for jsii.\n// In practice, this is a combination of known incompatible options, known configurable options and additional best practices.\n// The rule set also explicitly disallows unknown options.\nconst strict = new RuleSet({\n unexpectedFields: RuleType.FAIL,\n});\n\n// import all options that are configurable\nstrict.import(configurableOptions);\n\n// import all options that are definitely incompatible\nstrict.import(incompatibleOptions);\n\n// strict family options\nstrict.import(strictFamilyOptions);\n\n// Best practice rules\nstrict.shouldPass('target', Match.eq('es2022')); // node18\nstrict.shouldPass('lib', Match.arrEq(['es2022'])); // node18\nstrict.shouldPass('module', Match.oneOf('node16', 'commonjs'));\nstrict.shouldPass('moduleResolution', Match.optional(Match.oneOf('node', 'node16')));\nstrict.shouldPass('esModuleInterop', Match.TRUE);\nstrict.shouldPass('skipLibCheck', Match.TRUE);\nstrict.shouldPass('stripInternal', Match.optional(Match.FALSE));\nstrict.shouldPass('noEmitOnError', Match.TRUE);\n\n// Deprecated ts options that should not be used with jsii\nstrict.import(deprecatedOptions);\n\nexport default strict;\n"]}
1
+ {"version":3,"file":"strict.public.js","sourceRoot":"","sources":["../../../src/tsconfig/rulesets/strict.public.ts"],"names":[],"mappings":";;AAAA,iEAAyD;AACzD,6DAAqD;AACrD,iEAAyD;AACzD,mEAA0D;AAC1D,4CAAwD;AAExD,yEAAyE;AACzE,+FAA+F;AAC/F,8HAA8H;AAC9H,0DAA0D;AAC1D,MAAM,MAAM,GAAG,IAAI,mBAAO,CAAC;IACzB,gBAAgB,EAAE,oBAAQ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ions from './configurable-options';\nimport deprecatedOptions from './deprecated-options';\nimport incompatibleOptions from './incompatible-options';\nimport strictFamilyOptions from './strict-family-options';\nimport { Match, RuleSet, RuleType } from '../validator';\n\n// The public rule set used for the \"strict\" tsconfig validation setting.\n// The goal of this rule set is to ensure a tsconfig that is following best practices for jsii.\n// In practice, this is a combination of known incompatible options, known configurable options and additional best practices.\n// The rule set also explicitly disallows unknown options.\nconst strict = new RuleSet({\n unexpectedFields: RuleType.FAIL,\n});\n\n// import all options that are configurable\nstrict.import(configurableOptions);\n\n// import all options that are definitely incompatible\nstrict.import(incompatibleOptions);\n\n// strict family options\nstrict.import(strictFamilyOptions);\n\n// Best practice rules\nstrict.shouldPass('target', Match.eq('es2022')); // node18\nstrict.shouldPass('lib', Match.arrEq(['es2022'])); // node18\nstrict.shouldPass('module', Match.oneOf('node16', 'commonjs'));\nstrict.shouldPass('moduleResolution', Match.optional(Match.oneOf('node', 'node16')));\nstrict.shouldPass('esModuleInterop', Match.TRUE);\nstrict.shouldPass('skipLibCheck', Match.TRUE);\nstrict.shouldPass('stripInternal', Match.optional(Match.FALSE));\nstrict.shouldPass('noEmitOnError', Match.TRUE);\nstrict.shouldPass('declaration', Match.TRUE);\n\n// Deprecated ts options that should not be used with jsii\nstrict.import(deprecatedOptions);\n\nexport default strict;\n"]}
package/lib/version.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /** The short version number for this JSII compiler (e.g: `X.Y.Z`) */
2
- export declare const SHORT_VERSION = "5.4.32-dev.2";
2
+ export declare const SHORT_VERSION = "5.4.33-dev.0";
3
3
  /** The qualified version number for this JSII compiler (e.g: `X.Y.Z (build #######)`) */
4
- export declare const VERSION = "5.4.32-dev.2 (build 12c32d5)";
4
+ export declare const VERSION = "5.4.33-dev.0 (build 0945871)";
5
5
  /** The release line identifier for this JSII compiler (e.g: `X.Y`) */
6
6
  export declare const RELEASE_LINE = "5.4";
7
7
  //# sourceMappingURL=version.d.ts.map
package/lib/version.js CHANGED
@@ -4,9 +4,9 @@ exports.RELEASE_LINE = exports.VERSION = exports.SHORT_VERSION = void 0;
4
4
  const typescript_1 = require("typescript");
5
5
  // GENERATED: This file is generated by build-tools/code-gen.ts -- Do not edit by hand!
6
6
  /** The short version number for this JSII compiler (e.g: `X.Y.Z`) */
7
- exports.SHORT_VERSION = '5.4.32-dev.2';
7
+ exports.SHORT_VERSION = '5.4.33-dev.0';
8
8
  /** The qualified version number for this JSII compiler (e.g: `X.Y.Z (build #######)`) */
9
- exports.VERSION = '5.4.32-dev.2 (build 12c32d5)';
9
+ exports.VERSION = '5.4.33-dev.0 (build 0945871)';
10
10
  /** The release line identifier for this JSII compiler (e.g: `X.Y`) */
11
11
  exports.RELEASE_LINE = typescript_1.versionMajorMinor;
12
12
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAE/C,uFAAuF;AAEvF,qEAAqE;AACxD,QAAA,aAAa,GAAG,cAAc,CAAC;AAE5C,yFAAyF;AAC5E,QAAA,OAAO,GAAG,8BAA8B,CAAC;AAEtD,sEAAsE;AACzD,QAAA,YAAY,GAAG,8BAAiB,CAAC","sourcesContent":["import { versionMajorMinor } from 'typescript';\n\n// GENERATED: This file is generated by build-tools/code-gen.ts -- Do not edit by hand!\n\n/** The short version number for this JSII compiler (e.g: `X.Y.Z`) */\nexport const SHORT_VERSION = '5.4.32-dev.2';\n\n/** The qualified version number for this JSII compiler (e.g: `X.Y.Z (build #######)`) */\nexport const VERSION = '5.4.32-dev.2 (build 12c32d5)';\n\n/** The release line identifier for this JSII compiler (e.g: `X.Y`) */\nexport const RELEASE_LINE = versionMajorMinor;\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";;;AAAA,2CAA+C;AAE/C,uFAAuF;AAEvF,qEAAqE;AACxD,QAAA,aAAa,GAAG,cAAc,CAAC;AAE5C,yFAAyF;AAC5E,QAAA,OAAO,GAAG,8BAA8B,CAAC;AAEtD,sEAAsE;AACzD,QAAA,YAAY,GAAG,8BAAiB,CAAC","sourcesContent":["import { versionMajorMinor } from 'typescript';\n\n// GENERATED: This file is generated by build-tools/code-gen.ts -- Do not edit by hand!\n\n/** The short version number for this JSII compiler (e.g: `X.Y.Z`) */\nexport const SHORT_VERSION = '5.4.33-dev.0';\n\n/** The qualified version number for this JSII compiler (e.g: `X.Y.Z (build #######)`) */\nexport const VERSION = '5.4.33-dev.0 (build 0945871)';\n\n/** The release line identifier for this JSII compiler (e.g: `X.Y`) */\nexport const RELEASE_LINE = versionMajorMinor;\n"]}