@jskit-ai/kernel 0.1.175 → 0.1.177

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.
@@ -52,15 +52,14 @@ function isPathInsideRoot(rootPath, candidatePath) {
52
52
  }
53
53
 
54
54
  /**
55
- * Generated apps intentionally preserve package symlinks, so a bare import from an editable local
56
- * package would otherwise keep its node_modules path. optimizeDeps.exclude only prevents prebundling;
57
- * Vite can still append its dependency-wide ?v hash and serve that source as one-year immutable.
58
- * That hash does not change when local source changes, which lets a browser reuse stale client code
59
- * even after Vite restarts.
55
+ * Vite's default real-path resolution keeps linked packages on editable application source. This
56
+ * table is a fallback for declared file dependencies when another resolver still returns their
57
+ * installed node_modules identity. optimizeDeps.exclude alone does not prevent Vite from appending
58
+ * a dependency version token and assigning one-year immutable browser caching.
60
59
  *
61
- * Build this table from every local package declared by the app, not only packages with a ./client export.
62
- * Resolving only the bootstrap entry is insufficient: a local client can use bare imports from another
63
- * local package's root, shared entry, or exported subpath and accidentally re-enter node_modules caching.
60
+ * Include every declared file dependency, not only packages with a client export. A local client can
61
+ * import another local package's root, shared entry, or exported subpath and accidentally re-enter
62
+ * node_modules caching.
64
63
  */
65
64
  async function resolveLocalPackageSources({ appRoot }) {
66
65
  const appPackageJson = await readJsonFile(path.resolve(appRoot, "package.json"), {});
@@ -350,6 +349,7 @@ function resolveClientRuntimeDedupeSpecifiers(userResolveConfig = {}) {
350
349
 
351
350
  function createJskitClientBootstrapPlugin({ proxyTarget = "" } = {}) {
352
351
  let appRoot = process.cwd();
352
+ let hasMutableLocalPackages = false;
353
353
  let localPackages = Object.freeze([]);
354
354
  let resolvePackageSpecifier = null;
355
355
 
@@ -371,6 +371,11 @@ function createJskitClientBootstrapPlugin({ proxyTarget = "" } = {}) {
371
371
  localPackages = await resolveLocalPackageSources({
372
372
  appRoot
373
373
  });
374
+ hasMutableLocalPackages = (
375
+ localPackages.length > 0 ||
376
+ localScopePackageIds.length > 0 ||
377
+ installedPackages.some((entry) => LOCAL_PACKAGE_SOURCE_TYPES.has(entry.sourceType))
378
+ );
374
379
  const clientExcludeSpecifiers = resolveClientOptimizeExcludeSpecifiers(clientModules);
375
380
  const localScopeExcludeSpecifiers = resolveLocalScopeOptimizeExcludeSpecifiers(localScopePackageIds);
376
381
  const userOptimizeDeps = normalizeObject(userConfig.optimizeDeps);
@@ -399,6 +404,7 @@ function createJskitClientBootstrapPlugin({ proxyTarget = "" } = {}) {
399
404
  },
400
405
  resolve: {
401
406
  ...userResolve,
407
+ ...(hasMutableLocalPackages ? { preserveSymlinks: false } : {}),
402
408
  dedupe
403
409
  },
404
410
  server: {
@@ -410,6 +416,11 @@ function createJskitClientBootstrapPlugin({ proxyTarget = "" } = {}) {
410
416
  };
411
417
  },
412
418
  configResolved(resolvedConfig) {
419
+ if (hasMutableLocalPackages && resolvedConfig.resolve?.preserveSymlinks === true) {
420
+ throw new Error(
421
+ "JSKIT mutable local packages require Vite real-path resolution. Remove resolve.preserveSymlinks: true."
422
+ );
423
+ }
413
424
  // Do not use `this.resolve()` for this lookup. That re-enters Vite's live plugin chain, where
414
425
  // the dependency optimizer can turn an unlisted local subpath into node_modules/.vite (or add
415
426
  // its dependency ?v hash) before JSKIT sees the selected file. The config resolver applies the
@@ -856,7 +856,11 @@ test("createJskitClientBootstrapPlugin config excludes local package roots and c
856
856
 
857
857
  process.chdir(tempRoot);
858
858
  const plugin = createJskitClientBootstrapPlugin();
859
- const result = await plugin.config({});
859
+ const result = await plugin.config({
860
+ resolve: {
861
+ preserveSymlinks: true
862
+ }
863
+ });
860
864
 
861
865
  assert.deepEqual(result.optimizeDeps.exclude, [
862
866
  "@example/local-client",
@@ -868,6 +872,7 @@ test("createJskitClientBootstrapPlugin config excludes local package roots and c
868
872
  "@jskit-ai/kernel/client/moduleBootstrap",
869
873
  "mime-match"
870
874
  ]);
875
+ assert.equal(result.resolve.preserveSymlinks, false);
871
876
  assert.deepEqual(result.resolve.dedupe, ["@tanstack/vue-query", "pinia", "vue", "vue-router", "vuetify"]);
872
877
  } finally {
873
878
  process.chdir(previousCwd);
@@ -951,6 +956,34 @@ test("createJskitClientBootstrapPlugin config excludes all @local scoped package
951
956
  "@example/remote-client/client",
952
957
  "@jskit-ai/kernel/client/moduleBootstrap"
953
958
  ]);
959
+ assert.equal(result.resolve.preserveSymlinks, false);
960
+ } finally {
961
+ process.chdir(previousCwd);
962
+ }
963
+ });
964
+
965
+ test("createJskitClientBootstrapPlugin rejects a later preserveSymlinks override for local packages", async () => {
966
+ const tempRoot = await mkdtemp(path.join(os.tmpdir(), "jskit-client-bootstrap-local-symlink-config-"));
967
+ const previousCwd = process.cwd();
968
+
969
+ try {
970
+ await declareInstalledPackages(tempRoot, {
971
+ "@local/main": { packagePath: "packages/main" }
972
+ });
973
+
974
+ process.chdir(tempRoot);
975
+ const plugin = createJskitClientBootstrapPlugin();
976
+ const result = await plugin.config({});
977
+
978
+ assert.equal(result.resolve.preserveSymlinks, false);
979
+ assert.throws(
980
+ () => plugin.configResolved({
981
+ resolve: {
982
+ preserveSymlinks: true
983
+ }
984
+ }),
985
+ /mutable local packages require Vite real-path resolution/u
986
+ );
954
987
  } finally {
955
988
  process.chdir(previousCwd);
956
989
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jskit-ai/kernel",
3
- "version": "0.1.175",
3
+ "version": "0.1.177",
4
4
  "type": "module",
5
5
  "dependencies": {
6
6
  "json-rest-schema": "^1.0.17"