Show good error message if project code has broken import
MODIFY
packages/kit/src/api/dev/index.ts
packages/kit/src/api/dev/index.ts
@@ -137,6 +137,23 @@ class Watcher extends EventEmitter {
setup = {};
}
+ let root;
+
+ try {
+ root = await load(`/_app/main/root.js`);
+
+ if (!root.default) {
+ res.statusCode = 500;
+ res.end('Failed to load root component');
+ return
+ }
+ }
+ catch (e) {
+ res.statusCode = 500;
+ res.end(e.toString());
+ return
+ }
+
const rendered = await render({
host: null, // TODO what should this be? is it necessary?
headers: req.headers,
@@ -153,7 +170,7 @@ class Watcher extends EventEmitter {
},
files: 'build',
dev: true,
- root: await load(`/_app/main/root.js`),
+ root,
setup,
load: route => load(route.url.replace(/\.\w+$/, '.js')) // TODO is the replace still necessary?
});

Show good error message if project code has broken import