create-yeow 0.2.42 → 0.2.44
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/package.json
CHANGED
|
Binary file
|
|
@@ -157,6 +157,7 @@ function startHotReload() {
|
|
|
157
157
|
codeFile: compiled.replace(/\\/g, '/'),
|
|
158
158
|
assetsDir: existsSync(assetsDir) ? assetsDir.replace(/\\/g, '/') : null,
|
|
159
159
|
});
|
|
160
|
+
_consumer = null; // invalidate stale source-map cache
|
|
160
161
|
ok('Hot reload sent via WebSocket');
|
|
161
162
|
}
|
|
162
163
|
} catch (e) {
|
|
@@ -202,49 +203,67 @@ async function printFormattedError(err) {
|
|
|
202
203
|
if (err.context) out += ` ${c.D}context: ${err.context}${c.r}\n`;
|
|
203
204
|
out += ` ${c.Y}${err.message}${c.r}\n`;
|
|
204
205
|
|
|
205
|
-
const consumer =
|
|
206
|
-
if (consumer) {
|
|
207
|
-
if (err.
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
const indent = ' '.repeat(String(i + 1).padStart(4).length) + '| ';
|
|
223
|
-
const caret = ' '.repeat(col) + c.R + '^' + c.r;
|
|
224
|
-
out += ` ${c.R} →${c.r} ${indent}${caret}\n`;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
}
|
|
206
|
+
const consumer = err.fileName === 'main.js' ? await getSourceMapConsumer() : null;
|
|
207
|
+
if (!consumer) {
|
|
208
|
+
if (err.stack) err.stack.split('\n').slice(0, 5).forEach(l => { out += ` ${c.D} ${l.trim()}${c.r}\n`; });
|
|
209
|
+
console.log(out);
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// Resolve all stack frames
|
|
214
|
+
const frames = [];
|
|
215
|
+
if (err.stack) {
|
|
216
|
+
for (const line of err.stack.split('\n')) {
|
|
217
|
+
const m = line.match(/at\s+(?:\S+\s+)?\(?\/main\.js:(\d+):(\d+)\)?/);
|
|
218
|
+
if (m) {
|
|
219
|
+
const orig = consumer.originalPositionFor({ line: parseInt(m[1]), column: parseInt(m[2]) });
|
|
220
|
+
frames.push({ orig, raw: line });
|
|
221
|
+
} else {
|
|
222
|
+
frames.push({ raw: line });
|
|
228
223
|
}
|
|
229
224
|
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// Find first frame from user's src/ directory (not node_modules)
|
|
228
|
+
let ctxFrame = frames.find(f => f.orig?.source?.match(/[\\/]src[\\/]/) && !f.orig.source.includes('node_modules'))?.orig || null;
|
|
229
|
+
if (!ctxFrame && err.lineNumber > 0) {
|
|
230
|
+
ctxFrame = consumer.originalPositionFor({ line: err.lineNumber, column: err.columnNumber || 0 });
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// Show context for the chosen frame
|
|
234
|
+
if (ctxFrame?.source && ctxFrame.line) {
|
|
235
|
+
const srcPath = ctxFrame.source.replace(/^\.\.\/\.\.\//, '');
|
|
236
|
+
out += ` ${c.C}at ${srcPath}:${ctxFrame.line}:${ctxFrame.column}${c.r}\n`;
|
|
237
|
+
const content = consumer.sourceContentFor(ctxFrame.source);
|
|
238
|
+
if (content) {
|
|
239
|
+
const lines = content.split('\n');
|
|
240
|
+
const start = Math.max(0, ctxFrame.line - 3);
|
|
241
|
+
const end = Math.min(lines.length, ctxFrame.line + 2);
|
|
242
|
+
for (let i = start; i < end; i++) {
|
|
243
|
+
const prefix = i === ctxFrame.line - 1 ? c.R + ' →' : ' ';
|
|
244
|
+
out += ` ${prefix} ${c.D}${String(i + 1).padStart(4)}|${c.r} ${lines[i]}\n`;
|
|
245
|
+
if (i === ctxFrame.line - 1 && ctxFrame.column > 0) {
|
|
246
|
+
const col = Math.max(0, ctxFrame.column);
|
|
247
|
+
const indent = ' '.repeat(String(i + 1).padStart(4).length) + '| ';
|
|
248
|
+
const caret = ' '.repeat(col) + c.R + '^' + c.r;
|
|
249
|
+
out += ` ${c.R} →${c.r} ${indent}${caret}\n`;
|
|
242
250
|
}
|
|
243
|
-
out += ` ${c.D} ${line}${c.r}\n`;
|
|
244
251
|
}
|
|
245
252
|
}
|
|
246
|
-
}
|
|
247
|
-
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// Print resolved stack (all frames)
|
|
256
|
+
if (frames.length > 0) {
|
|
257
|
+
out += ` ${c.D}Stack:${c.r}\n`;
|
|
258
|
+
for (const f of frames) {
|
|
259
|
+
if (f.orig?.source) {
|
|
260
|
+
const srcPath = f.orig.source.replace(/^\.\.\/\.\.\//, '');
|
|
261
|
+
out += ` ${c.D} at ${srcPath}:${f.orig.line}:${f.orig.column}${c.r}\n`;
|
|
262
|
+
} else {
|
|
263
|
+
const internal = f.raw.includes('init.js') || f.raw.includes('unknown.js') ? ' (internal)' : '';
|
|
264
|
+
out += ` ${c.D} ${f.raw}${internal}${c.r}\n`;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
248
267
|
}
|
|
249
268
|
console.log(out);
|
|
250
269
|
}
|