@foldkit/vite-plugin 0.26.1-canary.6bd9ee8e728c → 0.26.1-canary.8c70ed904b29
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/dist/devToolsOverlay.d.ts.map +1 -1
- package/dist/devToolsOverlay.js +22 -15
- package/package.json +3 -3
|
@@ -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;
|
|
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"}
|
package/dist/devToolsOverlay.js
CHANGED
|
@@ -1,12 +1,26 @@
|
|
|
1
|
-
import { Option, Record, Schema } from 'effect';
|
|
1
|
+
import { Array, 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';
|
|
5
6
|
const DEV_TOOLS_VITE_EXPORT = './vite';
|
|
6
7
|
const DEV_TOOLS_OVERLAY_MODULE_ID = 'virtual:foldkit-devtools-overlay';
|
|
7
8
|
const RESOLVED_DEV_TOOLS_OVERLAY_MODULE_ID = `\0${DEV_TOOLS_OVERLAY_MODULE_ID}`;
|
|
8
9
|
const DEV_TOOLS_VITE_IMPORT_SPECIFIER = `${DEV_TOOLS_PACKAGE_NAME}${DEV_TOOLS_VITE_EXPORT.slice(1)}`;
|
|
9
10
|
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
|
+
];
|
|
10
24
|
const DEV_TOOLS_OVERLAY_MODULE_SOURCE = `
|
|
11
25
|
import { overlay } from '${DEV_TOOLS_VITE_IMPORT_SPECIFIER}'
|
|
12
26
|
import { __setDevToolsOverlay } from '${DEV_TOOLS_HOST_IMPORT_SPECIFIER}'
|
|
@@ -65,7 +79,8 @@ const resolvePackageDirectory = Option.liftThrowable((packageJsonPath) => realpa
|
|
|
65
79
|
// NOTE: Vite serves linked packages from source rather than pre-bundling them.
|
|
66
80
|
// A registry-installed package has a real path under `node_modules`, while a
|
|
67
81
|
// workspace link resolves to its source checkout; force-including a link would
|
|
68
|
-
// cache its current source and hide edits.
|
|
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.
|
|
69
84
|
const isPackageResolvedIntoNodeModules = (root, packageName) => findInstalledPackageJsonPath(root, packageName).pipe(Option.flatMap(resolvePackageDirectory), Option.exists(packageDirectory => packageDirectory.split(sep).includes('node_modules')));
|
|
70
85
|
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)));
|
|
71
86
|
/**
|
|
@@ -96,19 +111,11 @@ export const devToolsOverlayPlugin = () => {
|
|
|
96
111
|
!shouldInjectDevToolsOverlay(environment.command, root)) {
|
|
97
112
|
return undefined;
|
|
98
113
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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
|
-
}
|
|
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
|
+
});
|
|
112
119
|
},
|
|
113
120
|
configResolved: config => {
|
|
114
121
|
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.
|
|
3
|
+
"version": "0.26.1-canary.8c70ed904b29",
|
|
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.
|
|
20
|
+
"foldkit": "0.166.0-canary.8c70ed904b29",
|
|
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.
|
|
41
|
+
"foldkit": "0.166.0-canary.8c70ed904b29"
|
|
42
42
|
},
|
|
43
43
|
"keywords": [
|
|
44
44
|
"vite",
|