@smoothbricks/nx-plugin 0.7.16 → 0.7.17
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 +6 -0
- package/dist/.build-inputs.json +5 -3
- package/dist/compile-environment.d.ts +8 -0
- package/dist/compile-environment.d.ts.map +1 -0
- package/dist/compile-environment.js +80 -0
- package/dist/dependency-manifests.d.ts +13 -0
- package/dist/dependency-manifests.d.ts.map +1 -0
- package/dist/dependency-manifests.js +20 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -8
- package/dist/managed-files/files.d.ts +3 -3
- package/dist/managed-files/files.js +3 -3
- package/dist/typecheck-route.d.ts +3 -4
- package/dist/typecheck-route.d.ts.map +1 -1
- package/dist/typecheck-route.js +4 -15
- package/managed/raw/patches/{ttsc@0.34.1.patch → ttsc@0.36.3.patch} +728 -71
- package/managed/raw/tooling/direnv/devenv.smoo.nix +1 -1
- package/package.json +4 -4
- package/src/compile-environment.ts +35 -0
- package/src/dependency-manifests.ts +30 -0
- package/src/index.ts +17 -8
- package/src/managed-files/files.ts +3 -3
- package/src/typecheck-route.ts +5 -14
|
@@ -348,7 +348,7 @@ in {
|
|
|
348
348
|
# comment that rots.
|
|
349
349
|
#
|
|
350
350
|
# It needs its own input because the fleet's nixpkgs does not carry that patch:
|
|
351
|
-
# devenv-nixpkgs rolling has no Go 1.27, while ttsc 0.
|
|
351
|
+
# devenv-nixpkgs rolling has no Go 1.27, while ttsc 0.36.3 vendors go1.27.3.
|
|
352
352
|
# Same idiom, and same reason, for any single-package pin — one leaf package
|
|
353
353
|
# from a nixpkgs that has it, lock-pinned, prebuilt, rather than a fleet-wide
|
|
354
354
|
# bump that would move rustc, bun and node too. Not every pairing is
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smoothbricks/nx-plugin",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.17",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./loader.js",
|
|
@@ -661,7 +661,7 @@
|
|
|
661
661
|
"@nx/js": "24.0.3",
|
|
662
662
|
"@smoothbricks/build-inputs": "0.0.3",
|
|
663
663
|
"@smoothbricks/cargo-retain": "0.0.2",
|
|
664
|
-
"@smoothbricks/cowshed": "0.
|
|
664
|
+
"@smoothbricks/cowshed": "0.5.1",
|
|
665
665
|
"@smoothbricks/nextest-extract": "0.0.2",
|
|
666
666
|
"jsonc-parser": "^3.3.1",
|
|
667
667
|
"minimatch": "10.2.5",
|
|
@@ -674,8 +674,8 @@
|
|
|
674
674
|
"yaml": "^2.9.0"
|
|
675
675
|
},
|
|
676
676
|
"devDependencies": {
|
|
677
|
-
"@smoothbricks/lmao": "0.6.
|
|
678
|
-
"@smoothbricks/validation": "0.1.
|
|
677
|
+
"@smoothbricks/lmao": "0.6.2",
|
|
678
|
+
"@smoothbricks/validation": "0.1.14",
|
|
679
679
|
"fast-check": "^4.4.0"
|
|
680
680
|
}
|
|
681
681
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import typia from 'typia';
|
|
2
|
+
import type { DependencyManifest } from './dependency-manifests.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* What a package whose ttsc plugin lowers by environment variables declares in its manifest, as `smoo.compileEnv`:
|
|
6
|
+
* the variables the plugin's output depends on. `@smoothbricks/lmao-ttsc` declares `NODE_ENV`, which decides whether
|
|
7
|
+
* trace statements compile away (specs/lmao/01o_typescript_transformer.md §6.3). Every project that depends on such a
|
|
8
|
+
* package directly compiles through its plugin, so each target whose output is that compile hashes the variables.
|
|
9
|
+
*/
|
|
10
|
+
interface DeclaringManifest {
|
|
11
|
+
readonly smoo?: { readonly compileEnv?: readonly string[] };
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const validateManifest = typia.createValidate<DeclaringManifest>();
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The environment variables a project's transformed output depends on, over its direct dependencies' manifests, once
|
|
18
|
+
* each in declaration order. A manifest that declares `smoo.compileEnv` in another shape refuses the inference by its
|
|
19
|
+
* path and the field it got wrong.
|
|
20
|
+
*/
|
|
21
|
+
export function compileEnvironment(manifests: readonly DependencyManifest[]): string[] {
|
|
22
|
+
const names: string[] = [];
|
|
23
|
+
for (const manifest of manifests) {
|
|
24
|
+
const checked = validateManifest(manifest.json);
|
|
25
|
+
if (!checked.success) {
|
|
26
|
+
throw new Error(
|
|
27
|
+
`${manifest.path}: smoo.compileEnv must be ['<VARIABLE>', ...]: ${checked.errors
|
|
28
|
+
.map((error) => `${error.path} expected ${error.expected}`)
|
|
29
|
+
.join('; ')}`,
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
for (const name of checked.data.smoo?.compileEnv ?? []) if (!names.includes(name)) names.push(name);
|
|
33
|
+
}
|
|
34
|
+
return names;
|
|
35
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
|
|
5
|
+
/** One installed direct dependency's manifest: its package name, where it is, and its parsed JSON. */
|
|
6
|
+
export interface DependencyManifest {
|
|
7
|
+
readonly name: string;
|
|
8
|
+
readonly path: string;
|
|
9
|
+
readonly json: unknown;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The manifests of a project's direct dependencies, the ones ttsc discovers plugins on (`dependencies` and
|
|
14
|
+
* `devDependencies`), once per name. Each is the manifest Node resolution reaches from the project, as ttsc reads it;
|
|
15
|
+
* a dependency that is not installed has none. Read once per project, for every declaration inference reads from them.
|
|
16
|
+
*/
|
|
17
|
+
export function directDependencyManifests(
|
|
18
|
+
packageJsonPath: string,
|
|
19
|
+
dependencies: readonly string[],
|
|
20
|
+
): DependencyManifest[] {
|
|
21
|
+
const lookup = createRequire(packageJsonPath);
|
|
22
|
+
const manifests: DependencyManifest[] = [];
|
|
23
|
+
for (const name of new Set(dependencies)) {
|
|
24
|
+
const path = (lookup.resolve.paths(name) ?? [])
|
|
25
|
+
.map((root) => join(root, ...name.split('/'), 'package.json'))
|
|
26
|
+
.find((candidate) => existsSync(candidate));
|
|
27
|
+
if (path !== undefined) manifests.push({ name, path, json: JSON.parse(readFileSync(path, 'utf-8')) });
|
|
28
|
+
}
|
|
29
|
+
return manifests;
|
|
30
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -63,6 +63,7 @@ import {
|
|
|
63
63
|
type SerialTestGroup,
|
|
64
64
|
serialTestGroups,
|
|
65
65
|
} from './cargo-workspace.js';
|
|
66
|
+
import { compileEnvironment } from './compile-environment.js';
|
|
66
67
|
import {
|
|
67
68
|
CARGO_CROSS_LINT_COMMAND,
|
|
68
69
|
CARGO_CROSS_LINT_TARGET,
|
|
@@ -75,6 +76,7 @@ import {
|
|
|
75
76
|
cargoFrozen,
|
|
76
77
|
runsFrozenCargo,
|
|
77
78
|
} from './cross-check-policy.js';
|
|
79
|
+
import { type DependencyManifest, directDependencyManifests } from './dependency-manifests.js';
|
|
78
80
|
import { eslintConfigClosure } from './eslint-config-closure.js';
|
|
79
81
|
import type { EslintFileSet } from './eslint-file-set.js';
|
|
80
82
|
import { ESLINT_SOURCES_GLOB, eslintSources } from './eslint-sources.js';
|
|
@@ -160,11 +162,8 @@ interface TypecheckTargets {
|
|
|
160
162
|
* which bun.lock and the patches in its check inputs already key, and it waits for the targets the declaring package
|
|
161
163
|
* names to prepare the plugin binaries ttsc loads. Every other project runs the pinned native compiler.
|
|
162
164
|
*/
|
|
163
|
-
function typecheckTargets(
|
|
164
|
-
const route = typecheckRoute(
|
|
165
|
-
...Object.keys(packageJson.dependencies ?? {}),
|
|
166
|
-
...Object.keys(packageJson.devDependencies ?? {}),
|
|
167
|
-
]);
|
|
165
|
+
function typecheckTargets(manifests: readonly DependencyManifest[]): TypecheckTargets {
|
|
166
|
+
const route = typecheckRoute(manifests);
|
|
168
167
|
return route.declaredBy.length === 0
|
|
169
168
|
? { command: typecheckCommand, inputs: [TYPECHECK_COMPILER_INPUT], dependsOn: [] }
|
|
170
169
|
: { command: (args) => `ttsc ${args}`, inputs: [], dependsOn: route.dependsOn };
|
|
@@ -1625,7 +1624,14 @@ async function createProjectTargets(
|
|
|
1625
1624
|
const projectRoot = dirname(packageJsonPath);
|
|
1626
1625
|
const absoluteProjectRoot = join(workspaceRoot, projectRoot);
|
|
1627
1626
|
const packageJson = await readPackageJson(join(workspaceRoot, packageJsonPath));
|
|
1628
|
-
const
|
|
1627
|
+
const dependencyManifests = directDependencyManifests(join(workspaceRoot, packageJsonPath), [
|
|
1628
|
+
...Object.keys(packageJson.dependencies ?? {}),
|
|
1629
|
+
...Object.keys(packageJson.devDependencies ?? {}),
|
|
1630
|
+
]);
|
|
1631
|
+
const typecheck = typecheckTargets(dependencyManifests);
|
|
1632
|
+
// The environment a direct dependency's ttsc plugin lowers by (compile-environment.ts): the emitted JavaScript is a
|
|
1633
|
+
// function of it, so every target whose output is the transformed compile hashes it. A check never is.
|
|
1634
|
+
const compileEnvInputs = compileEnvironment(dependencyManifests).map((name) => ({ env: name }));
|
|
1629
1635
|
const projectName = packageJson.nx?.name ?? packageJson.name;
|
|
1630
1636
|
if (typeof projectName !== 'string' || projectName.length === 0) {
|
|
1631
1637
|
throw new Error(`${packageJsonPath} must declare a non-empty package or nx project name`);
|
|
@@ -1726,7 +1732,7 @@ async function createProjectTargets(
|
|
|
1726
1732
|
targets['tsc-js'] = {
|
|
1727
1733
|
executor: '@smoothbricks/nx-plugin:typescript-emit',
|
|
1728
1734
|
cache: true,
|
|
1729
|
-
inputs: ['production', '^production', ...toolchainInputs, '{projectRoot}/tsconfig.lib.json'],
|
|
1735
|
+
inputs: ['production', '^production', ...toolchainInputs, ...compileEnvInputs, '{projectRoot}/tsconfig.lib.json'],
|
|
1730
1736
|
outputs: inferTypescriptOutputs(libOutDir),
|
|
1731
1737
|
dependsOn: ['^*-js', ...(cargoWasmConfig ? ['cargo-wasm'] : [])],
|
|
1732
1738
|
options: {
|
|
@@ -1754,7 +1760,10 @@ async function createProjectTargets(
|
|
|
1754
1760
|
};
|
|
1755
1761
|
Object.assign(
|
|
1756
1762
|
targets,
|
|
1757
|
-
scriptcPlatformTargets(packageJson, packageJsonPath, projectRoot, libTsconfigPath,
|
|
1763
|
+
scriptcPlatformTargets(packageJson, packageJsonPath, projectRoot, libTsconfigPath, [
|
|
1764
|
+
...toolchainInputs,
|
|
1765
|
+
...compileEnvInputs,
|
|
1766
|
+
]),
|
|
1758
1767
|
);
|
|
1759
1768
|
}
|
|
1760
1769
|
|
|
@@ -72,9 +72,9 @@ export interface ManagedFileContext {
|
|
|
72
72
|
|
|
73
73
|
/** Temporary upstream compiler repairs distributed to smoo-managed Bun workspaces. */
|
|
74
74
|
export const managedTtscPatch = {
|
|
75
|
-
version: '0.
|
|
76
|
-
key: 'ttsc@0.
|
|
77
|
-
path: 'patches/ttsc@0.
|
|
75
|
+
version: '0.36.3',
|
|
76
|
+
key: 'ttsc@0.36.3',
|
|
77
|
+
path: 'patches/ttsc@0.36.3.patch',
|
|
78
78
|
} as const;
|
|
79
79
|
|
|
80
80
|
/** Maintained Nx 24.0.3 repairs, applied as an ordinary Bun patchedDependency over the registry release. */
|
package/src/typecheck-route.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
-
import { createRequire } from 'node:module';
|
|
3
|
-
import { join } from 'node:path';
|
|
4
1
|
import typia from 'typia';
|
|
2
|
+
import type { DependencyManifest } from './dependency-manifests.js';
|
|
5
3
|
|
|
6
4
|
/**
|
|
7
5
|
* What a package whose ttsc plugin lowers a dialect declares in its manifest, as `smoo.typecheck`: every project that
|
|
@@ -33,21 +31,14 @@ export interface TypecheckRoute {
|
|
|
33
31
|
}
|
|
34
32
|
|
|
35
33
|
/**
|
|
36
|
-
* The typecheck route of
|
|
37
|
-
* discovers plugins on: `dependencies` and `devDependencies`). Each dependency's manifest is the one Node resolution
|
|
38
|
-
* reaches from the project, as ttsc reads it; a dependency that is not installed declares nothing. A manifest that
|
|
34
|
+
* The typecheck route of a project over its direct dependencies' manifests (dependency-manifests.ts). A manifest that
|
|
39
35
|
* declares `smoo.typecheck` in another shape refuses the inference by its path and the field it got wrong.
|
|
40
36
|
*/
|
|
41
|
-
export function typecheckRoute(
|
|
37
|
+
export function typecheckRoute(manifests: readonly DependencyManifest[]): TypecheckRoute {
|
|
42
38
|
const declaredBy: string[] = [];
|
|
43
39
|
const dependsOn: string[] = [];
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
const manifest = (lookup.resolve.paths(name) ?? [])
|
|
47
|
-
.map((root) => join(root, ...name.split('/'), 'package.json'))
|
|
48
|
-
.find((candidate) => existsSync(candidate));
|
|
49
|
-
if (manifest === undefined) continue;
|
|
50
|
-
const checked = validateManifest(JSON.parse(readFileSync(manifest, 'utf-8')));
|
|
40
|
+
for (const { name, path: manifest, json } of manifests) {
|
|
41
|
+
const checked = validateManifest(json);
|
|
51
42
|
if (!checked.success) {
|
|
52
43
|
throw new Error(
|
|
53
44
|
`${manifest}: smoo.typecheck must be { compiler: 'ttsc', dependsOn: ['<project>:<target>', ...] }: ${checked.errors
|