tsoa: Version 6.1.0 leads to missing packages, breaks existing builds
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
I can upgrade from version 6.0.1 to 6.1.0 and expect there are no breaking changes.
Current Behavior
I just tried to upgrade from version 6.0.1 to version 6.1.0. The older version is just fine with no issues running our npm scripts.
However, with version 6.1.0 we now observe that packages are missing:
@hapi/boom@tsoa/cli
These lead to compile/build errors because those packages cannot be found.
Possible Solution
Something in the direct or indirect dependencies has changed between version 6.0.1 and 6.1.0.
The problem can be solved by applying the following in package.json:
- add package
@hapi/boomto the dependencies - add package
@tsoa/clito the devDependencies
Steps to Reproduce
Context (Environment)
Version of the library: 6.1.0 Version of NodeJS: 20.11.1 Version of TypeScript: 5.4.2
- Confirm you were using yarn not npm: [ ]
I’m using pnpm instead of npm but do not believe this to be the problem. Package tsoa worked just fine until an up to version 6.0.1 with pnpm across multiple TypeScript projects. There was no need to add any other package to make tsoa work.
Detailed Description
Breaking change?
Yes, this is a breaking change as we had to add the missing packages to package.json which we didn’t have to list as dependencies before.
UPDATE 10 Mar 2024
A possibly better option to resolve this is described in this comment: https://github.com/lukeautry/tsoa/issues/1573#issuecomment-1986996301
About this issue
- Original URL
- State: closed
- Created 4 months ago
- Reactions: 1
- Comments: 20 (1 by maintainers)
No, makes no sense imo. If we can import and what is already v. complicated because the package managers (pnmp) are kinda pushing this onto the user, that’ll raise it as an issue here in any case. TS can still make breaking changes, so does @types/* do often enough that we can’t avoid it.
The generated routes.ts file imports from @tsoa/cli. These services would need to be moved from @tsoa/cli to @tsoa/runtime before @tsoa/cli could be removed from production. https://github.com/lukeautry/tsoa/blob/118f090981f90078b348987cad7a3ae65a5c8d3a/packages/cli/src/routeGeneration/templates/express/express.hbs#L5
On further investigating this issue, I think there is a fundamental problem with the package
tsoa. It has a dependency on the cli and on the runtime. One of these should be a regular dependency (runtime) and the other a dev dependency (cli). However, when you install packagetsoaas described in the “Gettting Started” instructions, both of these packages become regular dependencies. Furthermore the newer version of the cli has the missing@hapi/boomissue.And here is how you can resolve this issue while also avoiding the bug reported at the beginning of this discussion:
Everybody who follows the “Getting Started” instructions at https://tsoa-community.github.io/docs/getting-started.html will add package
tsoato their project. As a result all of them will have the cli as a runtime dependency!I ran this little experiment:
tsoa@tsoa/runtimeas a regular dependency@tsoa/clias a devDependencytsoawith imports from@tsoa/runtimeThen clear your npm cache, delete node_modules, lock file, etc. to start with a clean slate. Restore packages, build and run your tests.
With this setup I managed to change the cli to a dev dependency. Also, this resolves the missing
@hapy/boomissue for both, version 6.0.1 and 6.1.0 of tsoa (which as a single package I no longer use at the moment).So I am wondering if this may be the best way to resolve this issue:
tsoa.This has the additional advantage that everybody should be able to remove the cli from their production deployments.
Again, happy to stand corrected in case I overlooked something. So far, I have applied this solution to two repositories and so far there don’t seem to be unwanted side effects.
As a point of reference, the dependencies in my
pnpm-lock.jsonfile look as follows:As desired, the cli is a dev dependency while the runtime is a regular dependency. Also, the cli has the runtime as a dependency which makes a lot of sense.
FYI @ManfredLange the text you wanted to provide in the copyable boxes appears to be empty.
I also encountered this today though and downgraded back to 6.0.1. Another issue besides being broken even in developent (due to
@hapi/boommissing as I am using Koa) is that we now need@tsoa/clias production dependency. The generated routes now import the Template stuff from@tsoa/cliCould we revert this? I would like to keep@tsoa/clias adevDependency