@foldkit/vite-plugin 0.26.1-canary.03baf1666c99 → 0.26.1-canary.6bd9ee8e728c

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.
@@ -1 +1 @@
1
- {"version":3,"file":"devToolsOverlay.d.ts","sourceRoot":"","sources":["../src/devToolsOverlay.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAsJlC;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,YAC7B,OAAO,GAAG,OAAO,QACpB,MAAM,KACX,OAQF,CAAA;AAED,+EAA+E;AAC/E,eAAO,MAAM,qBAAqB,QAAO,MA+DxC,CAAA"}
1
+ {"version":3,"file":"devToolsOverlay.d.ts","sourceRoot":"","sources":["../src/devToolsOverlay.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAoIlC;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,YAC7B,OAAO,GAAG,OAAO,QACpB,MAAM,KACX,OAQF,CAAA;AAED,+EAA+E;AAC/E,eAAO,MAAM,qBAAqB,QAAO,MAmExC,CAAA"}
@@ -1,26 +1,12 @@
1
- import { Array, Option, Record, Schema } from 'effect';
1
+ import { Option, Record, Schema } from 'effect';
2
2
  import { existsSync, readFileSync, realpathSync } from 'node:fs';
3
3
  import { dirname, join, resolve, sep } from 'node:path';
4
4
  const DEV_TOOLS_PACKAGE_NAME = '@foldkit/devtools';
5
- const FOLDKIT_PACKAGE_NAME = 'foldkit';
6
5
  const DEV_TOOLS_VITE_EXPORT = './vite';
7
6
  const DEV_TOOLS_OVERLAY_MODULE_ID = 'virtual:foldkit-devtools-overlay';
8
7
  const RESOLVED_DEV_TOOLS_OVERLAY_MODULE_ID = `\0${DEV_TOOLS_OVERLAY_MODULE_ID}`;
9
8
  const DEV_TOOLS_VITE_IMPORT_SPECIFIER = `${DEV_TOOLS_PACKAGE_NAME}${DEV_TOOLS_VITE_EXPORT.slice(1)}`;
10
9
  const DEV_TOOLS_HOST_IMPORT_SPECIFIER = 'foldkit/devtools-host';
11
- // NOTE: Vite's dependency scan cannot discover this virtual module's imports.
12
- // Declaring registry-installed imports before the first request avoids a
13
- // mid-session reoptimization and page reload.
14
- const DEV_TOOLS_OVERLAY_IMPORTS = [
15
- {
16
- specifier: DEV_TOOLS_VITE_IMPORT_SPECIFIER,
17
- packageName: DEV_TOOLS_PACKAGE_NAME,
18
- },
19
- {
20
- specifier: DEV_TOOLS_HOST_IMPORT_SPECIFIER,
21
- packageName: FOLDKIT_PACKAGE_NAME,
22
- },
23
- ];
24
10
  const DEV_TOOLS_OVERLAY_MODULE_SOURCE = `
25
11
  import { overlay } from '${DEV_TOOLS_VITE_IMPORT_SPECIFIER}'
26
12
  import { __setDevToolsOverlay } from '${DEV_TOOLS_HOST_IMPORT_SPECIFIER}'
@@ -79,8 +65,7 @@ const resolvePackageDirectory = Option.liftThrowable((packageJsonPath) => realpa
79
65
  // NOTE: Vite serves linked packages from source rather than pre-bundling them.
80
66
  // A registry-installed package has a real path under `node_modules`, while a
81
67
  // workspace link resolves to its source checkout; force-including a link would
82
- // cache its current source and hide edits. Each owner is checked independently
83
- // because one package may be linked while the other is installed.
68
+ // cache its current source and hide edits.
84
69
  const isPackageResolvedIntoNodeModules = (root, packageName) => findInstalledPackageJsonPath(root, packageName).pipe(Option.flatMap(resolvePackageDirectory), Option.exists(packageDirectory => packageDirectory.split(sep).includes('node_modules')));
85
70
  const isDevToolsProductionDependency = (root) => findApplicationPackageJsonPath(root).pipe(Option.flatMap(packageJsonPath => readPackageJson(decodeApplicationPackageJson, packageJsonPath)), Option.flatMapNullishOr(packageJson => packageJson.dependencies), Option.exists(Record.has(DEV_TOOLS_PACKAGE_NAME)));
86
71
  /**
@@ -111,11 +96,19 @@ export const devToolsOverlayPlugin = () => {
111
96
  !shouldInjectDevToolsOverlay(environment.command, root)) {
112
97
  return undefined;
113
98
  }
114
- const include = DEV_TOOLS_OVERLAY_IMPORTS.filter(({ packageName }) => isPackageResolvedIntoNodeModules(root, packageName)).map(({ specifier }) => specifier);
115
- return Array.match(include, {
116
- onEmpty: () => undefined,
117
- onNonEmpty: () => ({ optimizeDeps: { include } }),
118
- });
99
+ // NOTE: Vite's dependency scan cannot discover the virtual module's
100
+ // imports, so a registry-installed `@foldkit/devtools/vite` is declared
101
+ // before the first request to avoid a mid-session reoptimization and page
102
+ // reload. `foldkit/devtools-host` is deliberately not declared. The plugin
103
+ // excludes `foldkit` and serves it from source. Vite resolves a
104
+ // force-included specifier to its pre-bundle before consulting `exclude`.
105
+ // That would give the overlay its own copy of the DevTools config.
106
+ if (isPackageResolvedIntoNodeModules(root, DEV_TOOLS_PACKAGE_NAME)) {
107
+ return { optimizeDeps: { include: [DEV_TOOLS_VITE_IMPORT_SPECIFIER] } };
108
+ }
109
+ else {
110
+ return undefined;
111
+ }
119
112
  },
120
113
  configResolved: config => {
121
114
  isInjectionEnabled = shouldInjectDevToolsOverlay(config.command, config.root);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@foldkit/vite-plugin",
3
- "version": "0.26.1-canary.03baf1666c99",
3
+ "version": "0.26.1-canary.6bd9ee8e728c",
4
4
  "description": "Vite plugin for Foldkit with state-preserving live reload",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -17,7 +17,7 @@
17
17
  ],
18
18
  "peerDependencies": {
19
19
  "effect": "4.0.0",
20
- "foldkit": "0.166.0-canary.03baf1666c99",
20
+ "foldkit": "0.166.0-canary.6bd9ee8e728c",
21
21
  "vite": "^8.0.0"
22
22
  },
23
23
  "dependencies": {
@@ -38,7 +38,7 @@
38
38
  "vite": "^8.3.1",
39
39
  "vite-host": "npm:vite@8.2.1",
40
40
  "vitest": "^4.1.11",
41
- "foldkit": "0.166.0-canary.03baf1666c99"
41
+ "foldkit": "0.166.0-canary.6bd9ee8e728c"
42
42
  },
43
43
  "keywords": [
44
44
  "vite",