bun-plugin-stx 0.2.734 → 0.2.736
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 +5 -0
- package/dist/serve.js +41 -11
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -55,6 +55,11 @@ like `componentsDir`, whether configured in `stx.config.ts` or passed to
|
|
|
55
55
|
update. These roots do not need a duplicate `watchDirs` entry. Missing roots
|
|
56
56
|
are tolerated; resolution order and app overrides are unchanged.
|
|
57
57
|
|
|
58
|
+
Page roots in `patterns` are watched as well. Removing an app override file or
|
|
59
|
+
directory re-resolves the route against the remaining roots, including the
|
|
60
|
+
fallback page's middleware. Recreating the override restores its precedence
|
|
61
|
+
without restarting the development server.
|
|
62
|
+
|
|
58
63
|
## Usage with ESM
|
|
59
64
|
|
|
60
65
|
### 1. Configure Bun to use the plugin
|
package/dist/serve.js
CHANGED
|
@@ -9791,14 +9791,21 @@ function __stxOverlay(errs){
|
|
|
9791
9791
|
currentBuildErrors = errors;
|
|
9792
9792
|
broadcastHmr({ type: "build-error", errors });
|
|
9793
9793
|
}
|
|
9794
|
-
const watchersStarted = new
|
|
9794
|
+
const watchersStarted = new Map;
|
|
9795
|
+
const clearRenderCaches = () => {
|
|
9796
|
+
htmlCache.clear();
|
|
9797
|
+
cssCssCache.clear();
|
|
9798
|
+
resolvedStxModule?.clearDevCaches?.();
|
|
9799
|
+
resolvedStxModule?.clearStoreCache?.();
|
|
9800
|
+
resolvedStxModule?.clearComposableCache?.();
|
|
9801
|
+
};
|
|
9795
9802
|
const startWatcher = (dir) => {
|
|
9796
9803
|
if (production)
|
|
9797
9804
|
return;
|
|
9798
9805
|
if (watchersStarted.has(dir))
|
|
9799
9806
|
return;
|
|
9800
9807
|
try {
|
|
9801
|
-
const watcher = fsWatch(dir, { recursive: true }, (
|
|
9808
|
+
const watcher = fsWatch(dir, { recursive: true }, (event, filename) => {
|
|
9802
9809
|
if (!filename)
|
|
9803
9810
|
return;
|
|
9804
9811
|
const f = String(filename);
|
|
@@ -9807,16 +9814,13 @@ function __stxOverlay(errs){
|
|
|
9807
9814
|
const isData = f.endsWith(".json");
|
|
9808
9815
|
const isCss = f.endsWith(".css");
|
|
9809
9816
|
const isAsset = isCss || isCode || f.endsWith(".jpg") || f.endsWith(".jpeg") || f.endsWith(".png") || f.endsWith(".gif") || f.endsWith(".svg") || f.endsWith(".webp") || f.endsWith(".avif") || f.endsWith(".woff") || f.endsWith(".woff2") || f.endsWith(".ttf") || f.endsWith(".otf");
|
|
9810
|
-
|
|
9817
|
+
const topologyChanged = event === "rename";
|
|
9818
|
+
if (!isStxLike && !isAsset && !isData && !topologyChanged)
|
|
9811
9819
|
return;
|
|
9812
|
-
if (isStxLike || isCode || isData) {
|
|
9813
|
-
if (isStxLike)
|
|
9820
|
+
if (isStxLike || isCode || isData || topologyChanged) {
|
|
9821
|
+
if (isStxLike || topologyChanged)
|
|
9814
9822
|
sourceFiles = null;
|
|
9815
|
-
|
|
9816
|
-
cssCssCache.clear();
|
|
9817
|
-
resolvedStxModule?.clearDevCaches?.();
|
|
9818
|
-
resolvedStxModule?.clearStoreCache?.();
|
|
9819
|
-
resolvedStxModule?.clearComposableCache?.();
|
|
9823
|
+
clearRenderCaches();
|
|
9820
9824
|
if (layoutsDir && f.endsWith(".stx") && nodePath.resolve(f).startsWith(nodePath.resolve(layoutsDir)))
|
|
9821
9825
|
writeLayoutTypes();
|
|
9822
9826
|
}
|
|
@@ -9833,7 +9837,30 @@ function __stxOverlay(errs){
|
|
|
9833
9837
|
broadcastHmr({ type: "reload", file: f });
|
|
9834
9838
|
});
|
|
9835
9839
|
watcher.on("error", () => {});
|
|
9836
|
-
watchersStarted.
|
|
9840
|
+
watchersStarted.set(dir, watcher);
|
|
9841
|
+
} catch {}
|
|
9842
|
+
};
|
|
9843
|
+
const pageRootWatchersStarted = new Set;
|
|
9844
|
+
const watchPageRoot = (dir) => {
|
|
9845
|
+
if (production || pageRootWatchersStarted.has(dir))
|
|
9846
|
+
return;
|
|
9847
|
+
const absolute = nodePath.resolve(dir);
|
|
9848
|
+
const parent = nodePath.dirname(absolute);
|
|
9849
|
+
if (parent === absolute)
|
|
9850
|
+
return;
|
|
9851
|
+
try {
|
|
9852
|
+
const watcher = fsWatch(parent, { recursive: false }, (event, filename) => {
|
|
9853
|
+
if (event !== "rename" || String(filename) !== nodePath.basename(absolute))
|
|
9854
|
+
return;
|
|
9855
|
+
watchersStarted.get(dir)?.close();
|
|
9856
|
+
watchersStarted.delete(dir);
|
|
9857
|
+
startWatcher(dir);
|
|
9858
|
+
sourceFiles = null;
|
|
9859
|
+
clearRenderCaches();
|
|
9860
|
+
broadcastHmr({ type: "reload", file: dir });
|
|
9861
|
+
});
|
|
9862
|
+
watcher.on("error", () => {});
|
|
9863
|
+
pageRootWatchersStarted.add(dir);
|
|
9837
9864
|
} catch {}
|
|
9838
9865
|
};
|
|
9839
9866
|
const writeLayoutTypes = async () => {
|
|
@@ -10138,6 +10165,8 @@ function __stxOverlay(errs){
|
|
|
10138
10165
|
for (const pattern of patterns) {
|
|
10139
10166
|
try {
|
|
10140
10167
|
const stat = await nodeFs.stat(pattern).catch(() => null);
|
|
10168
|
+
if (stat?.isDirectory() || !stat && !pattern.includes("*") && !supportedExtensions.some((ext) => pattern.endsWith(ext)))
|
|
10169
|
+
watchPageRoot(pattern);
|
|
10141
10170
|
if (stat?.isDirectory()) {
|
|
10142
10171
|
startWatcher(pattern);
|
|
10143
10172
|
const excludeDirs = ["layouts", "components", "partials"];
|
|
@@ -11140,6 +11169,7 @@ ${block}`;
|
|
|
11140
11169
|
if (hookResult && typeof hookResult === "object")
|
|
11141
11170
|
Object.assign(reqCtx, hookResult);
|
|
11142
11171
|
}
|
|
11172
|
+
await discoverFiles();
|
|
11143
11173
|
const route = resolveRouteMiddleware(path);
|
|
11144
11174
|
const extraNames = extraProtectedPrefixes.some((p) => path === p || path.startsWith(p.endsWith("/") ? p : `${p}/`)) ? ["auth"] : [];
|
|
11145
11175
|
const requested = [...globalMiddlewareNames, ...route.names, ...extraNames];
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bun-plugin-stx",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.736",
|
|
5
5
|
"description": "A Bun plugin that allows for using Laravel Blade-like syntax.",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.org>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"typecheck": "bun tsc --noEmit"
|
|
75
75
|
},
|
|
76
76
|
"dependencies": {
|
|
77
|
-
"@stacksjs/stx": "0.2.
|
|
78
|
-
"stx-router": "0.2.
|
|
77
|
+
"@stacksjs/stx": "0.2.736",
|
|
78
|
+
"stx-router": "0.2.736"
|
|
79
79
|
}
|
|
80
80
|
}
|