Skip to content

Commit

Permalink
fix(ui5-tooling-transpile): do not stop server for transpile issues (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
petermuessig authored Jul 16, 2023
1 parent 1e2a9fb commit 2cbfd30
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions packages/ui5-tooling-transpile/lib/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,19 @@ module.exports = async function ({ resources, options, middlewareUtil }) {

const resource = matchedResources?.[0];
if (resource) {
// transpile the resource
const code = await transpileAsync(resource);

// send out transpiled source
let { contentType /*, charset */ } = middlewareUtil.getMimeInfo(".js");
res.setHeader("Content-Type", contentType);
res.end(normalizeLineFeeds(code));
// transpile the resource (+ error handling)
try {
const code = await transpileAsync(resource);

// send out transpiled source
let { contentType /*, charset */ } = middlewareUtil.getMimeInfo(".js");
res.setHeader("Content-Type", contentType);
res.end(normalizeLineFeeds(code));
} catch (err) {
res.status(500);
console.error(err.message);
res.end(JSON.stringify(err, undefined, 2));
}
// stop processing the request
return;
}
Expand Down

0 comments on commit 2cbfd30

Please sign in to comment.