question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Custom middleware does not work with esbuild because emitDecoratorMetadata is not supported

See original GitHub issue

https://github.com/lukeautry/tsoa/issues/961

According to this ticket, tsoa doesn’t rely on the emitDecoratorMetadata TS option. That seemed correct at the time of writing, but sadly appears to no longer be true: https://github.com/lukeautry/tsoa/blob/acdfeb4d398fa7416dd10e251029d9e109c216d3/packages/runtime/src/decorators/middlewares.ts#L41

Because esbuild doesn’t support emitDecoratorMetadata, it appears that custom middleware via the @Middlewares annotation cannot be used with esbuild.

Is there any advice for a workaround?

Sorting

  • I’m submitting a …

    • bug report
    • feature request
    • support request
  • I confirm that I

    • used the search to make sure that a similar issue hasn’t already been submit

Expected Behavior



Current Behavior



Possible Solution

Steps to Reproduce

Context (Environment)

Version of the library: Version of NodeJS:

  • Confirm you were using yarn not npm: [ ]

Detailed Description

Breaking change?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
jsamilowcommented, Aug 12, 2022

We fixed it. It turns out the issue is import {Middlewares} from 'tsoa'. It works if we do import {Middlewares} from '@tsoa/runtime'. This is surprising but it works. I guess I was barking up the totally wrong tree. Sorry about that and thanks for looking!

0reactions
bkiaccommented, Nov 9, 2022

@jsamilow thanks for the suggestion! Build fails if I’m importing from tsoa but it works just fine with @tsoa/runtime

Read more comments on GitHub >

github_iconTop Results From Across the Web

"emitDecoratorMetadata": false, supported or not? #961 - GitHub
I am attempting to evaluate tsoa for suitability in my stack. We use esbuild to produce a bundle. esbuild DOES support the tsconfig...
Read more >
Content Types - ESBuild
The emitDecoratorMetadata TypeScript configuration option is not supported. This feature passes a JavaScript representation of the corresponding TypeScript type ...
Read more >
Getting started with NestJS, Vite, and esbuild - LogRocket Blog
In this article, we'll learn about NestJS, Vite, and esbuild; how they work together; and how to configure a NestJS app to make...
Read more >
vite-plugin-node - npm
A vite plugin to allow you to use vite as node dev server. Features. All the perks from Vite plus: Node server HMR!...
Read more >
Next Generation Node.js server Development Tool - Axe
Life is short, don't waste on the server reloading. ... I'm recently working on a relatively large nestjs backend project.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found