react-client 1.0.26 → 1.0.28
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 +0 -2
- package/dist/cli/commands/dev.js +31 -23
- package/package.json +1 -2
package/README.md
CHANGED
|
@@ -91,7 +91,6 @@ Each template is pre-configured for esbuild, HMR, and fast bootstrapping.
|
|
|
91
91
|
- 🔍 **Source Map Stack Mapping** — Maps runtime errors to original TS/JS source lines
|
|
92
92
|
- 💬 **Auto Port Detection** — Prompts when default port 2202 is occupied
|
|
93
93
|
- 🧠 **Smart Config Loader** — Detects project root, compiles `.ts` configs dynamically
|
|
94
|
-
- 🎨 **PrismJS Highlighting** — For pretty overlay code frames
|
|
95
94
|
- 🔌 **Plugin Hook System** — Extendable with `configResolved`, `transform`, `buildEnd`
|
|
96
95
|
|
|
97
96
|
---
|
|
@@ -104,7 +103,6 @@ Each template is pre-configured for esbuild, HMR, and fast bootstrapping.
|
|
|
104
103
|
2. **Connect** serves files and APIs (React Refresh runtime, overlay, source-map).
|
|
105
104
|
3. **WebSocket** pushes HMR updates and overlay messages.
|
|
106
105
|
4. **Chokidar** watches `/src` for changes and triggers rebuilds.
|
|
107
|
-
5. **Overlay UI** (via PrismJS) displays mapped stack frames with syntax highlighting.
|
|
108
106
|
|
|
109
107
|
---
|
|
110
108
|
|
package/dist/cli/commands/dev.js
CHANGED
|
@@ -182,29 +182,33 @@ async function dev() {
|
|
|
182
182
|
res.setHeader('Content-Type', 'application/javascript');
|
|
183
183
|
return res.end(await fs_extra_1.default.readFile(cacheFile, 'utf8'));
|
|
184
184
|
}
|
|
185
|
-
// 🧠
|
|
185
|
+
// 🧠 Handle subpath imports correctly (like react-dom/client)
|
|
186
186
|
let entryFile = null;
|
|
187
187
|
try {
|
|
188
|
-
// Try direct require.resolve first (works for most)
|
|
189
188
|
entryFile = require.resolve(id, { paths: [appRoot] });
|
|
190
189
|
}
|
|
191
190
|
catch {
|
|
192
|
-
// Handle subpath imports
|
|
193
191
|
const parts = id.split('/');
|
|
194
192
|
const pkgRoot = parts[0].startsWith('@') ? parts.slice(0, 2).join('/') : parts[0];
|
|
195
193
|
const subPath = parts.slice(pkgRoot.startsWith('@') ? 2 : 1).join('/');
|
|
196
|
-
const
|
|
197
|
-
const pkgDir = path_1.default.dirname(
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
path_1.default.join(pkgDir,
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
194
|
+
const pkgJsonPath = require.resolve(`${pkgRoot}/package.json`, { paths: [appRoot] });
|
|
195
|
+
const pkgDir = path_1.default.dirname(pkgJsonPath);
|
|
196
|
+
// Special case: react-dom/client
|
|
197
|
+
if (pkgRoot === 'react-dom' && subPath === 'client') {
|
|
198
|
+
entryFile = path_1.default.join(pkgDir, 'client.js');
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
const candidates = [
|
|
202
|
+
path_1.default.join(pkgDir, subPath),
|
|
203
|
+
path_1.default.join(pkgDir, subPath, 'index.js'),
|
|
204
|
+
path_1.default.join(pkgDir, subPath + '.js'),
|
|
205
|
+
path_1.default.join(pkgDir, subPath + '.mjs'),
|
|
206
|
+
];
|
|
207
|
+
for (const f of candidates) {
|
|
208
|
+
if (await fs_extra_1.default.pathExists(f)) {
|
|
209
|
+
entryFile = f;
|
|
210
|
+
break;
|
|
211
|
+
}
|
|
208
212
|
}
|
|
209
213
|
}
|
|
210
214
|
}
|
|
@@ -228,11 +232,8 @@ async function dev() {
|
|
|
228
232
|
res.end(`// Failed to resolve module ${id}: ${err.message}`);
|
|
229
233
|
}
|
|
230
234
|
});
|
|
231
|
-
// --- Serve runtime overlay (
|
|
232
|
-
// --- Serve runtime overlay (inline in dev server)
|
|
235
|
+
// --- Serve runtime overlay (inline, no external dependencies)
|
|
233
236
|
const OVERLAY_RUNTIME = `
|
|
234
|
-
import "/@prismjs";
|
|
235
|
-
|
|
236
237
|
const overlayId = "__rc_error_overlay__";
|
|
237
238
|
|
|
238
239
|
const style = document.createElement("style");
|
|
@@ -251,11 +252,11 @@ style.textContent = \`
|
|
|
251
252
|
}
|
|
252
253
|
@keyframes fadeIn { from {opacity: 0;} to {opacity: 1;} }
|
|
253
254
|
#\${overlayId} h2 { color: #ff6b6b; margin-bottom: 16px; }
|
|
254
|
-
#\${overlayId} pre { background: rgba(255,255,255,0.1); padding: 12px; border-radius: 6px; }
|
|
255
|
+
#\${overlayId} pre { background: rgba(255,255,255,0.1); padding: 12px; border-radius: 6px; overflow-x: auto; }
|
|
255
256
|
#\${overlayId} a { color: #9cf; text-decoration: underline; }
|
|
256
257
|
#\${overlayId} .frame { margin: 12px 0; }
|
|
257
258
|
#\${overlayId} .frame-file { color: #ffa500; cursor: pointer; font-weight: bold; margin-bottom: 4px; }
|
|
258
|
-
.line-number { opacity: 0.5; margin-right: 10px; }
|
|
259
|
+
.line-number { opacity: 0.5; margin-right: 10px; display: inline-block; width: 2em; text-align: right; }
|
|
259
260
|
\`;
|
|
260
261
|
document.head.appendChild(style);
|
|
261
262
|
|
|
@@ -277,6 +278,14 @@ async function mapStackFrame(frame) {
|
|
|
277
278
|
return frame;
|
|
278
279
|
}
|
|
279
280
|
|
|
281
|
+
// 🔹 minimal inline syntax highlighting (keywords only)
|
|
282
|
+
function highlightJS(code) {
|
|
283
|
+
return code
|
|
284
|
+
.replace(/(const|let|var|function|return|import|from|export|class|new|await|async|if|else|for|while|try|catch|throw)/g, '<span style="color:#ffb86c;">$1</span>')
|
|
285
|
+
.replace(/("[^"]*"|'[^']*')/g, '<span style="color:#8be9fd;">$1</span>')
|
|
286
|
+
.replace(/(\\/\\/.*)/g, '<span style="opacity:0.6;">$1</span>');
|
|
287
|
+
}
|
|
288
|
+
|
|
280
289
|
async function renderOverlay(err) {
|
|
281
290
|
const overlay =
|
|
282
291
|
document.getElementById(overlayId) ||
|
|
@@ -302,8 +311,7 @@ async function renderOverlay(err) {
|
|
|
302
311
|
|
|
303
312
|
if (mapped.snippet) {
|
|
304
313
|
const pre = document.createElement("pre");
|
|
305
|
-
pre.
|
|
306
|
-
pre.innerHTML = Prism.highlight(mapped.snippet, Prism.languages.jsx, "jsx");
|
|
314
|
+
pre.innerHTML = highlightJS(mapped.snippet);
|
|
307
315
|
frameEl.appendChild(pre);
|
|
308
316
|
}
|
|
309
317
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-client",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.28",
|
|
4
4
|
"description": "react-client is a lightweight CLI and runtime for building React apps with fast iteration.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Venkatesh Sundaram",
|
|
@@ -102,7 +102,6 @@
|
|
|
102
102
|
"esbuild": "^0.25.12",
|
|
103
103
|
"fs-extra": "^11.3.2",
|
|
104
104
|
"open": "^8.4.2",
|
|
105
|
-
"prismjs": "^1.30.0",
|
|
106
105
|
"prompts": "^2.4.2",
|
|
107
106
|
"react-refresh": "^0.14.0",
|
|
108
107
|
"serve-static": "^1.15.0",
|