fimo-vite 2.0.0 → 2.0.1
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.
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export const PREVIEW_HEALTH_PATH = '/__fimo/preview-health';
|
|
2
|
+
const OPTIMIZED_DEP_PATH = '/node_modules/.vite/deps/';
|
|
3
|
+
export default function previewHealthPlugin() {
|
|
4
|
+
let failure = null;
|
|
5
|
+
return {
|
|
6
|
+
name: 'fimo:preview-health',
|
|
7
|
+
apply: 'serve',
|
|
8
|
+
configureServer(server) {
|
|
9
|
+
// This endpoint exists only in Fimo preview sandboxes. Local projects
|
|
10
|
+
// do not need a platform watchdog or an extra internal route.
|
|
11
|
+
if (!process.env.FIMO_PREVIEW_ALLOWED_ORIGINS) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
server.middlewares.use((req, res, next) => {
|
|
15
|
+
const url = new URL(req.url ?? '/', 'http://127.0.0.1');
|
|
16
|
+
if (url.pathname === PREVIEW_HEALTH_PATH) {
|
|
17
|
+
res.statusCode = 200;
|
|
18
|
+
res.setHeader('content-type', 'application/json');
|
|
19
|
+
res.end(JSON.stringify({
|
|
20
|
+
failureGeneration: failure?.generation ?? 0,
|
|
21
|
+
lastFailure: failure,
|
|
22
|
+
}));
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (url.pathname.includes(OPTIMIZED_DEP_PATH) && url.searchParams.has('v')) {
|
|
26
|
+
res.once('finish', () => {
|
|
27
|
+
if (res.statusCode >= 500) {
|
|
28
|
+
failure = {
|
|
29
|
+
generation: (failure?.generation ?? 0) + 1,
|
|
30
|
+
status: res.statusCode,
|
|
31
|
+
at: Date.now(),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
next();
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
package/dist/vite.js
CHANGED
|
@@ -3,6 +3,7 @@ import contentSyncPlugin from './plugins/content-sync.js';
|
|
|
3
3
|
import dataIdPlugin from './plugins/data-id.js';
|
|
4
4
|
import fimoConfigPlugin from './plugins/fimo-config.js';
|
|
5
5
|
import overlayPlugin from './plugins/overlay.js';
|
|
6
|
+
import previewHealthPlugin from './plugins/preview-health.js';
|
|
6
7
|
import robotsPlugin from './plugins/robots.js';
|
|
7
8
|
import seoPlugin from './plugins/seo.js';
|
|
8
9
|
import serverConfigPlugin from './plugins/server-config.js';
|
|
@@ -84,6 +85,7 @@ export function fimo(opts = {}) {
|
|
|
84
85
|
dataIdPlugin(),
|
|
85
86
|
translationsPlugin(),
|
|
86
87
|
overlayPlugin(),
|
|
88
|
+
previewHealthPlugin(),
|
|
87
89
|
];
|
|
88
90
|
if (opts.sitemap) {
|
|
89
91
|
plugins.push(sitemapPlugin());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fimo-vite",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "Framework-neutral Fimo Vite plugin. Pairs with the fimo package at the same version.",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist/",
|
|
@@ -31,15 +31,15 @@
|
|
|
31
31
|
"oxc-parser": "^0.118.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@fimo/tsconfig": "2.0.
|
|
34
|
+
"@fimo/tsconfig": "2.0.1",
|
|
35
35
|
"@types/node": "22.18.6",
|
|
36
|
-
"fimo": "2.0.
|
|
36
|
+
"fimo": "2.0.1",
|
|
37
37
|
"typescript": "7.0.2",
|
|
38
38
|
"vite": "8.2.2",
|
|
39
39
|
"vitest": "4.1.10"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"fimo": ">=2.0.
|
|
42
|
+
"fimo": ">=2.0.1",
|
|
43
43
|
"vite": "^7.0.0 || ^8.0.0"
|
|
44
44
|
},
|
|
45
45
|
"engines": {
|