@jskit-ai/kernel 0.1.96 → 0.1.98
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.
|
@@ -45,7 +45,7 @@ function normalizeDescriptorClientProviders(value) {
|
|
|
45
45
|
return Object.freeze(providers);
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
function
|
|
48
|
+
function normalizeDescriptorClientOptimizeSpecifiers(value) {
|
|
49
49
|
return Object.freeze(sortStrings(value));
|
|
50
50
|
}
|
|
51
51
|
|
|
@@ -61,15 +61,14 @@ function normalizeClientDescriptorSections(descriptorValue) {
|
|
|
61
61
|
return Object.freeze({
|
|
62
62
|
descriptorUiRoutes: normalizeDescriptorUiRoutes(ui.routes),
|
|
63
63
|
descriptorClientProviders: normalizeDescriptorClientProviders(runtimeClient.providers),
|
|
64
|
-
descriptorClientOptimizeIncludeSpecifiers:
|
|
65
|
-
|
|
66
|
-
)
|
|
64
|
+
descriptorClientOptimizeIncludeSpecifiers: normalizeDescriptorClientOptimizeSpecifiers(optimizeDeps.include),
|
|
65
|
+
descriptorClientOptimizeExcludeSpecifiers: normalizeDescriptorClientOptimizeSpecifiers(optimizeDeps.exclude)
|
|
67
66
|
});
|
|
68
67
|
}
|
|
69
68
|
|
|
70
69
|
export {
|
|
71
70
|
normalizeDescriptorUiRoutes,
|
|
72
71
|
normalizeDescriptorClientProviders,
|
|
73
|
-
|
|
72
|
+
normalizeDescriptorClientOptimizeSpecifiers,
|
|
74
73
|
normalizeClientDescriptorSections
|
|
75
74
|
};
|
|
@@ -5,7 +5,7 @@ import { normalizeObject } from "../../shared/support/normalize.js";
|
|
|
5
5
|
import { sortStrings } from "../../shared/support/sorting.js";
|
|
6
6
|
import {
|
|
7
7
|
normalizeDescriptorClientProviders,
|
|
8
|
-
|
|
8
|
+
normalizeDescriptorClientOptimizeSpecifiers,
|
|
9
9
|
normalizeDescriptorUiRoutes,
|
|
10
10
|
normalizeClientDescriptorSections
|
|
11
11
|
} from "../descriptorSections.js";
|
|
@@ -67,7 +67,8 @@ async function resolveInstalledClientModules({ appRoot, lockPath }) {
|
|
|
67
67
|
sourceType: String(installedPackageState?.source?.type || "").trim().toLowerCase(),
|
|
68
68
|
descriptorUiRoutes: descriptorSections.descriptorUiRoutes,
|
|
69
69
|
descriptorClientProviders: descriptorSections.descriptorClientProviders,
|
|
70
|
-
descriptorClientOptimizeIncludeSpecifiers: descriptorSections.descriptorClientOptimizeIncludeSpecifiers
|
|
70
|
+
descriptorClientOptimizeIncludeSpecifiers: descriptorSections.descriptorClientOptimizeIncludeSpecifiers,
|
|
71
|
+
descriptorClientOptimizeExcludeSpecifiers: descriptorSections.descriptorClientOptimizeExcludeSpecifiers
|
|
71
72
|
})
|
|
72
73
|
);
|
|
73
74
|
}
|
|
@@ -113,8 +114,11 @@ function normalizeClientModuleDescriptors(value) {
|
|
|
113
114
|
sourceType,
|
|
114
115
|
descriptorUiRoutes: normalizeDescriptorUiRoutes(record.descriptorUiRoutes),
|
|
115
116
|
descriptorClientProviders: normalizeDescriptorClientProviders(record.descriptorClientProviders),
|
|
116
|
-
descriptorClientOptimizeIncludeSpecifiers:
|
|
117
|
+
descriptorClientOptimizeIncludeSpecifiers: normalizeDescriptorClientOptimizeSpecifiers(
|
|
117
118
|
record.descriptorClientOptimizeIncludeSpecifiers
|
|
119
|
+
),
|
|
120
|
+
descriptorClientOptimizeExcludeSpecifiers: normalizeDescriptorClientOptimizeSpecifiers(
|
|
121
|
+
record.descriptorClientOptimizeExcludeSpecifiers
|
|
118
122
|
)
|
|
119
123
|
});
|
|
120
124
|
}
|
|
@@ -158,22 +162,26 @@ function resolveClientOptimizeExcludeSpecifiers(clientModules = []) {
|
|
|
158
162
|
const moduleDescriptors = normalizeClientModuleDescriptors(clientModules);
|
|
159
163
|
const localSourceTypes = new Set(["local-package", "app-local-package"]);
|
|
160
164
|
return sortStrings(
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
165
|
+
[
|
|
166
|
+
...moduleDescriptors
|
|
167
|
+
.filter((entry) => localSourceTypes.has(entry.sourceType))
|
|
168
|
+
.flatMap((entry) => [entry.packageId, `${entry.packageId}/shared`, `${entry.packageId}/client`]),
|
|
169
|
+
...moduleDescriptors.flatMap((entry) => entry.descriptorClientOptimizeExcludeSpecifiers || [])
|
|
170
|
+
]
|
|
164
171
|
);
|
|
165
172
|
}
|
|
166
173
|
|
|
167
|
-
function resolveClientOptimizeIncludeSpecifiers(clientModules = []) {
|
|
174
|
+
function resolveClientOptimizeIncludeSpecifiers(clientModules = [], excludeSpecifiers = []) {
|
|
168
175
|
const moduleDescriptors = normalizeClientModuleDescriptors(clientModules);
|
|
169
176
|
const localSourceTypes = new Set(["local-package", "app-local-package"]);
|
|
177
|
+
const excluded = new Set(sortStrings(excludeSpecifiers));
|
|
170
178
|
return sortStrings(
|
|
171
179
|
[
|
|
172
180
|
...moduleDescriptors
|
|
173
181
|
.filter((entry) => !localSourceTypes.has(entry.sourceType))
|
|
174
182
|
.map((entry) => `${entry.packageId}/client`),
|
|
175
183
|
...moduleDescriptors.flatMap((entry) => entry.descriptorClientOptimizeIncludeSpecifiers || [])
|
|
176
|
-
]
|
|
184
|
+
].filter((specifier) => !excluded.has(specifier))
|
|
177
185
|
);
|
|
178
186
|
}
|
|
179
187
|
|
|
@@ -204,12 +212,12 @@ function createJskitClientBootstrapPlugin({ lockPath = ".jskit/lock.json" } = {}
|
|
|
204
212
|
});
|
|
205
213
|
const clientExcludeSpecifiers = resolveClientOptimizeExcludeSpecifiers(clientModules);
|
|
206
214
|
const localScopeExcludeSpecifiers = resolveLocalScopeOptimizeExcludeSpecifiers(localScopePackageIds);
|
|
207
|
-
const clientIncludeSpecifiers = resolveClientOptimizeIncludeSpecifiers(clientModules);
|
|
208
215
|
const userOptimizeDeps = normalizeObject(userConfig.optimizeDeps);
|
|
209
216
|
const userExclude = sortStrings(userOptimizeDeps.exclude);
|
|
210
217
|
const userInclude = sortStrings(userOptimizeDeps.include);
|
|
211
218
|
const exclude = sortStrings([...userExclude, ...clientExcludeSpecifiers, ...localScopeExcludeSpecifiers]);
|
|
212
|
-
const
|
|
219
|
+
const clientIncludeSpecifiers = resolveClientOptimizeIncludeSpecifiers(clientModules, exclude);
|
|
220
|
+
const include = sortStrings([...userInclude, ...clientIncludeSpecifiers].filter((specifier) => !exclude.includes(specifier)));
|
|
213
221
|
const userResolve = normalizeObject(userConfig.resolve);
|
|
214
222
|
const dedupe = resolveClientRuntimeDedupeSpecifiers(userResolve);
|
|
215
223
|
|
|
@@ -82,6 +82,31 @@ test("resolveClientOptimizeExcludeSpecifiers excludes local/app-local package ro
|
|
|
82
82
|
]);
|
|
83
83
|
});
|
|
84
84
|
|
|
85
|
+
test("resolveClientOptimizeExcludeSpecifiers includes descriptor-declared excludes", () => {
|
|
86
|
+
const exclude = resolveClientOptimizeExcludeSpecifiers([
|
|
87
|
+
{
|
|
88
|
+
packageId: "@z/pkg",
|
|
89
|
+
sourceType: "packages-directory",
|
|
90
|
+
descriptorUiRoutes: [],
|
|
91
|
+
descriptorClientOptimizeExcludeSpecifiers: ["@z/pkg/client"]
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
packageId: "@a/pkg",
|
|
95
|
+
sourceType: "local-package",
|
|
96
|
+
descriptorUiRoutes: [],
|
|
97
|
+
descriptorClientOptimizeExcludeSpecifiers: ["external-problem-dep"]
|
|
98
|
+
}
|
|
99
|
+
]);
|
|
100
|
+
|
|
101
|
+
assert.deepEqual(exclude, [
|
|
102
|
+
"@a/pkg",
|
|
103
|
+
"@a/pkg/client",
|
|
104
|
+
"@a/pkg/shared",
|
|
105
|
+
"@z/pkg/client",
|
|
106
|
+
"external-problem-dep"
|
|
107
|
+
]);
|
|
108
|
+
});
|
|
109
|
+
|
|
85
110
|
test("resolveClientOptimizeIncludeSpecifiers includes only non-local package clients", () => {
|
|
86
111
|
const include = resolveClientOptimizeIncludeSpecifiers([
|
|
87
112
|
{
|
|
@@ -109,6 +134,27 @@ test("resolveClientOptimizeIncludeSpecifiers includes only non-local package cli
|
|
|
109
134
|
assert.deepEqual(include, ["@c/pkg/client", "@z/pkg/client"]);
|
|
110
135
|
});
|
|
111
136
|
|
|
137
|
+
test("resolveClientOptimizeIncludeSpecifiers omits excluded package clients", () => {
|
|
138
|
+
const include = resolveClientOptimizeIncludeSpecifiers(
|
|
139
|
+
[
|
|
140
|
+
{
|
|
141
|
+
packageId: "@z/pkg",
|
|
142
|
+
sourceType: "packages-directory",
|
|
143
|
+
descriptorUiRoutes: []
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
packageId: "@c/pkg",
|
|
147
|
+
sourceType: "npm",
|
|
148
|
+
descriptorUiRoutes: [],
|
|
149
|
+
descriptorClientOptimizeIncludeSpecifiers: ["extra-dep"]
|
|
150
|
+
}
|
|
151
|
+
],
|
|
152
|
+
["@z/pkg/client", "extra-dep"]
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
assert.deepEqual(include, ["@c/pkg/client"]);
|
|
156
|
+
});
|
|
157
|
+
|
|
112
158
|
test("resolveLocalScopeOptimizeExcludeSpecifiers expands @local package ids to root/client/shared", () => {
|
|
113
159
|
const exclude = resolveLocalScopeOptimizeExcludeSpecifiers(["@local/app", "@local/feature"]);
|
|
114
160
|
assert.deepEqual(exclude, [
|
|
@@ -410,6 +456,58 @@ test("createJskitClientBootstrapPlugin config excludes installed client package
|
|
|
410
456
|
}
|
|
411
457
|
});
|
|
412
458
|
|
|
459
|
+
test("createJskitClientBootstrapPlugin config lets descriptor excludes override automatic client includes", async () => {
|
|
460
|
+
const tempRoot = await mkdtemp(path.join(os.tmpdir(), "jskit-client-bootstrap-config-descriptor-exclude-"));
|
|
461
|
+
const previousCwd = process.cwd();
|
|
462
|
+
|
|
463
|
+
try {
|
|
464
|
+
await mkdir(path.join(tempRoot, ".jskit"), { recursive: true });
|
|
465
|
+
await writeJson(path.join(tempRoot, ".jskit", "lock.json"), {
|
|
466
|
+
lockVersion: 1,
|
|
467
|
+
installedPackages: {
|
|
468
|
+
"@example/app-bound-client": {
|
|
469
|
+
source: {
|
|
470
|
+
type: "npm"
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
});
|
|
475
|
+
|
|
476
|
+
const packageRoot = path.join(tempRoot, "node_modules", "@example", "app-bound-client");
|
|
477
|
+
await mkdir(packageRoot, { recursive: true });
|
|
478
|
+
await writeJson(path.join(packageRoot, "package.json"), {
|
|
479
|
+
name: "@example/app-bound-client",
|
|
480
|
+
exports: {
|
|
481
|
+
"./client": "./src/client/index.js"
|
|
482
|
+
}
|
|
483
|
+
});
|
|
484
|
+
await writeDescriptor(path.join(packageRoot, "package.descriptor.mjs"), {
|
|
485
|
+
metadata: {
|
|
486
|
+
client: {
|
|
487
|
+
optimizeDeps: {
|
|
488
|
+
include: ["safe-helper"],
|
|
489
|
+
exclude: ["@example/app-bound-client/client"]
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
});
|
|
494
|
+
|
|
495
|
+
process.chdir(tempRoot);
|
|
496
|
+
const plugin = createJskitClientBootstrapPlugin();
|
|
497
|
+
const result = await plugin.config({
|
|
498
|
+
optimizeDeps: {
|
|
499
|
+
include: ["@example/app-bound-client/client", "user-helper"],
|
|
500
|
+
exclude: ["user-excluded"]
|
|
501
|
+
}
|
|
502
|
+
});
|
|
503
|
+
|
|
504
|
+
assert.deepEqual(result.optimizeDeps.exclude, ["@example/app-bound-client/client", "user-excluded"]);
|
|
505
|
+
assert.deepEqual(result.optimizeDeps.include, ["safe-helper", "user-helper"]);
|
|
506
|
+
} finally {
|
|
507
|
+
process.chdir(previousCwd);
|
|
508
|
+
}
|
|
509
|
+
});
|
|
510
|
+
|
|
413
511
|
test("createJskitClientBootstrapPlugin config excludes local package roots and client/shared subpaths", async () => {
|
|
414
512
|
const tempRoot = await mkdtemp(path.join(os.tmpdir(), "jskit-client-bootstrap-config-local-"));
|
|
415
513
|
const previousCwd = process.cwd();
|