-
Notifications
You must be signed in to change notification settings - Fork 400
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow disabling type-checking when swc-loader is used #2833
Comments
but the plugins are evaluated by The only problem that I can see is the performance of this task |
I mean, adding the plugin should not improve performance - it should at most have the same performance or a worse performance. Does not make sense enabling @nestjs/swagger plugin and simply getting 15x faster build time. What if I want to have this 15x faster build in my project and opt to not use the swagger plugin? Currently is not possible. |
Enabling the plugin doesn't make the build faster as you can't even use it with swc-loader (they are not compatible). I suppose it just doesn't build stuff at all (or fallbacks to cache) Please provide a minimum reproduction repository (Git repository/StackBlitz/CodeSandbox project). |
It's not caching at all and I am sure it's building correctly, because in both scenarios application runs correctly. I am sure it's not caching because I build it in a docker container as well and the behavior is the same. I'll try to create a repository that reproduces that, but I am afraid that a small repository won't be noticeable the difference in build time. |
Either way, We need a minimum reproduction repository to help you out |
Done! Here is the repository. You can follow the README.md, but in short I have created an entrypoint script that builds the application with the @nestjs/swagger plugin enabled and also with the plugin disabled so that you can easily compare the build time between them. I recommend running it in Docker You can of course reproduce without the script by simple running the build commands manually and comparing the time, having full control of the flow. There is also a README.md with the instructions to reproduce it, but it's quite straightforward to reproduce this weird behavior. As you can see in the screenshot, enabling the @nestjs/swagger plugin improves the build time by ~15x, which is weird. What if I want fast build times without this plugin enabled? Currently is not possible, so I am forced to use this plugin to improve the build time. |
I'll look into it as soon as I can, but it has low priority as—as I've already mentioned above—plugin and swc-loader are not compatible anyway, so the results you're seeing are incorrect (there's very likely some error being thrown under the hood that falls back to a different configuration—a plugin entry in the configuration might be causing it, but I'll have to double-check). TLDR; It's not swc-loader "without a plugin causing the build to be slow" (as it doesn't even use that plugin). There must be something else |
Alright, I had a few minutes and decided to dive deeper into this issue. The difference is, when a project doesn't use any plugin, we can run the That being said, in your repository Hence 3 seconds instead of 400ms Using swc-loader + plugins (which isn't supported, as mentioned above, and shouldn't be used) means there's no async type-checker + SWC just transpiles your code (no errors) + plugins are not executed anyway. |
Sure, makes sense. But how can I have no type-check in my build without the need of enabling a plugin while using webpack + swc-loader? I'd like to prioritize a faster build instead. |
Why would you ever want |
I've been trying to create a NestJS project using Bun and sometimes I got a different behavior using Besides, I've just tested and running |
const swcDefaultConfig =
require('@nestjs/cli/lib/compiler/defaults/swc-defaults').swcDefaultsFactory()
.swcOptions;
module.exports = (webpackConfig) => {
return {
module: {
rules: [
{
test: /\.ts$/,
exclude: /node_modules/,
use: {
loader: 'swc-loader',
options: swcDefaultConfig,
},
},
],
},
plugins: [webpackConfig.plugins[0]],
};
}; ☝️ this configuration excludes |
Is there an existing issue for this?
Current behavior
I have a monorepo project that uses webpack + swc-loader + @nestjs/swagger plugin. Everything runs fine and fast (build is around 100ms), however if I simply REMOVE the @nestjs/swagger plugin, build time increases to ~=2200ms for no reason.
Minimum reproduction code
https://github.com/christian-gama/nestjs-build-bug-reproduction
Steps to reproduce
Local
git clone https://github.com/christian-gama/nestjs-build-bug-reproduction.git
cd nestjs-build-bug-reproduction.git
pnpm install
chmod +x ./entrypoint.sh
./entrypoint.sh
Docker
git clone https://github.com/christian-gama/nestjs-build-bug-reproduction.git
cd nestjs-build-bug-reproduction.git
pnpm docker:build
Expected behavior
Disabling or enabling the @nestjs/swagger should have no impact in the build time of the application, but the weirdest behavior is to have a build time 10x faster with the plugin ENABLED, which does not make any sense, since swc-loader does not even support the @nest/swagger plugin.
I'd like to see a faster build time without using the @nest/swagger plugin enabled - the only thing this plugin is doing for the project is to improve the build time, which shouldn't be happening.
Package
@nestjs/common
@nestjs/core
@nestjs/microservices
@nestjs/platform-express
@nestjs/platform-fastify
@nestjs/platform-socket.io
@nestjs/platform-ws
@nestjs/testing
@nestjs/websockets
Other package
@nestjs/swagger
NestJS version
10.4.12
Packages versions
[System Information]
OS Version : macOS 24.1.0
NodeJS Version : v23.1.0
NPM Version : 10.9.0
[Nest CLI]
Nest CLI Version : 10.4.8
[Nest Platform Information]
platform-express version : 10.4.12
cache-manager version : 2.3.0
microservices version : 10.4.12
mapped-types version : 2.0.6
schematics version : 10.2.3
passport version : 10.0.3
schedule version : 4.1.1
terminus version : 10.2.3
swagger version : 8.0.7
testing version : 10.4.12
common version : 10.4.12
config version : 3.3.0
axios version : 3.1.2
core version : 10.4.12
cli version : 10.4.8
version : 2.4.2
version : 1.2.4
Node.js version
23.1.0
In which operating systems have you tested?
Other
No response
The text was updated successfully, but these errors were encountered: