@decocms/start 2.1.0 → 2.1.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.
- package/package.json +1 -1
- package/src/vite/plugin.js +16 -6
package/package.json
CHANGED
package/src/vite/plugin.js
CHANGED
|
@@ -122,19 +122,29 @@ export function decoVitePlugin() {
|
|
|
122
122
|
if (siteName) {
|
|
123
123
|
const envName = process.env.DECO_ENV_NAME || "dev";
|
|
124
124
|
|
|
125
|
+
// Daemon files are .ts and live inside node_modules. Node's
|
|
126
|
+
// experimental strip-types refuses to transpile node_modules, so
|
|
127
|
+
// a plain dynamic `import()` blows up under `vite dev`. Use tsx's
|
|
128
|
+
// ad-hoc loader (`tsImport`) — scoped to this import, doesn't
|
|
129
|
+
// register a global hook.
|
|
130
|
+
const loadDaemon = (specifier) =>
|
|
131
|
+
import("tsx/esm/api").then(({ tsImport }) => tsImport(specifier, import.meta.url));
|
|
132
|
+
|
|
125
133
|
// Add daemon middleware (x-daemon-api interception + auth + volumes + SSE + admin routes)
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
134
|
+
loadDaemon("../daemon/middleware.ts")
|
|
135
|
+
.then(({ createDaemonMiddleware }) => {
|
|
136
|
+
server.middlewares.use(createDaemonMiddleware({ site: siteName, server }));
|
|
137
|
+
})
|
|
138
|
+
.catch((err) => {
|
|
139
|
+
console.warn("[deco] Failed to load daemon middleware:", err.message);
|
|
140
|
+
});
|
|
131
141
|
|
|
132
142
|
// Start tunnel after HTTP server is listening (so we know the real port)
|
|
133
143
|
server.httpServer?.once("listening", async () => {
|
|
134
144
|
const addr = server.httpServer?.address();
|
|
135
145
|
const port = typeof addr === "object" && addr ? addr.port : 5173;
|
|
136
146
|
try {
|
|
137
|
-
const { startTunnel } = await
|
|
147
|
+
const { startTunnel } = await loadDaemon("../daemon/tunnel.ts");
|
|
138
148
|
const tunnel = await startTunnel({
|
|
139
149
|
site: siteName,
|
|
140
150
|
env: envName,
|