jsii 5.9.44 → 6.0.0-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/README.md +73 -289
- package/lib/assembler.js +95 -46
- package/lib/assembler.js.map +1 -1
- package/lib/case.js +13 -10
- package/lib/case.js.map +1 -1
- package/lib/common/find-utils.js +35 -2
- package/lib/common/find-utils.js.map +1 -1
- package/lib/common/symbol-id.js +39 -7
- package/lib/common/symbol-id.js.map +1 -1
- package/lib/compiler.js +51 -8
- package/lib/compiler.js.map +1 -1
- package/lib/directives.js +48 -16
- package/lib/directives.js.map +1 -1
- package/lib/docs.js +36 -4
- package/lib/docs.js.map +1 -1
- package/lib/helpers.js +38 -4
- package/lib/helpers.js.map +1 -1
- package/lib/jsii-diagnostic.js +524 -497
- package/lib/jsii-diagnostic.js.map +1 -1
- package/lib/literate.js +35 -2
- package/lib/literate.js.map +1 -1
- package/lib/main.js +40 -7
- package/lib/main.js.map +1 -1
- package/lib/project-info.d.ts +1 -1
- package/lib/project-info.js +41 -11
- package/lib/project-info.js.map +1 -1
- package/lib/support.js +7 -4
- package/lib/support.js.map +1 -1
- package/lib/transforms/deprecated-remover.js +65 -23
- package/lib/transforms/deprecated-remover.js.map +1 -1
- package/lib/transforms/deprecation-warnings.js +50 -10
- package/lib/transforms/deprecation-warnings.js.map +1 -1
- package/lib/transforms/runtime-info.js +36 -2
- package/lib/transforms/runtime-info.js.map +1 -1
- package/lib/tsconfig/compiler-options.js +40 -5
- package/lib/tsconfig/compiler-options.js.map +1 -1
- package/lib/tsconfig/rulesets/configurable-options.js +10 -1
- package/lib/tsconfig/rulesets/configurable-options.js.map +1 -1
- package/lib/tsconfig/rulesets/deprecated-options.js +16 -1
- package/lib/tsconfig/rulesets/deprecated-options.js.map +1 -1
- package/lib/tsconfig/rulesets/generated.public.js +7 -2
- package/lib/tsconfig/rulesets/generated.public.js.map +1 -1
- package/lib/tsconfig/rulesets/jsii-configured-options.js +0 -1
- package/lib/tsconfig/rulesets/jsii-configured-options.js.map +1 -1
- package/lib/tsconfig/rulesets/minimal.public.js +4 -1
- package/lib/tsconfig/rulesets/minimal.public.js.map +1 -1
- package/lib/tsconfig/rulesets/strict.public.js +12 -9
- package/lib/tsconfig/rulesets/strict.public.js.map +1 -1
- package/lib/tsconfig/tsconfig-validator.js +9 -3
- package/lib/tsconfig/tsconfig-validator.js.map +1 -1
- package/lib/tsconfig/validator.d.ts +5 -0
- package/lib/tsconfig/validator.js +26 -16
- package/lib/tsconfig/validator.js.map +1 -1
- package/lib/type-analysis.js +39 -3
- package/lib/type-analysis.js.map +1 -1
- package/lib/type-reference.js +34 -1
- package/lib/type-reference.js.map +1 -1
- package/lib/type-tracker.js +35 -4
- package/lib/type-tracker.js.map +1 -1
- package/lib/type-visitor.js +34 -1
- package/lib/type-visitor.js.map +1 -1
- package/lib/utils.js +37 -2
- package/lib/utils.js.map +1 -1
- package/lib/validator.js +49 -11
- package/lib/validator.js.map +1 -1
- package/lib/version.d.ts +3 -3
- package/lib/version.js +2 -2
- package/lib/version.js.map +1 -1
- package/lib/warnings.js +34 -1
- package/lib/warnings.js.map +1 -1
- package/package.json +7 -8
- package/releases.json +3 -2
package/lib/case.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.kebab = exports.snake = exports.pascal = exports.constant = exports.camel = void 0;
|
|
4
|
-
const
|
|
7
|
+
const case_1 = __importDefault(require("case"));
|
|
5
8
|
const withCache = (func) => (text) => Cache.fetch(text, func);
|
|
6
|
-
exports.camel = withCache(
|
|
7
|
-
exports.constant = withCache(
|
|
8
|
-
exports.pascal = withCache(
|
|
9
|
-
exports.snake = withCache(
|
|
10
|
-
exports.kebab = withCache(
|
|
9
|
+
exports.camel = withCache(case_1.default.camel);
|
|
10
|
+
exports.constant = withCache(case_1.default.constant);
|
|
11
|
+
exports.pascal = withCache(case_1.default.pascal);
|
|
12
|
+
exports.snake = withCache(case_1.default.snake);
|
|
13
|
+
exports.kebab = withCache(case_1.default.kebab);
|
|
11
14
|
class Cache {
|
|
12
15
|
static fetch(text, func) {
|
|
13
16
|
// Check whether we have a cache for this function...
|
|
@@ -28,10 +31,10 @@ class Cache {
|
|
|
28
31
|
cache.set(text, result);
|
|
29
32
|
return result;
|
|
30
33
|
}
|
|
34
|
+
// Cache is indexed on a weak CacheKey so the cache can be purged under memory pressure
|
|
35
|
+
static CACHES = new WeakMap();
|
|
31
36
|
constructor() { }
|
|
32
37
|
}
|
|
33
|
-
// Cache is indexed on a weak CacheKey so the cache can be purged under memory pressure
|
|
34
|
-
Cache.CACHES = new WeakMap();
|
|
35
38
|
class CacheKey {
|
|
36
39
|
static for(data) {
|
|
37
40
|
const entry = this.STORE.get(data)?.deref();
|
|
@@ -42,8 +45,8 @@ class CacheKey {
|
|
|
42
45
|
this.STORE.set(data, new WeakRef(newKey));
|
|
43
46
|
return newKey;
|
|
44
47
|
}
|
|
48
|
+
// Storing cache keys as weak references to allow garbage collection if there is memory pressure.
|
|
49
|
+
static STORE = new Map();
|
|
45
50
|
constructor() { }
|
|
46
51
|
}
|
|
47
|
-
// Storing cache keys as weak references to allow garbage collection if there is memory pressure.
|
|
48
|
-
CacheKey.STORE = new Map();
|
|
49
52
|
//# sourceMappingURL=case.js.map
|
package/lib/case.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"case.js","sourceRoot":"","sources":["../src/case.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"case.js","sourceRoot":"","sources":["../src/case.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAExB,MAAM,SAAS,GACb,CAAC,IAA8B,EAA8B,EAAE,CAC/D,CAAC,IAAY,EAAE,EAAE,C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B,MAAM,QAAQ;IACL,MAAM,CAAC,GAAG,CAAC,IAAS;QACzB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC;QAC5C,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;YAClB,OAAO,KAAK,CAAC;QACf,CAAC;QACD,MAAM,MAAM,GAAG,IAAI,QAAQ,EAAE,CAAC;QAC9B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;QAC1C,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,iGAAiG;IACzF,MAAM,CAAU,KAAK,GAAG,IAAI,GAAG,EAA0B,CAAC;IAElE,gBAAuB,CAAC","sourcesContent":["import Case from 'case';\n\nconst withCache =\n (func: (text: string) => string): ((text: string) => string) =>\n (text: string) =>\n Cache.fetch(text, func);\n\nexport const camel = withCache(Case.camel);\nexport const constant = withCache(Case.constant);\nexport const pascal = withCache(Case.pascal);\nexport const snake = withCache(Case.snake);\nexport const kebab = withCache(Case.kebab);\n\nclass Cache {\n public static fetch(text: string, func: (text: string) => string): string {\n // Check whether we have a cache for this function...\n const cacheKey = CacheKey.for(func);\n let cache = this.CACHES.get(cacheKey);\n if (cache == null) {\n // If not, create one...\n cache = new Map<string, string>();\n this.CACHES.set(cacheKey, cache);\n }\n\n // Check if the current cache has a value for this text...\n const cached = cache.get(text);\n if (cached != null) {\n return cached;\n }\n\n // If not, compute one...\n const result = func(text);\n cache.set(text, result);\n return result;\n }\n\n // Cache is indexed on a weak CacheKey so the cache can be purged under memory pressure\n private static readonly CACHES = new WeakMap<CacheKey, Map<string, string>>();\n\n private constructor() {}\n}\n\nclass CacheKey {\n public static for(data: any) {\n const entry = this.STORE.get(data)?.deref();\n if (entry != null) {\n return entry;\n }\n const newKey = new CacheKey();\n this.STORE.set(data, new WeakRef(newKey));\n return newKey;\n }\n\n // Storing cache keys as weak references to allow garbage collection if there is memory pressure.\n private static readonly STORE = new Map<any, WeakRef<CacheKey>>();\n\n private constructor() {}\n}\n"]}
|
package/lib/common/find-utils.js
CHANGED
|
@@ -1,10 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
36
|
exports.findUp = findUp;
|
|
4
37
|
exports.findPackageJsonUp = findPackageJsonUp;
|
|
5
38
|
exports.findDependencyDirectory = findDependencyDirectory;
|
|
6
|
-
const fs = require("node:fs");
|
|
7
|
-
const path = require("node:path");
|
|
39
|
+
const fs = __importStar(require("node:fs"));
|
|
40
|
+
const path = __importStar(require("node:path"));
|
|
8
41
|
const utils_1 = require("../utils");
|
|
9
42
|
/**
|
|
10
43
|
* Find a directory up the tree from a starting directory matching a condition
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find-utils.js","sourceRoot":"","sources":["../../src/common/find-utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"find-utils.js","sourceRoot":"","sources":["../../src/common/find-utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,wBAaC;AAQD,8CAKC;AAQD,0DAgBC;AA9DD,4CAA8B;AAC9B,gDAAkC;AAClC,oCAAqC;AAErC;;;;;;;GAOG;AACH,SAAgB,MAAM,CAAC,SAAiB,EAAE,IAA8B;IACtE,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC;IAE/B,IAAI,MAAM,EAAE,CAAC;QACX,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACvC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AAC9B,CAAC;AAED;;;;;GAKG;AACH,SAAgB,iBAAiB,CAAC,WAAmB,EAAE,SAAiB;IACtE,OAAO,MAAM,CAAC,SAAS,EAAE,CAAC,GAAG,EAAE,EAAE;QAC/B,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;QAC9C,OAAO,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,KAAK,WAAW,CAAC;IACpG,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;GAKG;AACH,SAAgB,uBAAuB,CAAC,cAAsB,EAAE,WAAmB;IACjF,oFAAoF;IACpF,gDAAgD;IAChD,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,cAAc,EAAE;QACjD,KAAK,EAAE,CAAC,WAAW,CAAC;KACrB,CAAC,CAAC;IAEH,8EAA8E;IAC9E,6EAA6E;IAC7E,MAAM,cAAc,GAAG,iBAAiB,CAAC,cAAc,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;IAEnF,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,MAAM,IAAI,iBAAS,CAAC,8BAA8B,cAAc,WAAW,WAAW,GAAG,CAAC,CAAC;IAC7F,CAAC;IAED,OAAO,cAAc,CAAC;AACxB,CAAC","sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { JsiiError } from '../utils';\n\n/**\n * Find a directory up the tree from a starting directory matching a condition\n *\n * Will return `undefined` if no directory matches\n *\n * (This code is duplicated among jsii/jsii-pacmak/jsii-reflect. Changes should be done in all\n * 3 locations, and we should unify these at some point: https://github.com/aws/jsii/issues/3236)\n */\nexport function findUp(directory: string, pred: (dir: string) => boolean): string | undefined {\n const result = pred(directory);\n\n if (result) {\n return directory;\n }\n\n const parent = path.dirname(directory);\n if (parent === directory) {\n return undefined;\n }\n\n return findUp(parent, pred);\n}\n\n/**\n * Find the package.json for a given package upwards from the given directory\n *\n * (This code is duplicated among jsii/jsii-pacmak/jsii-reflect. Changes should be done in all\n * 3 locations, and we should unify these at some point: https://github.com/aws/jsii/issues/3236)\n */\nexport function findPackageJsonUp(packageName: string, directory: string) {\n return findUp(directory, (dir) => {\n const pjFile = path.join(dir, 'package.json');\n return fs.existsSync(pjFile) && JSON.parse(fs.readFileSync(pjFile, 'utf-8')).name === packageName;\n });\n}\n\n/**\n * Find the directory that contains a given dependency, identified by its 'package.json', from a starting search directory\n *\n * (This code is duplicated among jsii/jsii-pacmak/jsii-reflect. Changes should be done in all\n * 3 locations, and we should unify these at some point: https://github.com/aws/jsii/issues/3236)\n */\nexport function findDependencyDirectory(dependencyName: string, searchStart: string) {\n // Explicitly do not use 'require(\"dep/package.json\")' because that will fail if the\n // package does not export that particular file.\n const entryPoint = require.resolve(dependencyName, {\n paths: [searchStart],\n });\n\n // Search up from the given directory, looking for a package.json that matches\n // the dependency name (so we don't accidentally find stray 'package.jsons').\n const depPkgJsonPath = findPackageJsonUp(dependencyName, path.dirname(entryPoint));\n\n if (!depPkgJsonPath) {\n throw new JsiiError(`Could not find dependency '${dependencyName}' from '${searchStart}'`);\n }\n\n return depPkgJsonPath;\n}\n"]}
|
package/lib/common/symbol-id.js
CHANGED
|
@@ -1,10 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
36
|
exports.symbolIdentifier = symbolIdentifier;
|
|
4
37
|
exports.normalizePath = normalizePath;
|
|
5
|
-
const fs = require("node:fs");
|
|
6
|
-
const path = require("node:path");
|
|
7
|
-
const ts = require("typescript");
|
|
38
|
+
const fs = __importStar(require("node:fs"));
|
|
39
|
+
const path = __importStar(require("node:path"));
|
|
40
|
+
const ts = __importStar(require("typescript"));
|
|
8
41
|
const find_utils_1 = require("./find-utils");
|
|
9
42
|
/**
|
|
10
43
|
* Return a symbol identifier for the given symbol
|
|
@@ -77,9 +110,9 @@ class Helper {
|
|
|
77
110
|
this.INSTANCES.set(typeChecker, helper);
|
|
78
111
|
return helper;
|
|
79
112
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
113
|
+
static INSTANCES = new WeakMap();
|
|
114
|
+
packageInfo = new Map();
|
|
115
|
+
constructor() { }
|
|
83
116
|
assemblyRelativeSourceFile(sourceFileName, asm) {
|
|
84
117
|
const packageInfo = this.findPackageInfo(path.dirname(sourceFileName));
|
|
85
118
|
if (!packageInfo) {
|
|
@@ -127,7 +160,6 @@ class Helper {
|
|
|
127
160
|
return result;
|
|
128
161
|
}
|
|
129
162
|
}
|
|
130
|
-
Helper.INSTANCES = new WeakMap();
|
|
131
163
|
/**
|
|
132
164
|
* Ensures that the sourcePath is pointing to the source code
|
|
133
165
|
* and not compiled code. This can happen if the root directory
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"symbol-id.js","sourceRoot":"","sources":["../../src/common/symbol-id.ts"],"names":[],"mappings":";;AAiDA,4CA4CC;AA2FD,sCAyBC;AAjND,8BAA8B;AAC9B,kCAAkC;AAElC,iCAAiC;AAEjC,6CAAsC;AAgBtC;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,SAAgB,gBAAgB,CAC9B,WAA2B,EAC3B,GAA0B,EAC1B,UAA2B,EAAE;IAE7B,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,0DAA0D;IAC1D,sCAAsC;IACtC,OAAO,CAAC,GAAG,CAAC,KAAK,GAAG,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;QAChD,GAAG,GAAG,WAAW,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;IAC1C,CAAC;IAED,MAAM,QAAQ;IACZ,sCAAsC;IACtC,CAAC,GAAG,CAAC,KAAK;QACR,sCAAsC;QACtC,CAAC,EAAE,CAAC,WAAW,CAAC,MAAM;YACpB,sCAAsC;YACtC,EAAE,CAAC,WAAW,CAAC,QAAQ;YACvB,EAAE,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;QAC/B,CAAC,CAAC;IAEJ,MAAM,MAAM,GAAG,WAAW,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC;IAEtD,2DAA2D;IAC3D,MAAM,MAAM,GAAG,wBAAwB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACrD,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,SAAS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,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;IAElD,IAAI,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACvD,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAE5D,IAAI,MAAM,KAAK,OAAO,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;QACzC,wDAAwD;QACxD,qCAAqC;QACrC,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;YACnB,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QACpC,CAAC;QACD,UAAU,GAAG,OAAO,KAAK,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;IACnF,CAAC;IACD,OAAO,OAAO,CAAC,UAAU,CAAC,CAAC;IAE3B,SAAS,cAAc,CAAC,QAAgB;QACtC,OAAO,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;IACzF,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAS,OAAO,CAAC,CAAS;IACxB,OAAO,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AAC/B,CAAC","sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport type { Assembly } from '@jsii/spec';\nimport * as ts from 'typescript';\n\nimport { findUp } from './find-utils';\n\n/**\n * Additional options that may be provided to the symbolIdentifier.\n */\ninterface SymbolIdOptions {\n /**\n * The assembly that the symbol is found in.\n * This is used to provide the correct root directory\n * as specified in the assembly metadata. In turn,\n * the root directory is used to ensure that the\n * symbolId comes from source code and not compiled code.\n */\n readonly assembly?: Assembly;\n}\n\n/**\n * Return a symbol identifier for the given symbol\n *\n * The symbol identifier identifies a TypeScript symbol in a source file inside\n * a package. We can use this to map between jsii entries in the manifest, and\n * entities in the TypeScript source code.\n *\n * Going via symbol id is the only way to identify symbols in submodules. Otherwise,\n * all the TypeScript compiler sees is:\n *\n * ```\n * /my/package/lib/source/directory/dist.js <containing> MyClass\n * ```\n *\n * And there's no way to figure out what submodule name\n * `lib/source/directory/dist` is exported as.\n *\n * The format of a symbol id is:\n *\n * ```\n * relative/source/file:Name.space.Class[#member]\n * ```\n *\n * We used to build this identifier ourselves. Turns out there was a built-in\n * way to get pretty much the same, by calling `typeChecker.getFullyQualifiedName()`.\n * Whoops ^_^ (this historical accident is why the format is similar to but\n * different from what the TS checker returns).\n */\nexport function symbolIdentifier(\n typeChecker: ts.TypeChecker,\n sym: ts.Symbol | undefined,\n options: SymbolIdOptions = {},\n): string | undefined {\n if (!sym) {\n return undefined;\n }\n\n // If this symbol happens to be an alias, resolve it first\n // eslint-disable-next-line no-bitwise\n while ((sym.flags & ts.SymbolFlags.Alias) !== 0) {\n sym = typeChecker.getAliasedSymbol(sym);\n }\n\n const isMember =\n // eslint-disable-next-line no-bitwise\n (sym.flags &\n // eslint-disable-next-line no-bitwise\n (ts.SymbolFlags.Method |\n // eslint-disable-next-line no-bitwise\n ts.SymbolFlags.Property |\n ts.SymbolFlags.EnumMember)) !==\n 0;\n\n const tsName = typeChecker.getFullyQualifiedName(sym);\n\n // TypeScript fqn looks like \"/path/to/file\"[.name.in.file]\n const groups = /^\"([^\"]+)\"(?:\\.(.*))?$/.exec(tsName);\n if (!groups) {\n return undefined;\n }\n\n const [, fileName, inFileName] = groups; // inFileName may be absent\n\n const relFile = Helper.for(typeChecker).assemblyRelativeSourceFile(fileName, options?.assembly);\n if (!relFile) {\n return undefined;\n }\n\n // If this is a member symbol, replace the final '.' with a '#'\n const typeSymbol = isMember ? (inFileName ?? '').replace(/\\.([^.]+)$/, '#$1') : inFileName ?? '';\n\n return `${relFile}:${typeSymbol}`;\n}\n\nclass Helper {\n public static for(typeChecker: ts.TypeChecker) {\n const cached = this.INSTANCES.get(typeChecker);\n if (cached != null) {\n return cached;\n }\n const helper = new Helper();\n this.INSTANCES.set(typeChecker, helper);\n return helper;\n }\n\n private static readonly INSTANCES = new WeakMap<ts.TypeChecker, Helper>();\n\n private readonly packageInfo = new Map<string, PackageInfo | undefined>();\n\n private constructor() {}\n\n public assemblyRelativeSourceFile(sourceFileName: string, asm?: Assembly) {\n const packageInfo = this.findPackageInfo(path.dirname(sourceFileName));\n if (!packageInfo) {\n return undefined;\n }\n\n let sourcePath = removePrefix(packageInfo.outdir ?? '', path.relative(packageInfo.packageJsonDir, sourceFileName));\n\n // Modify the namespace if we send in the assembly.\n if (asm) {\n const tscRootDir = packageInfo.tscRootDir ?? asm.metadata?.tscRootDir;\n const tscOutDir = packageInfo.tscOutDir;\n sourcePath = normalizePath(sourcePath, tscRootDir, tscOutDir);\n }\n\n return sourcePath.replace(/(\\.d)?\\.ts$/, '');\n\n function removePrefix(prefix: string, filePath: string) {\n const prefixParts = prefix.split(/[/\\\\]/g);\n const pathParts = filePath.split(/[/\\\\]/g);\n let i = 0;\n while (prefixParts[i] === pathParts[i]) {\n i++;\n }\n return pathParts.slice(i).join('/');\n }\n }\n\n private findPackageInfo(from: string): PackageInfo | undefined {\n if (this.packageInfo.has(from)) {\n return this.packageInfo.get(from);\n }\n\n const packageJsonDir = findUp(from, (dir) => fs.existsSync(path.join(dir, 'package.json')));\n\n if (!packageJsonDir) {\n this.packageInfo.set(from, undefined);\n return undefined;\n }\n\n if (this.packageInfo.has(packageJsonDir)) {\n return this.packageInfo.get(packageJsonDir);\n }\n\n const { jsii } = JSON.parse(fs.readFileSync(path.join(packageJsonDir, 'package.json'), 'utf-8'));\n\n const result = {\n packageJsonDir,\n outdir: jsii?.outdir,\n tscRootDir: jsii?.tsc?.rootDir,\n tscOutDir: jsii?.tsc?.outDir,\n };\n this.packageInfo.set(from, result);\n this.packageInfo.set(packageJsonDir, result);\n return result;\n }\n}\n\ninterface PackageInfo {\n readonly packageJsonDir: string;\n readonly outdir: string | undefined;\n readonly tscRootDir: string | undefined;\n readonly tscOutDir: string | undefined;\n}\n\n/**\n * Ensures that the sourcePath is pointing to the source code\n * and not compiled code. This can happen if the root directory\n * and/or out directory is set for the project. We check to see\n * if the out directory is present in the sourcePath, and if so,\n * we replace it with the root directory.\n */\nexport function normalizePath(sourcePath: string, rootDir?: string, outDir?: string): string {\n if (rootDir === undefined || outDir === undefined) {\n return sourcePath;\n }\n\n outDir = removeEndSlash(path.normalize(outDir));\n const outDirLength = outDir.split(path.sep).length;\n rootDir = removeEndSlash(path.normalize(rootDir));\n\n let paths = path.normalize(sourcePath).split(path.sep);\n const pathDir = paths.slice(0, outDirLength).join(path.sep);\n\n if (outDir === pathDir || outDir === '.') {\n // outDir === '.' is a special case where we do not want\n // to remove any paths from the list.\n if (outDir !== '.') {\n paths = paths.slice(outDirLength);\n }\n sourcePath = rootDir === '.' ? paths.join('/') : `${rootDir}/${paths.join('/')}`;\n }\n return unixize(sourcePath);\n\n function removeEndSlash(filePath: string) {\n return filePath.endsWith(path.sep) ? filePath.slice(0, filePath.length - 1) : filePath;\n }\n}\n\n/**\n * Turn backslashes in a path into forward slashes\n */\nfunction unixize(p: string) {\n return p.replace(/\\\\/g, '/');\n}\n"]}
|
|
1
|
+
{"version":3,"file":"symbol-id.js","sourceRoot":"","sources":["../../src/common/symbol-id.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDA,4CA4CC;AA2FD,sCAyBC;AAjND,4CAA8B;AAC9B,gDAAkC;AAElC,+CAAiC;AAEjC,6CAAsC;AAgBtC;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2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AAC,KAAK,CAAC,YAAY,CAAC,CAAC;QACpC,CAAC;QACD,UAAU,GAAG,OAAO,KAAK,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;IACnF,CAAC;IACD,OAAO,OAAO,CAAC,UAAU,CAAC,CAAC;IAE3B,SAAS,cAAc,CAAC,QAAgB;QACtC,OAAO,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;IACzF,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAS,OAAO,CAAC,CAAS;IACxB,OAAO,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AAC/B,CAAC","sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport type { Assembly } from '@jsii/spec';\nimport * as ts from 'typescript';\n\nimport { findUp } from './find-utils';\n\n/**\n * Additional options that may be provided to the symbolIdentifier.\n */\ninterface SymbolIdOptions {\n /**\n * The assembly that the symbol is found in.\n * This is used to provide the correct root directory\n * as specified in the assembly metadata. In turn,\n * the root directory is used to ensure that the\n * symbolId comes from source code and not compiled code.\n */\n readonly assembly?: Assembly;\n}\n\n/**\n * Return a symbol identifier for the given symbol\n *\n * The symbol identifier identifies a TypeScript symbol in a source file inside\n * a package. We can use this to map between jsii entries in the manifest, and\n * entities in the TypeScript source code.\n *\n * Going via symbol id is the only way to identify symbols in submodules. Otherwise,\n * all the TypeScript compiler sees is:\n *\n * ```\n * /my/package/lib/source/directory/dist.js <containing> MyClass\n * ```\n *\n * And there's no way to figure out what submodule name\n * `lib/source/directory/dist` is exported as.\n *\n * The format of a symbol id is:\n *\n * ```\n * relative/source/file:Name.space.Class[#member]\n * ```\n *\n * We used to build this identifier ourselves. Turns out there was a built-in\n * way to get pretty much the same, by calling `typeChecker.getFullyQualifiedName()`.\n * Whoops ^_^ (this historical accident is why the format is similar to but\n * different from what the TS checker returns).\n */\nexport function symbolIdentifier(\n typeChecker: ts.TypeChecker,\n sym: ts.Symbol | undefined,\n options: SymbolIdOptions = {},\n): string | undefined {\n if (!sym) {\n return undefined;\n }\n\n // If this symbol happens to be an alias, resolve it first\n // eslint-disable-next-line no-bitwise\n while ((sym.flags & ts.SymbolFlags.Alias) !== 0) {\n sym = typeChecker.getAliasedSymbol(sym);\n }\n\n const isMember =\n // eslint-disable-next-line no-bitwise\n (sym.flags &\n // eslint-disable-next-line no-bitwise\n (ts.SymbolFlags.Method |\n // eslint-disable-next-line no-bitwise\n ts.SymbolFlags.Property |\n ts.SymbolFlags.EnumMember)) !==\n 0;\n\n const tsName = typeChecker.getFullyQualifiedName(sym);\n\n // TypeScript fqn looks like \"/path/to/file\"[.name.in.file]\n const groups = /^\"([^\"]+)\"(?:\\.(.*))?$/.exec(tsName);\n if (!groups) {\n return undefined;\n }\n\n const [, fileName, inFileName] = groups; // inFileName may be absent\n\n const relFile = Helper.for(typeChecker).assemblyRelativeSourceFile(fileName, options?.assembly);\n if (!relFile) {\n return undefined;\n }\n\n // If this is a member symbol, replace the final '.' with a '#'\n const typeSymbol = isMember ? (inFileName ?? '').replace(/\\.([^.]+)$/, '#$1') : inFileName ?? '';\n\n return `${relFile}:${typeSymbol}`;\n}\n\nclass Helper {\n public static for(typeChecker: ts.TypeChecker) {\n const cached = this.INSTANCES.get(typeChecker);\n if (cached != null) {\n return cached;\n }\n const helper = new Helper();\n this.INSTANCES.set(typeChecker, helper);\n return helper;\n }\n\n private static readonly INSTANCES = new WeakMap<ts.TypeChecker, Helper>();\n\n private readonly packageInfo = new Map<string, PackageInfo | undefined>();\n\n private constructor() {}\n\n public assemblyRelativeSourceFile(sourceFileName: string, asm?: Assembly) {\n const packageInfo = this.findPackageInfo(path.dirname(sourceFileName));\n if (!packageInfo) {\n return undefined;\n }\n\n let sourcePath = removePrefix(packageInfo.outdir ?? '', path.relative(packageInfo.packageJsonDir, sourceFileName));\n\n // Modify the namespace if we send in the assembly.\n if (asm) {\n const tscRootDir = packageInfo.tscRootDir ?? asm.metadata?.tscRootDir;\n const tscOutDir = packageInfo.tscOutDir;\n sourcePath = normalizePath(sourcePath, tscRootDir, tscOutDir);\n }\n\n return sourcePath.replace(/(\\.d)?\\.ts$/, '');\n\n function removePrefix(prefix: string, filePath: string) {\n const prefixParts = prefix.split(/[/\\\\]/g);\n const pathParts = filePath.split(/[/\\\\]/g);\n let i = 0;\n while (prefixParts[i] === pathParts[i]) {\n i++;\n }\n return pathParts.slice(i).join('/');\n }\n }\n\n private findPackageInfo(from: string): PackageInfo | undefined {\n if (this.packageInfo.has(from)) {\n return this.packageInfo.get(from);\n }\n\n const packageJsonDir = findUp(from, (dir) => fs.existsSync(path.join(dir, 'package.json')));\n\n if (!packageJsonDir) {\n this.packageInfo.set(from, undefined);\n return undefined;\n }\n\n if (this.packageInfo.has(packageJsonDir)) {\n return this.packageInfo.get(packageJsonDir);\n }\n\n const { jsii } = JSON.parse(fs.readFileSync(path.join(packageJsonDir, 'package.json'), 'utf-8'));\n\n const result = {\n packageJsonDir,\n outdir: jsii?.outdir,\n tscRootDir: jsii?.tsc?.rootDir,\n tscOutDir: jsii?.tsc?.outDir,\n };\n this.packageInfo.set(from, result);\n this.packageInfo.set(packageJsonDir, result);\n return result;\n }\n}\n\ninterface PackageInfo {\n readonly packageJsonDir: string;\n readonly outdir: string | undefined;\n readonly tscRootDir: string | undefined;\n readonly tscOutDir: string | undefined;\n}\n\n/**\n * Ensures that the sourcePath is pointing to the source code\n * and not compiled code. This can happen if the root directory\n * and/or out directory is set for the project. We check to see\n * if the out directory is present in the sourcePath, and if so,\n * we replace it with the root directory.\n */\nexport function normalizePath(sourcePath: string, rootDir?: string, outDir?: string): string {\n if (rootDir === undefined || outDir === undefined) {\n return sourcePath;\n }\n\n outDir = removeEndSlash(path.normalize(outDir));\n const outDirLength = outDir.split(path.sep).length;\n rootDir = removeEndSlash(path.normalize(rootDir));\n\n let paths = path.normalize(sourcePath).split(path.sep);\n const pathDir = paths.slice(0, outDirLength).join(path.sep);\n\n if (outDir === pathDir || outDir === '.') {\n // outDir === '.' is a special case where we do not want\n // to remove any paths from the list.\n if (outDir !== '.') {\n paths = paths.slice(outDirLength);\n }\n sourcePath = rootDir === '.' ? paths.join('/') : `${rootDir}/${paths.join('/')}`;\n }\n return unixize(sourcePath);\n\n function removeEndSlash(filePath: string) {\n return filePath.endsWith(path.sep) ? filePath.slice(0, filePath.length - 1) : filePath;\n }\n}\n\n/**\n * Turn backslashes in a path into forward slashes\n */\nfunction unixize(p: string) {\n return p.replace(/\\\\/g, '/');\n}\n"]}
|
package/lib/compiler.js
CHANGED
|
@@ -1,11 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
2
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
39
|
exports.Compiler = exports.JSII_DIAGNOSTICS_CODE = exports.DIAGNOSTICS = void 0;
|
|
4
|
-
const fs = require("node:fs");
|
|
5
|
-
const path = require("node:path");
|
|
6
|
-
const
|
|
7
|
-
const log4js = require("log4js");
|
|
8
|
-
const ts = require("typescript");
|
|
40
|
+
const fs = __importStar(require("node:fs"));
|
|
41
|
+
const path = __importStar(require("node:path"));
|
|
42
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
43
|
+
const log4js = __importStar(require("log4js"));
|
|
44
|
+
const ts = __importStar(require("typescript"));
|
|
9
45
|
const assembler_1 = require("./assembler");
|
|
10
46
|
const find_utils_1 = require("./common/find-utils");
|
|
11
47
|
const jsii_diagnostic_1 = require("./jsii-diagnostic");
|
|
@@ -14,15 +50,22 @@ const tsconfig_1 = require("./tsconfig");
|
|
|
14
50
|
const compiler_options_1 = require("./tsconfig/compiler-options");
|
|
15
51
|
const tsconfig_validator_1 = require("./tsconfig/tsconfig-validator");
|
|
16
52
|
const validator_1 = require("./tsconfig/validator");
|
|
17
|
-
const utils = require("./utils");
|
|
53
|
+
const utils = __importStar(require("./utils"));
|
|
18
54
|
const warnings_1 = require("./warnings");
|
|
19
55
|
const LOG = log4js.getLogger('jsii/compiler');
|
|
20
56
|
exports.DIAGNOSTICS = 'diagnostics';
|
|
21
57
|
exports.JSII_DIAGNOSTICS_CODE = 9999;
|
|
22
58
|
class Compiler {
|
|
59
|
+
options;
|
|
60
|
+
system;
|
|
61
|
+
compilerHost;
|
|
62
|
+
userProvidedTypeScriptConfig;
|
|
63
|
+
tsconfig;
|
|
64
|
+
rootFiles = [];
|
|
65
|
+
configPath;
|
|
66
|
+
projectRoot;
|
|
23
67
|
constructor(options) {
|
|
24
68
|
this.options = options;
|
|
25
|
-
this.rootFiles = [];
|
|
26
69
|
if (options.generateTypeScriptConfig != null && options.typeScriptConfig != null) {
|
|
27
70
|
throw new utils.JsiiError('Cannot use `generateTypeScriptConfig` and `typeScriptConfig` together. Provide only one of them.');
|
|
28
71
|
}
|
|
@@ -297,7 +340,7 @@ class Compiler {
|
|
|
297
340
|
...this.tsconfig,
|
|
298
341
|
compilerOptions: (0, compiler_options_1.convertForJson)(this.tsconfig?.compilerOptions),
|
|
299
342
|
};
|
|
300
|
-
LOG.debug(`Creating or updating ${
|
|
343
|
+
LOG.debug(`Creating or updating ${chalk_1.default.blue(this.configPath)}`);
|
|
301
344
|
fs.writeFileSync(this.configPath, JSON.stringify(outputConfig, null, 2), 'utf8');
|
|
302
345
|
}
|
|
303
346
|
/**
|
package/lib/compiler.js.map
CHANGED
|
@@ -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;AAE9D,uDAAmD;AAEnD,4EAA2E;AAC3E,yCAAiF;AACjF,kEAAoF;AACpF,sEAA0E;AAC1E,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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 { Emitter } from './emitter';\nimport { JsiiDiagnostic } from './jsii-diagnostic';\nimport { ProjectInfo } from './project-info';\nimport { WARNINGSCODE_FILE_NAME } from './transforms/deprecation-warnings';\nimport { TypeScriptConfig, TypeScriptConfigValidationRuleSet } from './tsconfig';\nimport { BASE_COMPILER_OPTIONS, convertForJson } from './tsconfig/compiler-options';\nimport { TypeScriptConfigValidator } from './tsconfig/tsconfig-validator';\nimport { ValidationError } from './tsconfig/validator';\nimport * as utils from './utils';\nimport { isSilenced } from './warnings';\n\nconst LOG = log4js.getLogger('jsii/compiler');\nexport const DIAGNOSTICS = 'diagnostics';\nexport const JSII_DIAGNOSTICS_CODE = 9999;\n\nexport interface CompilerOptions {\n /** The information about the project to be built */\n projectInfo: ProjectInfo;\n /** Whether the compiler should watch for changes or just compile once */\n watch?: boolean;\n /** Whether to detect and generate TypeScript project references */\n projectReferences?: boolean;\n /** Whether to fail when a warning is emitted */\n failOnWarnings?: boolean;\n /** Whether to strip deprecated members from emitted artifacts */\n stripDeprecated?: boolean;\n /** The path to an allowlist of FQNs to strip if stripDeprecated is set */\n stripDeprecatedAllowListFile?: string;\n /** Whether to add warnings for deprecated elements */\n addDeprecationWarnings?: boolean;\n /**\n * The name of the tsconfig file to generate.\n * Cannot be used at the same time as `typeScriptConfig`.\n * @default \"tsconfig.json\"\n */\n generateTypeScriptConfig?: string;\n /**\n * The name of the tsconfig file to use.\n * Cannot be used at the same time as `generateTypeScriptConfig`.\n * @default - generate the tsconfig file\n */\n typeScriptConfig?: string;\n /**\n * The ruleset to validate the provided tsconfig file against.\n * Can only be used when `typeScriptConfig` is provided.\n * @default TypeScriptConfigValidationRuleSet.STRICT - if `typeScriptConfig` is provided\n */\n validateTypeScriptConfig?: TypeScriptConfigValidationRuleSet;\n /**\n * Whether to compress the assembly\n * @default false\n */\n compressAssembly?: boolean;\n}\n\nexport class Compiler implements Emitter {\n private readonly system: ts.System;\n private readonly compilerHost: ts.CompilerHost;\n private readonly userProvidedTypeScriptConfig: boolean;\n private readonly tsconfig: TypeScriptConfig;\n private rootFiles: string[] = [];\n private readonly configPath: string;\n private readonly projectRoot: string;\n\n public constructor(private readonly options: CompilerOptions) {\n if (options.generateTypeScriptConfig != null && options.typeScriptConfig != null) {\n throw new utils.JsiiError(\n 'Cannot use `generateTypeScriptConfig` and `typeScriptConfig` together. Provide only one of them.',\n );\n }\n\n this.projectRoot = this.options.projectInfo.projectRoot;\n const configFileName = options.typeScriptConfig ?? options.generateTypeScriptConfig ?? 'tsconfig.json';\n this.configPath = path.join(this.projectRoot, configFileName);\n this.userProvidedTypeScriptConfig = Boolean(options.typeScriptConfig);\n\n this.system = {\n ...ts.sys,\n getCurrentDirectory: () => this.projectRoot,\n createDirectory: (pth) => ts.sys.createDirectory(path.resolve(this.projectRoot, pth)),\n deleteFile: ts.sys.deleteFile && ((pth) => ts.sys.deleteFile!(path.join(this.projectRoot, pth))),\n fileExists: (pth) => ts.sys.fileExists(path.resolve(this.projectRoot, pth)),\n getFileSize: ts.sys.getFileSize && ((pth) => ts.sys.getFileSize!(path.resolve(this.projectRoot, pth))),\n readFile: (pth, encoding) => ts.sys.readFile(path.resolve(this.projectRoot, pth), encoding),\n watchFile:\n ts.sys.watchFile &&\n ((pth, callback, pollingInterval, watchOptions) =>\n ts.sys.watchFile!(path.resolve(this.projectRoot, pth), callback, pollingInterval, watchOptions)),\n writeFile: (pth, data, writeByteOrderMark) =>\n ts.sys.writeFile(path.resolve(this.projectRoot, pth), data, writeByteOrderMark),\n };\n\n this.tsconfig = this.configureTypeScript();\n this.compilerHost = ts.createIncrementalCompilerHost(this.tsconfig.compilerOptions, this.system);\n }\n\n /**\n * Compiles the configured program.\n *\n * @param files can be specified to override the standard source code location logic. Useful for example when testing \"negatives\".\n */\n public emit(...files: string[]): ts.EmitResult {\n this.prepareForBuild(...files);\n return this.buildOnce();\n }\n\n /**\n * Watches for file-system changes and dynamically recompiles the project as needed. In non-blocking mode, this\n * returns the TypeScript watch handle for the application to use.\n *\n * @internal\n */\n public async watch(opts: NonBlockingWatchOptions): Promise<ts.Watch<ts.BuilderProgram>>;\n /**\n * Watches for file-system changes and dynamically recompiles the project as needed. In blocking mode, this results\n * in a never-resolving promise.\n */\n public async watch(): Promise<never>;\n public async watch(opts?: NonBlockingWatchOptions): Promise<ts.Watch<ts.BuilderProgram> | never> {\n this.prepareForBuild();\n\n const host = ts.createWatchCompilerHost(\n this.configPath,\n {\n ...this.tsconfig.compilerOptions,\n noEmitOnError: false,\n },\n this.system,\n ts.createEmitAndSemanticDiagnosticsBuilderProgram,\n opts?.reportDiagnostics,\n opts?.reportWatchStatus,\n this.tsconfig.watchOptions,\n );\n if (!host.getDefaultLibLocation) {\n throw new Error('No default library location was found on the TypeScript compiler host!');\n }\n const orig = host.afterProgramCreate;\n // This is a callback cascade, so it's \"okay\" to return an unhandled promise there. This may\n // cause an unhandled promise rejection warning, but that's not a big deal.\n //\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n host.afterProgramCreate = (builderProgram) => {\n const startTime = Date.now();\n const emitResult = this.consumeProgram(builderProgram.getProgram(), host.getDefaultLibLocation!());\n\n for (const diag of emitResult.diagnostics.filter((d) => d.code === JSII_DIAGNOSTICS_CODE)) {\n utils.logDiagnostic(diag, this.projectRoot);\n }\n\n console.log(\n utils.formatCompilationSummary(emitResult.diagnostics, emitResult.emitSkipped, Date.now() - startTime),\n );\n\n if (orig) {\n orig.call(host, builderProgram);\n }\n if (opts?.compilationComplete) {\n opts.compilationComplete(emitResult);\n }\n };\n const watch = ts.createWatchProgram(host);\n\n if (opts?.nonBlocking) {\n // In non-blocking mode, returns the handle to the TypeScript watch interface.\n return watch;\n }\n // In blocking mode, returns a never-resolving promise.\n return new Promise<never>(() => null);\n }\n\n /**\n * Prepares the project for build, by creating the necessary configuration\n * file(s), and assigning the relevant root file(s).\n *\n * @param files the files that were specified as input in the CLI invocation.\n */\n private configureTypeScript(): TypeScriptConfig {\n if (this.userProvidedTypeScriptConfig) {\n const config = this.readTypeScriptConfig();\n\n // emit a warning if validation is disabled\n const rules = this.options.validateTypeScriptConfig ?? TypeScriptConfigValidationRuleSet.NONE;\n if (rules === TypeScriptConfigValidationRuleSet.NONE) {\n utils.logDiagnostic(\n JsiiDiagnostic.JSII_4009_DISABLED_TSCONFIG_VALIDATION.create(undefined, this.configPath),\n this.projectRoot,\n );\n }\n\n // validate the user provided config\n if (rules !== TypeScriptConfigValidationRuleSet.NONE) {\n const configName = path.relative(this.projectRoot, this.configPath);\n try {\n const validator = new TypeScriptConfigValidator(rules);\n validator.validate({\n ...config,\n // convert the internal format to the user format which is what the validator operates on\n compilerOptions: convertForJson(config.compilerOptions),\n });\n } catch (error: unknown) {\n if (error instanceof ValidationError) {\n utils.logDiagnostic(\n JsiiDiagnostic.JSII_4000_FAILED_TSCONFIG_VALIDATION.create(\n undefined,\n configName,\n rules,\n error.violations,\n ),\n this.projectRoot,\n );\n }\n\n throw new utils.JsiiError(\n `Failed validation of tsconfig \"compilerOptions\" in \"${configName}\" against rule set \"${rules}\"!`,\n );\n }\n }\n\n return config;\n }\n\n // generated config if none is provided by the user\n return this.buildTypeScriptConfig();\n }\n\n /**\n * Final preparations of the project for build.\n *\n * These are preparations that either\n * - must happen immediately before the build, or\n * - can be different for every build like assigning the relevant root file(s).\n *\n * @param files the files that were specified as input in the CLI invocation.\n */\n private prepareForBuild(...files: string[]) {\n if (!this.userProvidedTypeScriptConfig) {\n this.writeTypeScriptConfig();\n }\n\n this.rootFiles = this.determineSources(files);\n }\n\n /**\n * Do a single build\n */\n private buildOnce(): ts.EmitResult {\n if (!this.compilerHost.getDefaultLibLocation) {\n throw new Error('No default library location was found on the TypeScript compiler host!');\n }\n\n const tsconf = this.tsconfig!;\n\n const prog = ts.createIncrementalProgram({\n rootNames: this.rootFiles.concat(_pathOfLibraries(tsconf.compilerOptions, this.compilerHost)),\n options: tsconf.compilerOptions,\n // Make the references absolute for the compiler\n projectReferences: tsconf.references?.map((ref) => ({\n path: path.resolve(path.dirname(this.configPath), ref.path),\n })),\n host: this.compilerHost,\n });\n\n return this.consumeProgram(prog.getProgram(), this.compilerHost.getDefaultLibLocation());\n }\n\n private consumeProgram(program: ts.Program, stdlib: string): ts.EmitResult {\n const diagnostics = [...ts.getPreEmitDiagnostics(program)];\n let hasErrors = false;\n\n if (!hasErrors && this.diagsHaveAbortableErrors(diagnostics)) {\n hasErrors = true;\n LOG.error('Compilation errors prevented the JSII assembly from being created');\n }\n\n // Do the \"Assembler\" part first because we need some of the analysis done in there\n // to post-process the AST\n const assembler = new Assembler(this.options.projectInfo, this.system, program, stdlib, {\n stripDeprecated: this.options.stripDeprecated,\n stripDeprecatedAllowListFile: this.options.stripDeprecatedAllowListFile,\n addDeprecationWarnings: this.options.addDeprecationWarnings,\n compressAssembly: this.options.compressAssembly,\n });\n\n try {\n const assmEmit = assembler.emit();\n if (!hasErrors && (assmEmit.emitSkipped || this.diagsHaveAbortableErrors(assmEmit.diagnostics))) {\n hasErrors = true;\n LOG.error('Type model errors prevented the JSII assembly from being created');\n }\n\n diagnostics.push(...assmEmit.diagnostics);\n } catch (e: any) {\n diagnostics.push(JsiiDiagnostic.JSII_9997_UNKNOWN_ERROR.createDetached(e));\n hasErrors = true;\n }\n\n // Do the emit, but add in transformers which are going to replace real\n // comments with synthetic ones.\n const emit = program.emit(\n undefined, // targetSourceFile\n undefined, // writeFile\n undefined, // cancellationToken\n undefined, // emitOnlyDtsFiles\n assembler.customTransformers,\n );\n diagnostics.push(...emit.diagnostics);\n\n if (!hasErrors && (emit.emitSkipped || this.diagsHaveAbortableErrors(emit.diagnostics))) {\n hasErrors = true;\n LOG.error('Compilation errors prevented the JSII assembly from being created');\n }\n\n // Some extra validation on the config.\n // Make sure that { \"./.warnings.jsii.js\": \"./.warnings.jsii.js\" } is in the set of\n // exports, if they are specified.\n if (this.options.addDeprecationWarnings && this.options.projectInfo.exports !== undefined) {\n const expected = `./${WARNINGSCODE_FILE_NAME}`;\n const warningsExport = Object.entries(this.options.projectInfo.exports).filter(\n ([k, v]) => k === expected && v === expected,\n );\n\n if (warningsExport.length === 0) {\n hasErrors = true;\n diagnostics.push(JsiiDiagnostic.JSII_0007_MISSING_WARNINGS_EXPORT.createDetached());\n }\n }\n\n return {\n emitSkipped: hasErrors,\n diagnostics: ts.sortAndDeduplicateDiagnostics(diagnostics),\n emittedFiles: emit.emittedFiles,\n };\n }\n\n /**\n * Build the TypeScript config object from jsii config\n *\n * This is the object that will be written to disk\n * unless an existing tsconfig was provided.\n */\n private buildTypeScriptConfig(): TypeScriptConfig {\n let references: string[] | undefined;\n\n const isComposite =\n this.options.projectReferences !== undefined\n ? this.options.projectReferences\n : this.options.projectInfo.projectReferences !== undefined\n ? this.options.projectInfo.projectReferences\n : false;\n if (isComposite) {\n references = this.findProjectReferences();\n }\n\n const pi = this.options.projectInfo;\n\n return {\n compilerOptions: {\n ...pi.tsc,\n ...BASE_COMPILER_OPTIONS,\n // Enable composite mode if project references are enabled\n composite: isComposite,\n // When incremental, configure a tsbuildinfo file\n tsBuildInfoFile: path.join(pi.tsc?.outDir ?? '.', 'tsconfig.tsbuildinfo'),\n },\n include: [pi.tsc?.rootDir != null ? path.join(pi.tsc.rootDir, '**', '*.ts') : path.join('**', '*.ts')],\n exclude: [\n 'node_modules',\n ...(pi.excludeTypescript ?? []),\n ...(pi.tsc?.outDir != null &&\n (pi.tsc?.rootDir == null || path.resolve(pi.tsc.outDir).startsWith(path.resolve(pi.tsc.rootDir) + path.sep))\n ? [path.join(pi.tsc.outDir, '**', '*.ts')]\n : []),\n ],\n // Change the references a little. We write 'originalpath' to the\n // file under the 'path' key, which is the same as what the\n // TypeScript compiler does. Make it relative so that the files are\n // movable. Not strictly required but looks better.\n references: references?.map((p) => ({ path: p })),\n };\n }\n\n /**\n * Load the TypeScript config object from a provided file\n */\n private readTypeScriptConfig(): TypeScriptConfig {\n const projectRoot = this.options.projectInfo.projectRoot;\n const { config, error } = ts.readConfigFile(this.configPath, ts.sys.readFile);\n if (error) {\n utils.logDiagnostic(error, projectRoot);\n throw new utils.JsiiError(`Failed to load tsconfig at ${this.configPath}`);\n }\n const extended = ts.parseJsonConfigFileContent(config, ts.sys, projectRoot);\n // the tsconfig parser adds this in, but it is not an expected compilerOption\n delete extended.options.configFilePath;\n\n return {\n compilerOptions: extended.options,\n watchOptions: extended.watchOptions,\n include: extended.fileNames,\n };\n }\n\n /**\n * Creates a `tsconfig.json` file to improve the IDE experience.\n *\n * @return the fully qualified path to the `tsconfig.json` file\n */\n private writeTypeScriptConfig(): void {\n const commentKey = '_generated_by_jsii_';\n const commentValue = 'Generated by jsii - safe to delete, and ideally should be in .gitignore';\n\n (this.tsconfig as any)[commentKey] = commentValue;\n\n if (fs.existsSync(this.configPath)) {\n const currentConfig = JSON.parse(fs.readFileSync(this.configPath, 'utf-8'));\n if (!(commentKey in currentConfig)) {\n throw new utils.JsiiError(\n `A '${this.configPath}' file that was not generated by jsii is in ${this.options.projectInfo.projectRoot}. Aborting instead of overwriting.`,\n );\n }\n }\n\n const outputConfig = {\n ...this.tsconfig,\n compilerOptions: convertForJson(this.tsconfig?.compilerOptions),\n };\n\n LOG.debug(`Creating or updating ${chalk.blue(this.configPath)}`);\n fs.writeFileSync(this.configPath, JSON.stringify(outputConfig, null, 2), 'utf8');\n }\n\n /**\n * Find all dependencies that look like TypeScript projects.\n *\n * Enumerate all dependencies, if they have a tsconfig.json file with\n * \"composite: true\" we consider them project references.\n *\n * (Note: TypeScript seems to only correctly find transitive project references\n * if there's an \"index\" tsconfig.json of all projects somewhere up the directory\n * tree)\n */\n private findProjectReferences(): string[] {\n const pkg = this.options.projectInfo.packageJson;\n\n const ret = new Array<string>();\n\n const dependencyNames = new Set<string>();\n for (const dependencyMap of [pkg.dependencies, pkg.devDependencies, pkg.peerDependencies]) {\n if (dependencyMap === undefined) {\n continue;\n }\n for (const name of Object.keys(dependencyMap)) {\n dependencyNames.add(name);\n }\n }\n\n for (const tsconfigFile of Array.from(dependencyNames).map((depName) => this.findMonorepoPeerTsconfig(depName))) {\n if (!tsconfigFile) {\n continue;\n }\n\n const { config: tsconfig } = ts.readConfigFile(tsconfigFile, this.system.readFile);\n\n // Add references to any TypeScript package we find that is 'composite' enabled.\n // Make it relative.\n if (tsconfig.compilerOptions?.composite) {\n ret.push(path.relative(this.options.projectInfo.projectRoot, path.dirname(tsconfigFile)));\n } else {\n // Not a composite package--if this package is in a node_modules directory, that is most\n // likely correct, otherwise it is most likely an error (heuristic here, I don't know how to\n // properly check this).\n if (tsconfigFile.includes('node_modules')) {\n LOG.warn('%s: not a composite TypeScript package, but it probably should be', path.dirname(tsconfigFile));\n }\n }\n }\n\n return ret;\n }\n\n /**\n * Find source files using the same mechanism that the TypeScript compiler itself uses.\n *\n * Respects includes/excludes/etc.\n *\n * This makes it so that running 'typescript' and running 'jsii' has the same behavior.\n */\n private determineSources(files: string[]): string[] {\n // explicitly requested files\n if (files.length > 0) {\n return [...files];\n }\n\n // for user provided config we already have parsed the full list of files\n if (this.userProvidedTypeScriptConfig) {\n return [...(this.tsconfig.include ?? [])];\n }\n\n // finally get the file list for the generated config\n const parseConfigHost = parseConfigHostFromCompilerHost(this.compilerHost);\n const parsed = ts.parseJsonConfigFileContent(this.tsconfig, parseConfigHost, this.options.projectInfo.projectRoot);\n return [...parsed.fileNames];\n }\n\n /**\n * Resolve the given dependency name from the current package, and find the associated tsconfig.json location\n *\n * Because we have the following potential directory layout:\n *\n * package/node_modules/some_dependency\n * package/tsconfig.json\n *\n * We resolve symlinks and only find a \"TypeScript\" dependency if doesn't have 'node_modules' in\n * the path after resolving symlinks (i.e., if it's a peer package in the same monorepo).\n *\n * Returns undefined if no such tsconfig could be found.\n */\n private findMonorepoPeerTsconfig(depName: string): string | undefined {\n // eslint-disable-next-line @typescript-eslint/no-require-imports,@typescript-eslint/no-var-requires\n const { builtinModules } = require('node:module');\n if ((builtinModules ?? []).includes(depName)) {\n // Can happen for modules like 'punycode' which are declared as dependency for polyfill purposes\n return undefined;\n }\n\n try {\n const depDir = findDependencyDirectory(depName, this.options.projectInfo.projectRoot);\n\n const dep = path.join(depDir, 'tsconfig.json');\n if (!fs.existsSync(dep)) {\n return undefined;\n }\n\n // Resolve symlinks, to check if this is a monorepo peer\n const dependencyRealPath = fs.realpathSync(dep);\n if (dependencyRealPath.split(path.sep).includes('node_modules')) {\n return undefined;\n }\n\n return dependencyRealPath;\n } catch (e: any) {\n // @types modules cannot be required, for example\n if (['MODULE_NOT_FOUND', 'ERR_PACKAGE_PATH_NOT_EXPORTED'].includes(e.code)) {\n return undefined;\n }\n throw e;\n }\n }\n\n private diagsHaveAbortableErrors(diags: readonly ts.Diagnostic[]) {\n return diags.some(\n (d) =>\n d.category === ts.DiagnosticCategory.Error ||\n (this.options.failOnWarnings && d.category === ts.DiagnosticCategory.Warning && !isSilenced(d)),\n );\n }\n}\n\n/**\n * Options for Watch in non-blocking mode.\n *\n * @internal\n */\nexport interface NonBlockingWatchOptions {\n /**\n * Signals non-blocking execution\n */\n readonly nonBlocking: true;\n\n /**\n * Configures the diagnostics reporter\n */\n readonly reportDiagnostics: ts.DiagnosticReporter;\n\n /**\n * Configures the watch status reporter\n */\n readonly reportWatchStatus: ts.WatchStatusReporter;\n\n /**\n * This hook gets invoked when a compilation cycle (complete with Assembler execution) completes.\n */\n readonly compilationComplete: (emitResult: ts.EmitResult) => void;\n}\n\nfunction _pathOfLibraries(options: ts.CompilerOptions, host: ts.CompilerHost | ts.WatchCompilerHost<any>): string[] {\n // Prefer user libraries, falling back to a library based on the target if not supplied by the user.\n // This matches tsc behavior.\n const libs = options.lib ?? [ts.getDefaultLibFileName(options)];\n if (libs.length === 0) {\n return [];\n }\n\n const libDir = host.getDefaultLibLocation?.();\n if (!libDir) {\n throw new Error(`Compiler host doesn't have a default library directory available for ${libs.join(', ')}`);\n }\n return libs.map((name) => path.join(libDir, name));\n}\n\nfunction parseConfigHostFromCompilerHost(host: ts.CompilerHost): ts.ParseConfigHost {\n // Copied from upstream\n // https://github.com/Microsoft/TypeScript/blob/9e05abcfd3f8bb3d6775144ede807daceab2e321/src/compiler/program.ts#L3105\n return {\n fileExists: (f) => host.fileExists(f),\n readDirectory(root, extensions, excludes, includes, depth) {\n if (host.readDirectory === undefined) {\n throw new Error(\"'CompilerHost.readDirectory' must be implemented to correctly process 'projectReferences'\");\n }\n return host.readDirectory(root, extensions, excludes, includes, depth);\n },\n readFile: (f) => host.readFile(f),\n useCaseSensitiveFileNames: host.useCaseSensitiveFileNames(),\n trace: host.trace ? (s) => host.trace!(s) : undefined,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"compiler.js","sourceRoot":"","sources":["../src/compiler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAA8B;AAC9B,gDAAkC;AAClC,kDAA0B;AAC1B,+CAAiC;AACjC,+CAAiC;AAEjC,2CAAwC;AACxC,oDAA8D;AAE9D,uDAAmD;AAEnD,4EAA2E;AAC3E,yCAAiF;AACjF,kEAAoF;AACpF,sEAA0E;AAC1E,oDAAuD;AACvD,+CAAiC;AACjC,yCAAwC;AAExC,MAAM,GA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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 chalk from 'chalk';\nimport * as log4js from 'log4js';\nimport * as ts from 'typescript';\n\nimport { Assembler } from './assembler';\nimport { findDependencyDirectory } from './common/find-utils';\nimport { Emitter } from './emitter';\nimport { JsiiDiagnostic } from './jsii-diagnostic';\nimport { ProjectInfo } from './project-info';\nimport { WARNINGSCODE_FILE_NAME } from './transforms/deprecation-warnings';\nimport { TypeScriptConfig, TypeScriptConfigValidationRuleSet } from './tsconfig';\nimport { BASE_COMPILER_OPTIONS, convertForJson } from './tsconfig/compiler-options';\nimport { TypeScriptConfigValidator } from './tsconfig/tsconfig-validator';\nimport { ValidationError } from './tsconfig/validator';\nimport * as utils from './utils';\nimport { isSilenced } from './warnings';\n\nconst LOG = log4js.getLogger('jsii/compiler');\nexport const DIAGNOSTICS = 'diagnostics';\nexport const JSII_DIAGNOSTICS_CODE = 9999;\n\nexport interface CompilerOptions {\n /** The information about the project to be built */\n projectInfo: ProjectInfo;\n /** Whether the compiler should watch for changes or just compile once */\n watch?: boolean;\n /** Whether to detect and generate TypeScript project references */\n projectReferences?: boolean;\n /** Whether to fail when a warning is emitted */\n failOnWarnings?: boolean;\n /** Whether to strip deprecated members from emitted artifacts */\n stripDeprecated?: boolean;\n /** The path to an allowlist of FQNs to strip if stripDeprecated is set */\n stripDeprecatedAllowListFile?: string;\n /** Whether to add warnings for deprecated elements */\n addDeprecationWarnings?: boolean;\n /**\n * The name of the tsconfig file to generate.\n * Cannot be used at the same time as `typeScriptConfig`.\n * @default \"tsconfig.json\"\n */\n generateTypeScriptConfig?: string;\n /**\n * The name of the tsconfig file to use.\n * Cannot be used at the same time as `generateTypeScriptConfig`.\n * @default - generate the tsconfig file\n */\n typeScriptConfig?: string;\n /**\n * The ruleset to validate the provided tsconfig file against.\n * Can only be used when `typeScriptConfig` is provided.\n * @default TypeScriptConfigValidationRuleSet.STRICT - if `typeScriptConfig` is provided\n */\n validateTypeScriptConfig?: TypeScriptConfigValidationRuleSet;\n /**\n * Whether to compress the assembly\n * @default false\n */\n compressAssembly?: boolean;\n}\n\nexport class Compiler implements Emitter {\n private readonly system: ts.System;\n private readonly compilerHost: ts.CompilerHost;\n private readonly userProvidedTypeScriptConfig: boolean;\n private readonly tsconfig: TypeScriptConfig;\n private rootFiles: string[] = [];\n private readonly configPath: string;\n private readonly projectRoot: string;\n\n public constructor(private readonly options: CompilerOptions) {\n if (options.generateTypeScriptConfig != null && options.typeScriptConfig != null) {\n throw new utils.JsiiError(\n 'Cannot use `generateTypeScriptConfig` and `typeScriptConfig` together. Provide only one of them.',\n );\n }\n\n this.projectRoot = this.options.projectInfo.projectRoot;\n const configFileName = options.typeScriptConfig ?? options.generateTypeScriptConfig ?? 'tsconfig.json';\n this.configPath = path.join(this.projectRoot, configFileName);\n this.userProvidedTypeScriptConfig = Boolean(options.typeScriptConfig);\n\n this.system = {\n ...ts.sys,\n getCurrentDirectory: () => this.projectRoot,\n createDirectory: (pth) => ts.sys.createDirectory(path.resolve(this.projectRoot, pth)),\n deleteFile: ts.sys.deleteFile && ((pth) => ts.sys.deleteFile!(path.join(this.projectRoot, pth))),\n fileExists: (pth) => ts.sys.fileExists(path.resolve(this.projectRoot, pth)),\n getFileSize: ts.sys.getFileSize && ((pth) => ts.sys.getFileSize!(path.resolve(this.projectRoot, pth))),\n readFile: (pth, encoding) => ts.sys.readFile(path.resolve(this.projectRoot, pth), encoding),\n watchFile:\n ts.sys.watchFile &&\n ((pth, callback, pollingInterval, watchOptions) =>\n ts.sys.watchFile!(path.resolve(this.projectRoot, pth), callback, pollingInterval, watchOptions)),\n writeFile: (pth, data, writeByteOrderMark) =>\n ts.sys.writeFile(path.resolve(this.projectRoot, pth), data, writeByteOrderMark),\n };\n\n this.tsconfig = this.configureTypeScript();\n this.compilerHost = ts.createIncrementalCompilerHost(this.tsconfig.compilerOptions, this.system);\n }\n\n /**\n * Compiles the configured program.\n *\n * @param files can be specified to override the standard source code location logic. Useful for example when testing \"negatives\".\n */\n public emit(...files: string[]): ts.EmitResult {\n this.prepareForBuild(...files);\n return this.buildOnce();\n }\n\n /**\n * Watches for file-system changes and dynamically recompiles the project as needed. In non-blocking mode, this\n * returns the TypeScript watch handle for the application to use.\n *\n * @internal\n */\n public async watch(opts: NonBlockingWatchOptions): Promise<ts.Watch<ts.BuilderProgram>>;\n /**\n * Watches for file-system changes and dynamically recompiles the project as needed. In blocking mode, this results\n * in a never-resolving promise.\n */\n public async watch(): Promise<never>;\n public async watch(opts?: NonBlockingWatchOptions): Promise<ts.Watch<ts.BuilderProgram> | never> {\n this.prepareForBuild();\n\n const host = ts.createWatchCompilerHost(\n this.configPath,\n {\n ...this.tsconfig.compilerOptions,\n noEmitOnError: false,\n },\n this.system,\n ts.createEmitAndSemanticDiagnosticsBuilderProgram,\n opts?.reportDiagnostics,\n opts?.reportWatchStatus,\n this.tsconfig.watchOptions,\n );\n if (!host.getDefaultLibLocation) {\n throw new Error('No default library location was found on the TypeScript compiler host!');\n }\n const orig = host.afterProgramCreate;\n // This is a callback cascade, so it's \"okay\" to return an unhandled promise there. This may\n // cause an unhandled promise rejection warning, but that's not a big deal.\n //\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n host.afterProgramCreate = (builderProgram) => {\n const startTime = Date.now();\n const emitResult = this.consumeProgram(builderProgram.getProgram(), host.getDefaultLibLocation!());\n\n for (const diag of emitResult.diagnostics.filter((d) => d.code === JSII_DIAGNOSTICS_CODE)) {\n utils.logDiagnostic(diag, this.projectRoot);\n }\n\n console.log(\n utils.formatCompilationSummary(emitResult.diagnostics, emitResult.emitSkipped, Date.now() - startTime),\n );\n\n if (orig) {\n orig.call(host, builderProgram);\n }\n if (opts?.compilationComplete) {\n opts.compilationComplete(emitResult);\n }\n };\n const watch = ts.createWatchProgram(host);\n\n if (opts?.nonBlocking) {\n // In non-blocking mode, returns the handle to the TypeScript watch interface.\n return watch;\n }\n // In blocking mode, returns a never-resolving promise.\n return new Promise<never>(() => null);\n }\n\n /**\n * Prepares the project for build, by creating the necessary configuration\n * file(s), and assigning the relevant root file(s).\n *\n * @param files the files that were specified as input in the CLI invocation.\n */\n private configureTypeScript(): TypeScriptConfig {\n if (this.userProvidedTypeScriptConfig) {\n const config = this.readTypeScriptConfig();\n\n // emit a warning if validation is disabled\n const rules = this.options.validateTypeScriptConfig ?? TypeScriptConfigValidationRuleSet.NONE;\n if (rules === TypeScriptConfigValidationRuleSet.NONE) {\n utils.logDiagnostic(\n JsiiDiagnostic.JSII_4009_DISABLED_TSCONFIG_VALIDATION.create(undefined, this.configPath),\n this.projectRoot,\n );\n }\n\n // validate the user provided config\n if (rules !== TypeScriptConfigValidationRuleSet.NONE) {\n const configName = path.relative(this.projectRoot, this.configPath);\n try {\n const validator = new TypeScriptConfigValidator(rules);\n validator.validate({\n ...config,\n // convert the internal format to the user format which is what the validator operates on\n compilerOptions: convertForJson(config.compilerOptions),\n });\n } catch (error: unknown) {\n if (error instanceof ValidationError) {\n utils.logDiagnostic(\n JsiiDiagnostic.JSII_4000_FAILED_TSCONFIG_VALIDATION.create(\n undefined,\n configName,\n rules,\n error.violations,\n ),\n this.projectRoot,\n );\n }\n\n throw new utils.JsiiError(\n `Failed validation of tsconfig \"compilerOptions\" in \"${configName}\" against rule set \"${rules}\"!`,\n );\n }\n }\n\n return config;\n }\n\n // generated config if none is provided by the user\n return this.buildTypeScriptConfig();\n }\n\n /**\n * Final preparations of the project for build.\n *\n * These are preparations that either\n * - must happen immediately before the build, or\n * - can be different for every build like assigning the relevant root file(s).\n *\n * @param files the files that were specified as input in the CLI invocation.\n */\n private prepareForBuild(...files: string[]) {\n if (!this.userProvidedTypeScriptConfig) {\n this.writeTypeScriptConfig();\n }\n\n this.rootFiles = this.determineSources(files);\n }\n\n /**\n * Do a single build\n */\n private buildOnce(): ts.EmitResult {\n if (!this.compilerHost.getDefaultLibLocation) {\n throw new Error('No default library location was found on the TypeScript compiler host!');\n }\n\n const tsconf = this.tsconfig!;\n\n const prog = ts.createIncrementalProgram({\n rootNames: this.rootFiles.concat(_pathOfLibraries(tsconf.compilerOptions, this.compilerHost)),\n options: tsconf.compilerOptions,\n // Make the references absolute for the compiler\n projectReferences: tsconf.references?.map((ref) => ({\n path: path.resolve(path.dirname(this.configPath), ref.path),\n })),\n host: this.compilerHost,\n });\n\n return this.consumeProgram(prog.getProgram(), this.compilerHost.getDefaultLibLocation());\n }\n\n private consumeProgram(program: ts.Program, stdlib: string): ts.EmitResult {\n const diagnostics = [...ts.getPreEmitDiagnostics(program)];\n let hasErrors = false;\n\n if (!hasErrors && this.diagsHaveAbortableErrors(diagnostics)) {\n hasErrors = true;\n LOG.error('Compilation errors prevented the JSII assembly from being created');\n }\n\n // Do the \"Assembler\" part first because we need some of the analysis done in there\n // to post-process the AST\n const assembler = new Assembler(this.options.projectInfo, this.system, program, stdlib, {\n stripDeprecated: this.options.stripDeprecated,\n stripDeprecatedAllowListFile: this.options.stripDeprecatedAllowListFile,\n addDeprecationWarnings: this.options.addDeprecationWarnings,\n compressAssembly: this.options.compressAssembly,\n });\n\n try {\n const assmEmit = assembler.emit();\n if (!hasErrors && (assmEmit.emitSkipped || this.diagsHaveAbortableErrors(assmEmit.diagnostics))) {\n hasErrors = true;\n LOG.error('Type model errors prevented the JSII assembly from being created');\n }\n\n diagnostics.push(...assmEmit.diagnostics);\n } catch (e: any) {\n diagnostics.push(JsiiDiagnostic.JSII_9997_UNKNOWN_ERROR.createDetached(e));\n hasErrors = true;\n }\n\n // Do the emit, but add in transformers which are going to replace real\n // comments with synthetic ones.\n const emit = program.emit(\n undefined, // targetSourceFile\n undefined, // writeFile\n undefined, // cancellationToken\n undefined, // emitOnlyDtsFiles\n assembler.customTransformers,\n );\n diagnostics.push(...emit.diagnostics);\n\n if (!hasErrors && (emit.emitSkipped || this.diagsHaveAbortableErrors(emit.diagnostics))) {\n hasErrors = true;\n LOG.error('Compilation errors prevented the JSII assembly from being created');\n }\n\n // Some extra validation on the config.\n // Make sure that { \"./.warnings.jsii.js\": \"./.warnings.jsii.js\" } is in the set of\n // exports, if they are specified.\n if (this.options.addDeprecationWarnings && this.options.projectInfo.exports !== undefined) {\n const expected = `./${WARNINGSCODE_FILE_NAME}`;\n const warningsExport = Object.entries(this.options.projectInfo.exports).filter(\n ([k, v]) => k === expected && v === expected,\n );\n\n if (warningsExport.length === 0) {\n hasErrors = true;\n diagnostics.push(JsiiDiagnostic.JSII_0007_MISSING_WARNINGS_EXPORT.createDetached());\n }\n }\n\n return {\n emitSkipped: hasErrors,\n diagnostics: ts.sortAndDeduplicateDiagnostics(diagnostics),\n emittedFiles: emit.emittedFiles,\n };\n }\n\n /**\n * Build the TypeScript config object from jsii config\n *\n * This is the object that will be written to disk\n * unless an existing tsconfig was provided.\n */\n private buildTypeScriptConfig(): TypeScriptConfig {\n let references: string[] | undefined;\n\n const isComposite =\n this.options.projectReferences !== undefined\n ? this.options.projectReferences\n : this.options.projectInfo.projectReferences !== undefined\n ? this.options.projectInfo.projectReferences\n : false;\n if (isComposite) {\n references = this.findProjectReferences();\n }\n\n const pi = this.options.projectInfo;\n\n return {\n compilerOptions: {\n ...pi.tsc,\n ...BASE_COMPILER_OPTIONS,\n // Enable composite mode if project references are enabled\n composite: isComposite,\n // When incremental, configure a tsbuildinfo file\n tsBuildInfoFile: path.join(pi.tsc?.outDir ?? '.', 'tsconfig.tsbuildinfo'),\n },\n include: [pi.tsc?.rootDir != null ? path.join(pi.tsc.rootDir, '**', '*.ts') : path.join('**', '*.ts')],\n exclude: [\n 'node_modules',\n ...(pi.excludeTypescript ?? []),\n ...(pi.tsc?.outDir != null &&\n (pi.tsc?.rootDir == null || path.resolve(pi.tsc.outDir).startsWith(path.resolve(pi.tsc.rootDir) + path.sep))\n ? [path.join(pi.tsc.outDir, '**', '*.ts')]\n : []),\n ],\n // Change the references a little. We write 'originalpath' to the\n // file under the 'path' key, which is the same as what the\n // TypeScript compiler does. Make it relative so that the files are\n // movable. Not strictly required but looks better.\n references: references?.map((p) => ({ path: p })),\n };\n }\n\n /**\n * Load the TypeScript config object from a provided file\n */\n private readTypeScriptConfig(): TypeScriptConfig {\n const projectRoot = this.options.projectInfo.projectRoot;\n const { config, error } = ts.readConfigFile(this.configPath, ts.sys.readFile);\n if (error) {\n utils.logDiagnostic(error, projectRoot);\n throw new utils.JsiiError(`Failed to load tsconfig at ${this.configPath}`);\n }\n const extended = ts.parseJsonConfigFileContent(config, ts.sys, projectRoot);\n // the tsconfig parser adds this in, but it is not an expected compilerOption\n delete extended.options.configFilePath;\n\n return {\n compilerOptions: extended.options,\n watchOptions: extended.watchOptions,\n include: extended.fileNames,\n };\n }\n\n /**\n * Creates a `tsconfig.json` file to improve the IDE experience.\n *\n * @return the fully qualified path to the `tsconfig.json` file\n */\n private writeTypeScriptConfig(): void {\n const commentKey = '_generated_by_jsii_';\n const commentValue = 'Generated by jsii - safe to delete, and ideally should be in .gitignore';\n\n (this.tsconfig as any)[commentKey] = commentValue;\n\n if (fs.existsSync(this.configPath)) {\n const currentConfig = JSON.parse(fs.readFileSync(this.configPath, 'utf-8'));\n if (!(commentKey in currentConfig)) {\n throw new utils.JsiiError(\n `A '${this.configPath}' file that was not generated by jsii is in ${this.options.projectInfo.projectRoot}. Aborting instead of overwriting.`,\n );\n }\n }\n\n const outputConfig = {\n ...this.tsconfig,\n compilerOptions: convertForJson(this.tsconfig?.compilerOptions),\n };\n\n LOG.debug(`Creating or updating ${chalk.blue(this.configPath)}`);\n fs.writeFileSync(this.configPath, JSON.stringify(outputConfig, null, 2), 'utf8');\n }\n\n /**\n * Find all dependencies that look like TypeScript projects.\n *\n * Enumerate all dependencies, if they have a tsconfig.json file with\n * \"composite: true\" we consider them project references.\n *\n * (Note: TypeScript seems to only correctly find transitive project references\n * if there's an \"index\" tsconfig.json of all projects somewhere up the directory\n * tree)\n */\n private findProjectReferences(): string[] {\n const pkg = this.options.projectInfo.packageJson;\n\n const ret = new Array<string>();\n\n const dependencyNames = new Set<string>();\n for (const dependencyMap of [pkg.dependencies, pkg.devDependencies, pkg.peerDependencies]) {\n if (dependencyMap === undefined) {\n continue;\n }\n for (const name of Object.keys(dependencyMap)) {\n dependencyNames.add(name);\n }\n }\n\n for (const tsconfigFile of Array.from(dependencyNames).map((depName) => this.findMonorepoPeerTsconfig(depName))) {\n if (!tsconfigFile) {\n continue;\n }\n\n const { config: tsconfig } = ts.readConfigFile(tsconfigFile, this.system.readFile);\n\n // Add references to any TypeScript package we find that is 'composite' enabled.\n // Make it relative.\n if (tsconfig.compilerOptions?.composite) {\n ret.push(path.relative(this.options.projectInfo.projectRoot, path.dirname(tsconfigFile)));\n } else {\n // Not a composite package--if this package is in a node_modules directory, that is most\n // likely correct, otherwise it is most likely an error (heuristic here, I don't know how to\n // properly check this).\n if (tsconfigFile.includes('node_modules')) {\n LOG.warn('%s: not a composite TypeScript package, but it probably should be', path.dirname(tsconfigFile));\n }\n }\n }\n\n return ret;\n }\n\n /**\n * Find source files using the same mechanism that the TypeScript compiler itself uses.\n *\n * Respects includes/excludes/etc.\n *\n * This makes it so that running 'typescript' and running 'jsii' has the same behavior.\n */\n private determineSources(files: string[]): string[] {\n // explicitly requested files\n if (files.length > 0) {\n return [...files];\n }\n\n // for user provided config we already have parsed the full list of files\n if (this.userProvidedTypeScriptConfig) {\n return [...(this.tsconfig.include ?? [])];\n }\n\n // finally get the file list for the generated config\n const parseConfigHost = parseConfigHostFromCompilerHost(this.compilerHost);\n const parsed = ts.parseJsonConfigFileContent(this.tsconfig, parseConfigHost, this.options.projectInfo.projectRoot);\n return [...parsed.fileNames];\n }\n\n /**\n * Resolve the given dependency name from the current package, and find the associated tsconfig.json location\n *\n * Because we have the following potential directory layout:\n *\n * package/node_modules/some_dependency\n * package/tsconfig.json\n *\n * We resolve symlinks and only find a \"TypeScript\" dependency if doesn't have 'node_modules' in\n * the path after resolving symlinks (i.e., if it's a peer package in the same monorepo).\n *\n * Returns undefined if no such tsconfig could be found.\n */\n private findMonorepoPeerTsconfig(depName: string): string | undefined {\n // eslint-disable-next-line @typescript-eslint/no-require-imports,@typescript-eslint/no-var-requires\n const { builtinModules } = require('node:module');\n if ((builtinModules ?? []).includes(depName)) {\n // Can happen for modules like 'punycode' which are declared as dependency for polyfill purposes\n return undefined;\n }\n\n try {\n const depDir = findDependencyDirectory(depName, this.options.projectInfo.projectRoot);\n\n const dep = path.join(depDir, 'tsconfig.json');\n if (!fs.existsSync(dep)) {\n return undefined;\n }\n\n // Resolve symlinks, to check if this is a monorepo peer\n const dependencyRealPath = fs.realpathSync(dep);\n if (dependencyRealPath.split(path.sep).includes('node_modules')) {\n return undefined;\n }\n\n return dependencyRealPath;\n } catch (e: any) {\n // @types modules cannot be required, for example\n if (['MODULE_NOT_FOUND', 'ERR_PACKAGE_PATH_NOT_EXPORTED'].includes(e.code)) {\n return undefined;\n }\n throw e;\n }\n }\n\n private diagsHaveAbortableErrors(diags: readonly ts.Diagnostic[]) {\n return diags.some(\n (d) =>\n d.category === ts.DiagnosticCategory.Error ||\n (this.options.failOnWarnings && d.category === ts.DiagnosticCategory.Warning && !isSilenced(d)),\n );\n }\n}\n\n/**\n * Options for Watch in non-blocking mode.\n *\n * @internal\n */\nexport interface NonBlockingWatchOptions {\n /**\n * Signals non-blocking execution\n */\n readonly nonBlocking: true;\n\n /**\n * Configures the diagnostics reporter\n */\n readonly reportDiagnostics: ts.DiagnosticReporter;\n\n /**\n * Configures the watch status reporter\n */\n readonly reportWatchStatus: ts.WatchStatusReporter;\n\n /**\n * This hook gets invoked when a compilation cycle (complete with Assembler execution) completes.\n */\n readonly compilationComplete: (emitResult: ts.EmitResult) => void;\n}\n\nfunction _pathOfLibraries(options: ts.CompilerOptions, host: ts.CompilerHost | ts.WatchCompilerHost<any>): string[] {\n // Prefer user libraries, falling back to a library based on the target if not supplied by the user.\n // This matches tsc behavior.\n const libs = options.lib ?? [ts.getDefaultLibFileName(options)];\n if (libs.length === 0) {\n return [];\n }\n\n const libDir = host.getDefaultLibLocation?.();\n if (!libDir) {\n throw new Error(`Compiler host doesn't have a default library directory available for ${libs.join(', ')}`);\n }\n return libs.map((name) => path.join(libDir, name));\n}\n\nfunction parseConfigHostFromCompilerHost(host: ts.CompilerHost): ts.ParseConfigHost {\n // Copied from upstream\n // https://github.com/Microsoft/TypeScript/blob/9e05abcfd3f8bb3d6775144ede807daceab2e321/src/compiler/program.ts#L3105\n return {\n fileExists: (f) => host.fileExists(f),\n readDirectory(root, extensions, excludes, includes, depth) {\n if (host.readDirectory === undefined) {\n throw new Error(\"'CompilerHost.readDirectory' must be implemented to correctly process 'projectReferences'\");\n }\n return host.readDirectory(root, extensions, excludes, includes, depth);\n },\n readFile: (f) => host.readFile(f),\n useCaseSensitiveFileNames: host.useCaseSensitiveFileNames(),\n trace: host.trace ? (s) => host.trace!(s) : undefined,\n };\n}\n"]}
|