@vistagenic/vista 0.2.0 → 0.2.2
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/bin/build-rsc.js
CHANGED
|
@@ -53,7 +53,7 @@ function runPostCSS(cwd, vistaDir) {
|
|
|
53
53
|
/**
|
|
54
54
|
* Generate the RSC-aware client entry file
|
|
55
55
|
*/
|
|
56
|
-
function generateRSCClientEntry(cwd, vistaDir) {
|
|
56
|
+
function generateRSCClientEntry(cwd, vistaDir, isDev) {
|
|
57
57
|
const clientEntryContent = `/**
|
|
58
58
|
* Vista RSC Client Entry
|
|
59
59
|
*
|
|
@@ -89,7 +89,8 @@ hydrateRoot(
|
|
|
89
89
|
})
|
|
90
90
|
);
|
|
91
91
|
|
|
92
|
-
|
|
92
|
+
${isDev
|
|
93
|
+
? `// Vista live-reload: listen for server component changes via SSE
|
|
93
94
|
(function connectReload() {
|
|
94
95
|
const es = new EventSource('${constants_1.SSE_ENDPOINT}');
|
|
95
96
|
es.onmessage = (e) => {
|
|
@@ -108,7 +109,8 @@ hydrateRoot(
|
|
|
108
109
|
es.close();
|
|
109
110
|
setTimeout(connectReload, 3000);
|
|
110
111
|
};
|
|
111
|
-
})()
|
|
112
|
+
})();`
|
|
113
|
+
: '// SSE live-reload disabled in production'}
|
|
112
114
|
`;
|
|
113
115
|
fs_1.default.writeFileSync(path_1.default.join(vistaDir, 'rsc-client.tsx'), clientEntryContent);
|
|
114
116
|
if (_debug)
|
|
@@ -257,7 +259,7 @@ async function buildRSC(watch = false) {
|
|
|
257
259
|
type: route.type,
|
|
258
260
|
})));
|
|
259
261
|
// Generate client entry
|
|
260
|
-
generateRSCClientEntry(cwd, vistaDirs.root);
|
|
262
|
+
generateRSCClientEntry(cwd, vistaDirs.root, watch);
|
|
261
263
|
// Create webpack configs
|
|
262
264
|
const options = {
|
|
263
265
|
cwd,
|
|
@@ -152,6 +152,15 @@ function setupTypeScriptRuntime(cwd) {
|
|
|
152
152
|
esModuleInterop: true,
|
|
153
153
|
},
|
|
154
154
|
});
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
catch {
|
|
158
|
+
// fallback
|
|
159
|
+
}
|
|
160
|
+
try {
|
|
161
|
+
require.resolve('tsx', { paths: [cwd] });
|
|
162
|
+
require('tsx/cjs');
|
|
163
|
+
return;
|
|
155
164
|
}
|
|
156
165
|
catch (e) {
|
|
157
166
|
console.log('Failed to setup TypeScript runtime:', e);
|
|
@@ -97,9 +97,19 @@ function setupTypeScriptRuntime(cwd) {
|
|
|
97
97
|
esModuleInterop: true,
|
|
98
98
|
},
|
|
99
99
|
});
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
// fallback
|
|
104
|
+
}
|
|
105
|
+
try {
|
|
106
|
+
require.resolve('tsx', { paths: [cwd] });
|
|
107
|
+
// tsx/cjs registers the TypeScript loader for require()
|
|
108
|
+
require('tsx/cjs');
|
|
109
|
+
return;
|
|
100
110
|
}
|
|
101
111
|
catch {
|
|
102
|
-
throw new Error('No TypeScript compiler available for RSC upstream runtime.');
|
|
112
|
+
throw new Error('No TypeScript compiler available for RSC upstream runtime. Install one of: @swc-node/register, ts-node, or tsx');
|
|
103
113
|
}
|
|
104
114
|
}
|
|
105
115
|
function hasClientBoundaryDirective(source) {
|