vike 0.4.234 → 0.4.235
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/cjs/node/vite/plugins/pluginVirtualFiles.js +30 -25
- package/dist/cjs/utils/PROJECT_VERSION.js +1 -1
- package/dist/esm/node/vite/plugins/pluginVirtualFiles.js +30 -25
- package/dist/esm/utils/PROJECT_VERSION.d.ts +1 -1
- package/dist/esm/utils/PROJECT_VERSION.js +1 -1
- package/package.json +1 -1
|
@@ -73,28 +73,33 @@ function handleFileAddRemove(server, config) {
|
|
|
73
73
|
if ((0, transpileAndExecuteFile_js_1.isTemporaryBuildFile)(file))
|
|
74
74
|
return;
|
|
75
75
|
const { moduleGraph } = server;
|
|
76
|
-
const
|
|
76
|
+
const isVikeConfigDep = await isVikeConfigDependency(file, moduleGraph);
|
|
77
77
|
const reload = () => reloadConfig(file, config, isRemove ? 'removed' : 'created', server);
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
else {
|
|
83
|
-
// Let Vite handle it
|
|
84
|
-
(0, utils_js_1.assert)(existsInViteModuleGraph(file, moduleGraph));
|
|
85
|
-
}
|
|
78
|
+
// Config code
|
|
79
|
+
if (isVikeConfigDep && !isVikeConfigDep.isProcessedByVite) {
|
|
80
|
+
reload();
|
|
81
|
+
return;
|
|
86
82
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
83
|
+
// New or deleted + file
|
|
84
|
+
if ((0, crawlPlusFiles_js_1.isPlusFile)(file)) {
|
|
85
|
+
reload();
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
// Runtime code => let Vite handle it
|
|
89
|
+
if (isVikeConfigDep && isVikeConfigDep.isProcessedByVite) {
|
|
90
|
+
(0, utils_js_1.assert)(existsInViteModuleGraph(file, moduleGraph));
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
// Trick: when importing a file that doesn't exist => we don't know whether `file` is that missing file => we take a leap of faith when the conditions below are met.
|
|
94
|
+
// - Not sure how reliable that trick is.
|
|
95
|
+
// - Reloading Vike's config is cheap and file creation/removal is rare => the trick is worth it.
|
|
96
|
+
// - Reproduction:
|
|
97
|
+
// ```bash
|
|
98
|
+
// rm someDep.js && sleep 2 && git checkout someDep.js
|
|
99
|
+
// ```
|
|
100
|
+
if ((0, utils_js_1.isScriptFile)(file) && (0, getVikeConfigError_js_1.getVikeConfigError)() && !existsInViteModuleGraph(file, moduleGraph)) {
|
|
101
|
+
reload();
|
|
102
|
+
return;
|
|
98
103
|
}
|
|
99
104
|
}
|
|
100
105
|
}
|
|
@@ -107,9 +112,9 @@ function invalidateVikeVirtualFiles(server) {
|
|
|
107
112
|
// Vite calls its hook handleHotUpdate() whenever *any file* is modified — including files that aren't in Vite's module graph such as `pages/+config.js`
|
|
108
113
|
async function handleHotUpdate(ctx, config) {
|
|
109
114
|
const { file, server } = ctx;
|
|
110
|
-
const
|
|
111
|
-
if (
|
|
112
|
-
if (
|
|
115
|
+
const isVikeConfigDep = await isVikeConfigDependency(ctx.file, ctx.server.moduleGraph);
|
|
116
|
+
if (isVikeConfigDep) {
|
|
117
|
+
if (!isVikeConfigDep.isProcessedByVite) {
|
|
113
118
|
/* Tailwind breaks this assertion, see https://github.com/vikejs/vike/discussions/1330#discussioncomment-7787238
|
|
114
119
|
const isViteModule = ctx.modules.length > 0
|
|
115
120
|
assert(!isViteModule)
|
|
@@ -139,7 +144,7 @@ async function isVikeConfigDependency(filePathAbsoluteFilesystem, moduleGraph) {
|
|
|
139
144
|
const { _vikeConfigDependencies: vikeConfigDependencies } = vikeConfigObject;
|
|
140
145
|
vikeConfigDependencies.forEach((f) => (0, utils_js_1.assertPosixPath)(f));
|
|
141
146
|
if (vikeConfigDependencies.has(filePathAbsoluteFilesystem))
|
|
142
|
-
return {
|
|
147
|
+
return { isProcessedByVite: false };
|
|
143
148
|
}
|
|
144
149
|
// Runtime Vike config files such as +data.js which are processed by Vite.
|
|
145
150
|
// - They're included in Vite's module graph.
|
|
@@ -148,7 +153,7 @@ async function isVikeConfigDependency(filePathAbsoluteFilesystem, moduleGraph) {
|
|
|
148
153
|
const importers = getImporters(filePathAbsoluteFilesystem, moduleGraph);
|
|
149
154
|
const isPlusValueFileDependency = Array.from(importers).some((importer) => importer.file && (0, crawlPlusFiles_js_1.isPlusFile)(importer.file));
|
|
150
155
|
if (isPlusValueFileDependency)
|
|
151
|
-
return {
|
|
156
|
+
return { isProcessedByVite: true };
|
|
152
157
|
return null;
|
|
153
158
|
}
|
|
154
159
|
function reloadConfig(filePath, config, op, server) {
|
|
@@ -68,28 +68,33 @@ function handleFileAddRemove(server, config) {
|
|
|
68
68
|
if (isTemporaryBuildFile(file))
|
|
69
69
|
return;
|
|
70
70
|
const { moduleGraph } = server;
|
|
71
|
-
const
|
|
71
|
+
const isVikeConfigDep = await isVikeConfigDependency(file, moduleGraph);
|
|
72
72
|
const reload = () => reloadConfig(file, config, isRemove ? 'removed' : 'created', server);
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
else {
|
|
78
|
-
// Let Vite handle it
|
|
79
|
-
assert(existsInViteModuleGraph(file, moduleGraph));
|
|
80
|
-
}
|
|
73
|
+
// Config code
|
|
74
|
+
if (isVikeConfigDep && !isVikeConfigDep.isProcessedByVite) {
|
|
75
|
+
reload();
|
|
76
|
+
return;
|
|
81
77
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
78
|
+
// New or deleted + file
|
|
79
|
+
if (isPlusFile(file)) {
|
|
80
|
+
reload();
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
// Runtime code => let Vite handle it
|
|
84
|
+
if (isVikeConfigDep && isVikeConfigDep.isProcessedByVite) {
|
|
85
|
+
assert(existsInViteModuleGraph(file, moduleGraph));
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
// Trick: when importing a file that doesn't exist => we don't know whether `file` is that missing file => we take a leap of faith when the conditions below are met.
|
|
89
|
+
// - Not sure how reliable that trick is.
|
|
90
|
+
// - Reloading Vike's config is cheap and file creation/removal is rare => the trick is worth it.
|
|
91
|
+
// - Reproduction:
|
|
92
|
+
// ```bash
|
|
93
|
+
// rm someDep.js && sleep 2 && git checkout someDep.js
|
|
94
|
+
// ```
|
|
95
|
+
if (isScriptFile(file) && getVikeConfigError() && !existsInViteModuleGraph(file, moduleGraph)) {
|
|
96
|
+
reload();
|
|
97
|
+
return;
|
|
93
98
|
}
|
|
94
99
|
}
|
|
95
100
|
}
|
|
@@ -102,9 +107,9 @@ function invalidateVikeVirtualFiles(server) {
|
|
|
102
107
|
// Vite calls its hook handleHotUpdate() whenever *any file* is modified — including files that aren't in Vite's module graph such as `pages/+config.js`
|
|
103
108
|
async function handleHotUpdate(ctx, config) {
|
|
104
109
|
const { file, server } = ctx;
|
|
105
|
-
const
|
|
106
|
-
if (
|
|
107
|
-
if (
|
|
110
|
+
const isVikeConfigDep = await isVikeConfigDependency(ctx.file, ctx.server.moduleGraph);
|
|
111
|
+
if (isVikeConfigDep) {
|
|
112
|
+
if (!isVikeConfigDep.isProcessedByVite) {
|
|
108
113
|
/* Tailwind breaks this assertion, see https://github.com/vikejs/vike/discussions/1330#discussioncomment-7787238
|
|
109
114
|
const isViteModule = ctx.modules.length > 0
|
|
110
115
|
assert(!isViteModule)
|
|
@@ -134,7 +139,7 @@ async function isVikeConfigDependency(filePathAbsoluteFilesystem, moduleGraph) {
|
|
|
134
139
|
const { _vikeConfigDependencies: vikeConfigDependencies } = vikeConfigObject;
|
|
135
140
|
vikeConfigDependencies.forEach((f) => assertPosixPath(f));
|
|
136
141
|
if (vikeConfigDependencies.has(filePathAbsoluteFilesystem))
|
|
137
|
-
return {
|
|
142
|
+
return { isProcessedByVite: false };
|
|
138
143
|
}
|
|
139
144
|
// Runtime Vike config files such as +data.js which are processed by Vite.
|
|
140
145
|
// - They're included in Vite's module graph.
|
|
@@ -143,7 +148,7 @@ async function isVikeConfigDependency(filePathAbsoluteFilesystem, moduleGraph) {
|
|
|
143
148
|
const importers = getImporters(filePathAbsoluteFilesystem, moduleGraph);
|
|
144
149
|
const isPlusValueFileDependency = Array.from(importers).some((importer) => importer.file && isPlusFile(importer.file));
|
|
145
150
|
if (isPlusValueFileDependency)
|
|
146
|
-
return {
|
|
151
|
+
return { isProcessedByVite: true };
|
|
147
152
|
return null;
|
|
148
153
|
}
|
|
149
154
|
function reloadConfig(filePath, config, op, server) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const PROJECT_VERSION: "0.4.
|
|
1
|
+
export declare const PROJECT_VERSION: "0.4.235";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Automatically updated by @brillout/release-me
|
|
2
|
-
export const PROJECT_VERSION = '0.4.
|
|
2
|
+
export const PROJECT_VERSION = '0.4.235';
|