evolit 0.3.0 → 0.4.0
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/README.md +62 -0
- package/package.json +7 -1
- package/src/build.js +65 -10
- package/src/client-assets.js +1 -0
- package/src/compiler.js +53 -11
- package/src/deployment-runtime.js +60 -6
- package/src/index.js +3 -0
- package/src/litsx-pipeline.d.ts +137 -0
- package/src/litsx-pipeline.js +705 -0
- package/src/render.js +1 -0
- package/src/server-setup.js +2 -1
- package/src/server.js +40 -1
package/src/render.js
CHANGED
|
@@ -147,6 +147,7 @@ function createRouteModuleOptions(projectRoot, mode, options = {}) {
|
|
|
147
147
|
staticAssetPublicUrls: resolvedStaticAssetPublicUrls,
|
|
148
148
|
onDevelopmentEvent: options.onDevelopmentEvent,
|
|
149
149
|
managedSourceRoots: options.managedSourceRoots,
|
|
150
|
+
litsxPipeline: options.litsxPipeline,
|
|
150
151
|
};
|
|
151
152
|
}
|
|
152
153
|
|
package/src/server-setup.js
CHANGED
|
@@ -21,7 +21,7 @@ function normalizeCleanup(result) {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
/** Runs the application server bootstrap once for a build or runtime instance. */
|
|
24
|
-
export async function runServerSetup({ projectRoot, mode, evolitConfig = {} }) {
|
|
24
|
+
export async function runServerSetup({ projectRoot, mode, evolitConfig = {}, litsxPipeline = null }) {
|
|
25
25
|
const serverConfig = evolitConfig.server;
|
|
26
26
|
if (serverConfig == null) return null;
|
|
27
27
|
if (!serverConfig || typeof serverConfig !== "object" || Array.isArray(serverConfig)) {
|
|
@@ -49,6 +49,7 @@ export async function runServerSetup({ projectRoot, mode, evolitConfig = {} }) {
|
|
|
49
49
|
mode,
|
|
50
50
|
sourceMaps: mode === "development",
|
|
51
51
|
target: "server",
|
|
52
|
+
litsxPipeline,
|
|
52
53
|
});
|
|
53
54
|
setup = resolveSetupExport(moduleRecord, configuredSetup);
|
|
54
55
|
}
|
package/src/server.js
CHANGED
|
@@ -268,6 +268,7 @@ async function createServer(projectRoot, mode, explicitPort, options = {}) {
|
|
|
268
268
|
const response = await deploymentRuntime.handle(
|
|
269
269
|
createDevelopmentNavigationRequest(subscription, origin),
|
|
270
270
|
);
|
|
271
|
+
syncLitsxDependencyWatchers();
|
|
271
272
|
const navigationResponse = createNavigationResponseFromDocument(response);
|
|
272
273
|
if (!getResponseHeader(navigationResponse.headers, "content-type")
|
|
273
274
|
?.includes("application/vnd.evolit.navigation+json")) return null;
|
|
@@ -342,6 +343,39 @@ async function createServer(projectRoot, mode, explicitPort, options = {}) {
|
|
|
342
343
|
{ shouldIgnorePath: createSourceWatchIgnorePath(sourceRoot) },
|
|
343
344
|
)))
|
|
344
345
|
: [];
|
|
346
|
+
const litsxDependencyWatchers = new Map();
|
|
347
|
+
|
|
348
|
+
function syncLitsxDependencyWatchers() {
|
|
349
|
+
if (mode !== "development") return;
|
|
350
|
+
const activeDependencies = new Set(
|
|
351
|
+
(deploymentRuntime.litsxDependencies ?? []).map((dependency) => path.resolve(dependency)),
|
|
352
|
+
);
|
|
353
|
+
for (const [dependency, watcher] of litsxDependencyWatchers) {
|
|
354
|
+
if (activeDependencies.has(dependency)) continue;
|
|
355
|
+
watcher.close();
|
|
356
|
+
litsxDependencyWatchers.delete(dependency);
|
|
357
|
+
}
|
|
358
|
+
for (const resolvedDependency of activeDependencies) {
|
|
359
|
+
const relativePath = path.relative(projectRoot, resolvedDependency);
|
|
360
|
+
if (relativePath.split(path.sep).includes(INTERNAL_DIRECTORY)) continue;
|
|
361
|
+
const isAlreadyManaged = managedSourceRoots.some((sourceRoot) => {
|
|
362
|
+
const managedRelativePath = path.relative(sourceRoot, resolvedDependency);
|
|
363
|
+
return managedRelativePath === ""
|
|
364
|
+
|| (managedRelativePath !== ".."
|
|
365
|
+
&& !managedRelativePath.startsWith(`..${path.sep}`)
|
|
366
|
+
&& !path.isAbsolute(managedRelativePath));
|
|
367
|
+
});
|
|
368
|
+
if (isAlreadyManaged) continue;
|
|
369
|
+
if (litsxDependencyWatchers.has(resolvedDependency)) continue;
|
|
370
|
+
try {
|
|
371
|
+
const watcher = watch(resolvedDependency, () => scheduleDevelopmentInvalidation(resolvedDependency));
|
|
372
|
+
watcher.on("error", () => {});
|
|
373
|
+
litsxDependencyWatchers.set(resolvedDependency, watcher);
|
|
374
|
+
} catch (error) {
|
|
375
|
+
if (error?.code !== "ENOENT") throw error;
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
}
|
|
345
379
|
|
|
346
380
|
const server = http.createServer(async (req, res) => {
|
|
347
381
|
try {
|
|
@@ -357,6 +391,7 @@ async function createServer(projectRoot, mode, explicitPort, options = {}) {
|
|
|
357
391
|
});
|
|
358
392
|
const requestStartedAt = performance.now();
|
|
359
393
|
const response = await deploymentRuntime.handle(request);
|
|
394
|
+
syncLitsxDependencyWatchers();
|
|
360
395
|
const navigationResponse = String(req.headers.accept ?? "").includes("application/vnd.evolit.navigation+json")
|
|
361
396
|
? createNavigationResponseFromDocument(response)
|
|
362
397
|
: response;
|
|
@@ -385,7 +420,9 @@ async function createServer(projectRoot, mode, explicitPort, options = {}) {
|
|
|
385
420
|
error,
|
|
386
421
|
});
|
|
387
422
|
res.writeHead(500, { "content-type": "text/plain; charset=utf-8" });
|
|
388
|
-
res.end(
|
|
423
|
+
res.end(mode === "development"
|
|
424
|
+
? error instanceof Error ? error.stack ?? error.message : String(error)
|
|
425
|
+
: "Internal Server Error");
|
|
389
426
|
}
|
|
390
427
|
});
|
|
391
428
|
|
|
@@ -417,6 +454,8 @@ async function createServer(projectRoot, mode, explicitPort, options = {}) {
|
|
|
417
454
|
clearTimeout(invalidationTimer);
|
|
418
455
|
}
|
|
419
456
|
for (const watcher of watchers) watcher.close();
|
|
457
|
+
for (const watcher of litsxDependencyWatchers.values()) watcher.close();
|
|
458
|
+
litsxDependencyWatchers.clear();
|
|
420
459
|
for (const socket of liveReloadSockets.keys()) {
|
|
421
460
|
socket.close();
|
|
422
461
|
}
|