@pracht/vite-plugin 0.7.3 → 0.7.4
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/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { i as scanPagesDirectory, n as generatePagesManifestSource, o as createRouteLoaderHints } from "./pages-router-
|
|
1
|
+
import { i as scanPagesDirectory, n as generatePagesManifestSource, o as createRouteLoaderHints } from "./pages-router-CStJY2Zp.mjs";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import { preactSsrPrecompile } from "@pracht/preact-ssr-precompile";
|
|
4
4
|
import preact from "@preact/preset-vite";
|
|
5
|
+
import { existsSync, readFileSync, readdirSync, realpathSync, statSync } from "node:fs";
|
|
5
6
|
import { dirname, extname, join, resolve } from "node:path";
|
|
6
7
|
import { loadEnv, parseAst } from "vite";
|
|
7
|
-
import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
|
|
8
8
|
import { CAPABILITY_SETTLED_EVENT, CAPABILITY_TRANSPORT_HEADER, CONFIRMATION_HEADER } from "@pracht/capabilities";
|
|
9
9
|
import { extractCapabilityProjection, extractCapabilityRegistrations } from "@pracht/capabilities/static";
|
|
10
10
|
import { createNodeServerEntryModule } from "@pracht/adapter-node";
|
|
@@ -1221,17 +1221,19 @@ function createEnvSafetyPlugin(envSafety) {
|
|
|
1221
1221
|
//#endregion
|
|
1222
1222
|
//#region src/hot-update-reload.ts
|
|
1223
1223
|
/**
|
|
1224
|
-
* True when `file` participates in server rendering but has no
|
|
1225
|
-
* the client module graph, meaning client HMR can never deliver
|
|
1224
|
+
* True when `file` participates in server rendering but has no runtime
|
|
1225
|
+
* counterpart in the client module graph, meaning client HMR can never deliver
|
|
1226
|
+
* its change. File-only asset entries created by content scanners are watchers,
|
|
1227
|
+
* not browser modules, so they do not make an update client-reachable.
|
|
1226
1228
|
*/
|
|
1227
1229
|
function isServerOnlyModuleFile(server, file) {
|
|
1228
1230
|
const environments = server.environments;
|
|
1229
1231
|
const client = environments?.client;
|
|
1230
1232
|
if (!client) return false;
|
|
1231
|
-
if (
|
|
1233
|
+
if (hasRuntimeModules(client, file)) return false;
|
|
1232
1234
|
for (const [name, environment] of Object.entries(environments ?? {})) {
|
|
1233
1235
|
if (name === "client" || !environment) continue;
|
|
1234
|
-
if (
|
|
1236
|
+
if (hasRuntimeModules(environment, file)) return true;
|
|
1235
1237
|
}
|
|
1236
1238
|
return false;
|
|
1237
1239
|
}
|
|
@@ -1241,8 +1243,9 @@ function sendServerOnlyFullReload(server, file) {
|
|
|
1241
1243
|
server.environments?.client?.hot?.send({ type: "full-reload" });
|
|
1242
1244
|
return true;
|
|
1243
1245
|
}
|
|
1244
|
-
function
|
|
1245
|
-
|
|
1246
|
+
function hasRuntimeModules(environment, file) {
|
|
1247
|
+
for (const module of environment.moduleGraph.getModulesByFile(file) ?? []) if (module.type !== "asset") return true;
|
|
1248
|
+
return false;
|
|
1246
1249
|
}
|
|
1247
1250
|
//#endregion
|
|
1248
1251
|
//#region src/plugin-assets.ts
|
|
@@ -2523,7 +2526,7 @@ function pracht(options = {}) {
|
|
|
2523
2526
|
root = config.root;
|
|
2524
2527
|
isBuild = config.command === "build";
|
|
2525
2528
|
routeFileDirs = computeRouteFileDirs(root, resolved);
|
|
2526
|
-
capabilityModulePaths = new Set(resolveCapabilityModulePaths(resolved, root).map(
|
|
2529
|
+
capabilityModulePaths = new Set(resolveCapabilityModulePaths(resolved, root).map(canonicalFilePath));
|
|
2527
2530
|
},
|
|
2528
2531
|
resolveId(id, importer, resolveIdOptions) {
|
|
2529
2532
|
if (isIslandsClientModule(id)) return PRACHT_ISLANDS_CLIENT_MODULE_ID;
|
|
@@ -2548,8 +2551,8 @@ function pracht(options = {}) {
|
|
|
2548
2551
|
return null;
|
|
2549
2552
|
},
|
|
2550
2553
|
transform(code, id) {
|
|
2551
|
-
const appFileAbs = resolveConfigPath(root, resolved.appFile);
|
|
2552
|
-
if (
|
|
2554
|
+
const appFileAbs = canonicalFilePath(resolveConfigPath(root, resolved.appFile));
|
|
2555
|
+
if (canonicalFilePath(id.split("?")[0]) !== appFileAbs) return null;
|
|
2553
2556
|
const transformed = rewriteManifestCoreImports(code.replace(/\(\)\s*=>\s*import\(\s*(['"])([^'"]+)\1\s*\)/g, "$1$2$1"));
|
|
2554
2557
|
if (transformed === code) return null;
|
|
2555
2558
|
return {
|
|
@@ -2760,7 +2763,7 @@ const ROUTE_FILE_EXTENSIONS = new Set([
|
|
|
2760
2763
|
".tsrx"
|
|
2761
2764
|
]);
|
|
2762
2765
|
function computeRouteFileDirs(root, resolved) {
|
|
2763
|
-
return (resolved.pagesDir ? [resolved.pagesDir] : [resolved.routesDir, resolved.shellsDir]).map((dir) => resolveConfigPath(root, dir)).map(withTrailingSep);
|
|
2766
|
+
return (resolved.pagesDir ? [resolved.pagesDir] : [resolved.routesDir, resolved.shellsDir]).map((dir) => canonicalFilePath(resolveConfigPath(root, dir))).map(withTrailingSep);
|
|
2764
2767
|
}
|
|
2765
2768
|
/**
|
|
2766
2769
|
* Whether `id` is one of the capability modules the manifest registers.
|
|
@@ -2774,7 +2777,20 @@ function isCapabilityModule(id, capabilityModulePaths) {
|
|
|
2774
2777
|
const queryStart = id.indexOf("?");
|
|
2775
2778
|
const path = queryStart === -1 ? id : id.slice(0, queryStart);
|
|
2776
2779
|
if (path.startsWith("\0") || path.startsWith("virtual:")) return false;
|
|
2777
|
-
return capabilityModulePaths.has(
|
|
2780
|
+
return capabilityModulePaths.has(canonicalFilePath(path));
|
|
2781
|
+
}
|
|
2782
|
+
/**
|
|
2783
|
+
* Match Vite's canonical module ids even when the manifest path crosses a
|
|
2784
|
+
* symlink (including macOS' /var -> /private/var alias). Missing paths keep
|
|
2785
|
+
* their lexical identity so the projection code can raise its precise missing
|
|
2786
|
+
* capability error later.
|
|
2787
|
+
*/
|
|
2788
|
+
function canonicalFilePath(path) {
|
|
2789
|
+
try {
|
|
2790
|
+
return toPosixPath(realpathSync.native(path));
|
|
2791
|
+
} catch {
|
|
2792
|
+
return toPosixPath(path);
|
|
2793
|
+
}
|
|
2778
2794
|
}
|
|
2779
2795
|
function isRouteOrShellFile(id, dirs) {
|
|
2780
2796
|
if (dirs.length === 0) return false;
|
package/dist/pages-router.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as sortRoutes, i as scanPagesDirectory, n as generatePagesManifestSource, r as generateRoutesFile, t as filePathToRoutePath } from "./pages-router-
|
|
1
|
+
import { a as sortRoutes, i as scanPagesDirectory, n as generatePagesManifestSource, r as generateRoutesFile, t as filePathToRoutePath } from "./pages-router-CStJY2Zp.mjs";
|
|
2
2
|
export { filePathToRoutePath, generatePagesManifestSource, generateRoutesFile, scanPagesDirectory, sortRoutes };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pracht/vite-plugin",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.4",
|
|
4
4
|
"description": "Vite plugin for Pracht apps with virtual modules, dev SSR, prerendering, route inspection, and multi-adapter builds.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pracht",
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@preact/preset-vite": "^2.10.5",
|
|
46
46
|
"@prefresh/vite": "^2.0.0",
|
|
47
|
-
"@pracht/adapter-node": "0.3.6",
|
|
48
|
-
"@pracht/capabilities": "0.1.1",
|
|
49
47
|
"@pracht/core": "0.11.3",
|
|
50
|
-
"@pracht/
|
|
48
|
+
"@pracht/adapter-node": "0.3.6",
|
|
49
|
+
"@pracht/preact-ssr-precompile": "0.1.2",
|
|
50
|
+
"@pracht/capabilities": "0.1.1"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"vite": "^8.0.0"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { basename, extname, join, relative } from "node:path";
|
|
2
1
|
import { readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { basename, extname, join, relative } from "node:path";
|
|
3
3
|
//#region src/route-loader-hints.ts
|
|
4
4
|
const ROUTE_EXTENSIONS = new Set([
|
|
5
5
|
".tsx",
|