ttsc 0.26.2 → 0.27.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 +9 -0
- package/cmd/ttsc/api_transform.go +17 -3
- package/cmd/ttscgraph/auxiliary_identity_state_tracks_retargets_not_source_contents_test.go +85 -0
- package/cmd/ttscgraph/disk_realpath_other.go +16 -0
- package/cmd/ttscgraph/disk_realpath_windows.go +56 -0
- package/cmd/ttscgraph/serve.go +104 -35
- package/driver/emit_plugin.go +20 -3
- package/driver/graph.go +64 -11
- package/driver/input_observation.go +273 -0
- package/driver/input_observation_test.go +149 -0
- package/driver/plugins.go +384 -4
- package/driver/program.go +54 -1
- package/driver/resolution_candidates.go +13 -5
- package/driver/rewrite.go +45 -2
- package/lib/TtscCompiler.d.ts +12 -11
- package/lib/TtscCompiler.js +44 -29
- package/lib/TtscCompiler.js.map +1 -1
- package/lib/compiler/internal/captureProcessOutput.js +2 -2
- package/lib/compiler/internal/captureProcessOutput.js.map +1 -1
- package/lib/compiler/internal/compileProjectInMemory.js +4 -3
- package/lib/compiler/internal/compileProjectInMemory.js.map +1 -1
- package/lib/compiler/internal/resolveEmittedJavaScript.d.ts +2 -0
- package/lib/compiler/internal/resolveEmittedJavaScript.js +3 -0
- package/lib/compiler/internal/resolveEmittedJavaScript.js.map +1 -1
- package/lib/compiler/internal/runBuild.d.ts +1 -1
- package/lib/compiler/internal/runBuild.js +80 -34
- package/lib/compiler/internal/runBuild.js.map +1 -1
- package/lib/compiler/internal/runSingleFileEmit.js +2 -2
- package/lib/compiler/internal/runSingleFileEmit.js.map +1 -1
- package/lib/compiler/internal/sharedHostHelpers.d.ts +28 -0
- package/lib/compiler/internal/sharedHostHelpers.js +39 -0
- package/lib/compiler/internal/sharedHostHelpers.js.map +1 -1
- package/lib/compiler/internal/startResidentTransform.js +12 -4
- package/lib/compiler/internal/startResidentTransform.js.map +1 -1
- package/lib/compiler/internal/transformProjectInMemory.d.ts +3 -0
- package/lib/compiler/internal/transformProjectInMemory.js +239 -35
- package/lib/compiler/internal/transformProjectInMemory.js.map +1 -1
- package/lib/flags/schema.js +12 -5
- package/lib/flags/schema.js.map +1 -1
- package/lib/internal/createCanonicalTempDirectory.d.ts +17 -0
- package/lib/internal/createCanonicalTempDirectory.js +42 -0
- package/lib/internal/createCanonicalTempDirectory.js.map +1 -0
- package/lib/internal/projectInputPathIdentity.d.ts +3 -0
- package/lib/internal/projectInputPathIdentity.js +11 -5
- package/lib/internal/projectInputPathIdentity.js.map +1 -1
- package/lib/internal/resolveNodeBinary.d.ts +14 -0
- package/lib/internal/resolveNodeBinary.js +150 -0
- package/lib/internal/resolveNodeBinary.js.map +1 -0
- package/lib/internal/resolveSafeCacheCleanupTargets.d.ts +15 -0
- package/lib/internal/resolveSafeCacheCleanupTargets.js +61 -0
- package/lib/internal/resolveSafeCacheCleanupTargets.js.map +1 -0
- package/lib/launcher/internal/prepareExecution.d.ts +3 -0
- package/lib/launcher/internal/prepareExecution.js +42 -14
- package/lib/launcher/internal/prepareExecution.js.map +1 -1
- package/lib/launcher/internal/runTtsc.js +25 -13
- package/lib/launcher/internal/runTtsc.js.map +1 -1
- package/lib/launcher/internal/runTtscserver.js +18 -3
- package/lib/launcher/internal/runTtscserver.js.map +1 -1
- package/lib/launcher/internal/runTtsx.js +2 -0
- package/lib/launcher/internal/runTtsx.js.map +1 -1
- package/lib/launcher/internal/runtimeHooks.d.ts +37 -1
- package/lib/launcher/internal/runtimeHooks.js +653 -62
- package/lib/launcher/internal/runtimeHooks.js.map +1 -1
- package/lib/plugin/internal/buildSourcePlugin.d.ts +62 -8
- package/lib/plugin/internal/buildSourcePlugin.js +754 -72
- package/lib/plugin/internal/buildSourcePlugin.js.map +1 -1
- package/lib/plugin/internal/loadProjectPlugins.d.ts +17 -5
- package/lib/plugin/internal/loadProjectPlugins.js +1339 -77
- package/lib/plugin/internal/loadProjectPlugins.js.map +1 -1
- package/lib/register.d.ts +1 -0
- package/lib/register.js +46 -0
- package/lib/register.js.map +1 -0
- package/lib/structures/ITtscCompilerContext.d.ts +6 -3
- package/lib/structures/ITtscCompilerTransformation.d.ts +31 -0
- package/lib/structures/ITtscPlugin.d.ts +33 -0
- package/package.json +16 -9
- package/shim/checker/go.mod +9 -0
- package/shim/checker/go.sum +22 -0
- package/shim/checker/shim.go +75 -0
- package/shim/compiler/incremental.go +45 -8
- package/src/TtscCompiler.ts +55 -33
- package/src/compiler/internal/captureProcessOutput.ts +3 -2
- package/src/compiler/internal/compileProjectInMemory.ts +4 -3
- package/src/compiler/internal/resolveEmittedJavaScript.ts +6 -0
- package/src/compiler/internal/runBuild.ts +102 -39
- package/src/compiler/internal/runSingleFileEmit.ts +2 -2
- package/src/compiler/internal/sharedHostHelpers.ts +44 -0
- package/src/compiler/internal/startResidentTransform.ts +12 -3
- package/src/compiler/internal/transformProjectInMemory.ts +410 -39
- package/src/flags/schema.ts +12 -5
- package/src/internal/createCanonicalTempDirectory.ts +53 -0
- package/src/internal/projectInputPathIdentity.ts +17 -4
- package/src/internal/resolveNodeBinary.ts +173 -0
- package/src/internal/resolveSafeCacheCleanupTargets.ts +85 -0
- package/src/launcher/internal/prepareExecution.ts +50 -14
- package/src/launcher/internal/runTtsc.ts +24 -13
- package/src/launcher/internal/runTtscserver.ts +18 -3
- package/src/launcher/internal/runTtsx.ts +2 -0
- package/src/launcher/internal/runtimeHooks.ts +823 -66
- package/src/plugin/internal/buildSourcePlugin.ts +984 -79
- package/src/plugin/internal/loadProjectPlugins.ts +1718 -104
- package/src/register.ts +47 -0
- package/src/structures/ITtscCompilerContext.ts +6 -3
- package/src/structures/ITtscCompilerTransformation.ts +39 -0
- package/src/structures/ITtscPlugin.ts +36 -0
- package/tools/shim_audit/baseline.json +0 -1
- package/utility/host.go +9 -3
- package/lib/internal/assertSafeExplicitCacheDirectory.d.ts +0 -5
- package/lib/internal/assertSafeExplicitCacheDirectory.js +0 -26
- package/lib/internal/assertSafeExplicitCacheDirectory.js.map +0 -1
- package/src/internal/assertSafeExplicitCacheDirectory.ts +0 -29
|
@@ -2,6 +2,50 @@ import path from "node:path";
|
|
|
2
2
|
|
|
3
3
|
import type { ITtscLoadedNativePlugin } from "../../structures/internal/ITtscLoadedNativePlugin";
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Environment channel carrying the JSON-encoded tsgo argv ttsc forwards to a
|
|
7
|
+
* native sidecar. Mirrors `driver.TsgoArgsEnv` on the Go side; see
|
|
8
|
+
* `runBuild.ts::createNativeTsgoArgs` for why the payload is not a CLI flag.
|
|
9
|
+
*/
|
|
10
|
+
export const TSGO_ARGS_ENV = "TTSC_TSGO_ARGS";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Drop a forwarded-tsgo payload this invocation did not publish itself.
|
|
14
|
+
*
|
|
15
|
+
* Every sidecar env starts from `process.env`, so a ttsc that is itself running
|
|
16
|
+
* inside a plugin sidecar — `@ttsc/lint` evaluating a config file through
|
|
17
|
+
* `ttsx`, for instance — would otherwise hand the outer run's `--strict` to its
|
|
18
|
+
* own sidecars, and `driver.LoadProgram` would apply it. The forwarded argv is
|
|
19
|
+
* per-invocation state the spawning host owns, the same rule
|
|
20
|
+
* `TTSC_PLUGIN_CONFIG_DIR` already follows. A caller that named the variable
|
|
21
|
+
* explicitly keeps it.
|
|
22
|
+
*/
|
|
23
|
+
export function clearInheritedTsgoArgs(
|
|
24
|
+
env: NodeJS.ProcessEnv,
|
|
25
|
+
callerEnv: NodeJS.ProcessEnv | undefined,
|
|
26
|
+
): void {
|
|
27
|
+
if (callerEnv?.[TSGO_ARGS_ENV] === undefined) {
|
|
28
|
+
delete env[TSGO_ARGS_ENV];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The `{ ...process.env, ...callerEnv }` a child process inherits, minus a
|
|
34
|
+
* forwarded-tsgo payload this lane never published.
|
|
35
|
+
*
|
|
36
|
+
* Use it at every spawn whose child can reach `driver.LoadProgram` — the
|
|
37
|
+
* `api-compile` / `api-transform` hosts, and the plugin loader, whose `ttsx`
|
|
38
|
+
* descriptor evaluation compiles a project of its own. One rule at every site
|
|
39
|
+
* beats four sites each reasoning about whether the variable could be present.
|
|
40
|
+
*/
|
|
41
|
+
export function inheritedSidecarEnv(
|
|
42
|
+
callerEnv: NodeJS.ProcessEnv | undefined,
|
|
43
|
+
): NodeJS.ProcessEnv {
|
|
44
|
+
const env: NodeJS.ProcessEnv = { ...process.env, ...callerEnv };
|
|
45
|
+
clearInheritedTsgoArgs(env, callerEnv);
|
|
46
|
+
return env;
|
|
47
|
+
}
|
|
48
|
+
|
|
5
49
|
/**
|
|
6
50
|
* Resolve the caller-declared plugin config anchor to an absolute path, or
|
|
7
51
|
* `undefined` when the caller did not declare one.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
|
|
3
|
+
import { resolveNodeBinary } from "../../internal/resolveNodeBinary";
|
|
3
4
|
import { loadProjectPlugins } from "../../plugin/internal/loadProjectPlugins";
|
|
4
5
|
import type { ITtscCompilerContext } from "../../structures/ITtscCompilerContext";
|
|
5
6
|
import type { ITtscLoadedNativePlugin } from "../../structures/internal/ITtscLoadedNativePlugin";
|
|
@@ -9,6 +10,8 @@ import { resolveBinary } from "./resolveBinary";
|
|
|
9
10
|
import { resolveTsgo } from "./resolveTsgo";
|
|
10
11
|
import {
|
|
11
12
|
assertSharedHostCompatibility,
|
|
13
|
+
clearInheritedTsgoArgs,
|
|
14
|
+
inheritedSidecarEnv,
|
|
12
15
|
linkedTransformPlugins,
|
|
13
16
|
resolvePluginConfigDir,
|
|
14
17
|
selectSharedHostPlugin,
|
|
@@ -52,7 +55,7 @@ export function startResidentTransform(
|
|
|
52
55
|
cacheDir: context.cacheDir ?? context.env?.TTSC_CACHE_DIR,
|
|
53
56
|
cwd,
|
|
54
57
|
entries: context.plugins,
|
|
55
|
-
env:
|
|
58
|
+
env: inheritedSidecarEnv(context.env),
|
|
56
59
|
pluginConfigDir: context.pluginConfigDir,
|
|
57
60
|
projectRoot: context.projectRoot,
|
|
58
61
|
tsconfig: project.path,
|
|
@@ -79,7 +82,7 @@ export function startResidentTransform(
|
|
|
79
82
|
],
|
|
80
83
|
binary: host.binary,
|
|
81
84
|
cwd: project.root,
|
|
82
|
-
env: residentEnv(context, tsgoBinary, loaded.nativePlugins),
|
|
85
|
+
env: residentEnv(context, project.root, tsgoBinary, loaded.nativePlugins),
|
|
83
86
|
});
|
|
84
87
|
return { process: resident, projectRoot: project.root };
|
|
85
88
|
}
|
|
@@ -95,13 +98,13 @@ export function startResidentTransform(
|
|
|
95
98
|
*/
|
|
96
99
|
function residentEnv(
|
|
97
100
|
context: ITtscCompilerContext,
|
|
101
|
+
projectRoot: string,
|
|
98
102
|
tsgoBinary: string,
|
|
99
103
|
nativePlugins: readonly ITtscLoadedNativePlugin[],
|
|
100
104
|
): NodeJS.ProcessEnv {
|
|
101
105
|
const pluginConfigDir = resolvePluginConfigDir(context);
|
|
102
106
|
const env: NodeJS.ProcessEnv = {
|
|
103
107
|
...process.env,
|
|
104
|
-
TTSC_NODE_BINARY: process.env.TTSC_NODE_BINARY ?? process.execPath,
|
|
105
108
|
...(pluginConfigDir === undefined
|
|
106
109
|
? {}
|
|
107
110
|
: { TTSC_PLUGIN_CONFIG_DIR: pluginConfigDir }),
|
|
@@ -111,6 +114,9 @@ function residentEnv(
|
|
|
111
114
|
path.join(__dirname, "..", "..", "launcher", "ttsx.js"),
|
|
112
115
|
...context.env,
|
|
113
116
|
};
|
|
117
|
+
const node = resolveNodeBinary(env, projectRoot);
|
|
118
|
+
if (node === undefined) delete env.TTSC_NODE_BINARY;
|
|
119
|
+
else env.TTSC_NODE_BINARY = node;
|
|
114
120
|
// The anchor is per-invocation state owned by this host: when this run
|
|
115
121
|
// declared none (and the caller's env does not name one), drop any value
|
|
116
122
|
// inherited from an ancestor ttsc process so a nested build never
|
|
@@ -121,6 +127,9 @@ function residentEnv(
|
|
|
121
127
|
) {
|
|
122
128
|
delete env.TTSC_PLUGIN_CONFIG_DIR;
|
|
123
129
|
}
|
|
130
|
+
// This lane forwards no tsgo argv of its own, so anything inherited belongs
|
|
131
|
+
// to an outer ttsc run and must not reach the resident sidecar.
|
|
132
|
+
clearInheritedTsgoArgs(env, context.env);
|
|
124
133
|
const linked = linkedTransformPlugins(nativePlugins);
|
|
125
134
|
if (linked.length !== 0) {
|
|
126
135
|
env.TTSC_LINKED_PLUGINS_JSON = serializeNativePlugins(linked);
|