Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 5 additions & 13 deletions tools/pfe-tools/dev-server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,21 +88,13 @@ async function cacheBusterMiddleware(ctx: Context, next: () => Promise<any>) {
function liveReloadTsChangesMiddleware(
config: ReturnType<typeof normalizeOptions>,
): Middleware {
/**
* capture group 1:
* Either config.elementsDir or `pfe-core`
* `/`
* **ANY** (_>= 0x_)
* `.js`
*/
const TYPESCRIPT_SOURCES_RE = new RegExp(`(${config.elementsDir}|pfe-core)/.*\\.js`);

return function(ctx, next) {
if (!ctx.path.includes('node_modules') && ctx.path
.match(TYPESCRIPT_SOURCES_RE)) {
return async function(ctx, next) {
await next();
if (ctx.status === 404
&& !ctx.path.includes('node_modules')
&& TYPESCRIPT_SOURCES_RE.test(ctx.path)) {
ctx.redirect(ctx.path.replace('.js', '.ts'));
Comment on lines 91 to 97
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

valid but likely no-op.

} else {
return next();
}
Comment on lines +92 to 98
};
}
Expand Down
Loading