tstyche 1.0.0-beta.8 → 1.0.0-beta.9
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/CHANGELOG.md +7 -0
- package/build/tstyche.js +22 -13
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [1.0.0-beta.9] - 2024-01-05
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- Fix `"target": ["current"]` support for TypeScript 5.2 and below ([#83](https://github.com/tstyche/tstyche/pull/83))
|
|
8
|
+
|
|
3
9
|
## [1.0.0-beta.8] - 2024-01-05
|
|
4
10
|
|
|
5
11
|
### Changed
|
|
@@ -94,6 +100,7 @@
|
|
|
94
100
|
|
|
95
101
|
_First pre-release._
|
|
96
102
|
|
|
103
|
+
[1.0.0-beta.9]: https://github.com/tstyche/tstyche/releases/tag/v1.0.0-beta.9
|
|
97
104
|
[1.0.0-beta.8]: https://github.com/tstyche/tstyche/releases/tag/v1.0.0-beta.8
|
|
98
105
|
[1.0.0-beta.7]: https://github.com/tstyche/tstyche/releases/tag/v1.0.0-beta.7
|
|
99
106
|
[1.0.0-beta.6]: https://github.com/tstyche/tstyche/releases/tag/v1.0.0-beta.6
|
package/build/tstyche.js
CHANGED
|
@@ -2525,7 +2525,7 @@ class TSTyche {
|
|
|
2525
2525
|
#abortController = new AbortController();
|
|
2526
2526
|
#storeService;
|
|
2527
2527
|
#taskRunner;
|
|
2528
|
-
static version = "1.0.0-beta.
|
|
2528
|
+
static version = "1.0.0-beta.9";
|
|
2529
2529
|
constructor(resolvedConfig, storeService) {
|
|
2530
2530
|
this.resolvedConfig = resolvedConfig;
|
|
2531
2531
|
this.#storeService = storeService;
|
|
@@ -3521,16 +3521,16 @@ class StoreService {
|
|
|
3521
3521
|
if (compilerInstance != null) {
|
|
3522
3522
|
return compilerInstance;
|
|
3523
3523
|
}
|
|
3524
|
-
|
|
3524
|
+
const modulePaths = [];
|
|
3525
3525
|
if (tag === "current") {
|
|
3526
3526
|
try {
|
|
3527
|
-
|
|
3527
|
+
modulePaths.push(this.#nodeRequire.resolve("typescript/lib/tsserverlibrary.js"), this.#nodeRequire.resolve("typescript"));
|
|
3528
3528
|
}
|
|
3529
3529
|
catch (error) {
|
|
3530
3530
|
this.#onDiagnostic(Diagnostic.fromError("Failed to resolve locally installed 'typescript' package. It might be not installed.", error));
|
|
3531
3531
|
}
|
|
3532
3532
|
}
|
|
3533
|
-
if (
|
|
3533
|
+
if (modulePaths.length === 0) {
|
|
3534
3534
|
if (tag === "current") {
|
|
3535
3535
|
return;
|
|
3536
3536
|
}
|
|
@@ -3543,24 +3543,33 @@ class StoreService {
|
|
|
3543
3543
|
if (compilerInstance != null) {
|
|
3544
3544
|
return compilerInstance;
|
|
3545
3545
|
}
|
|
3546
|
-
|
|
3546
|
+
const installedModulePath = await this.#packageInstaller.ensure(version, signal);
|
|
3547
|
+
if (installedModulePath != null) {
|
|
3548
|
+
modulePaths.push(installedModulePath);
|
|
3549
|
+
}
|
|
3547
3550
|
}
|
|
3548
|
-
if (
|
|
3549
|
-
compilerInstance = await this.#loadModule(
|
|
3551
|
+
if (modulePaths.length !== 0) {
|
|
3552
|
+
compilerInstance = await this.#loadModule(modulePaths);
|
|
3550
3553
|
this.#compilerInstanceCache.set(tag, compilerInstance);
|
|
3551
3554
|
this.#compilerInstanceCache.set(compilerInstance.version, compilerInstance);
|
|
3552
3555
|
return compilerInstance;
|
|
3553
3556
|
}
|
|
3554
3557
|
return;
|
|
3555
3558
|
}
|
|
3556
|
-
async #loadModule(
|
|
3559
|
+
async #loadModule(modulePaths) {
|
|
3557
3560
|
const exports = {};
|
|
3558
|
-
const require = createRequire(modulePath);
|
|
3559
3561
|
const module = { exports };
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3562
|
+
for (const modulePath of modulePaths) {
|
|
3563
|
+
const require = createRequire(modulePath);
|
|
3564
|
+
let sourceText = await fs.readFile(modulePath, { encoding: "utf8" });
|
|
3565
|
+
if (sourceText.length < 3000) {
|
|
3566
|
+
continue;
|
|
3567
|
+
}
|
|
3568
|
+
sourceText = sourceText.replace("isTypeAssignableTo,", "isTypeAssignableTo, isTypeIdenticalTo, isTypeSubtypeOf,");
|
|
3569
|
+
const compiledWrapper = vm.compileFunction(sourceText, ["exports", "require", "module", "__filename", "__dirname"], { filename: modulePath });
|
|
3570
|
+
compiledWrapper(exports, require, module, modulePath, Path.dirname(modulePath));
|
|
3571
|
+
break;
|
|
3572
|
+
}
|
|
3564
3573
|
return module.exports;
|
|
3565
3574
|
}
|
|
3566
3575
|
#onDiagnostic = (diagnostic) => {
|