Add swc as an option to use with node/nestjs builder #22632
Replies: 40 comments
-
This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. |
Beta Was this translation helpful? Give feedback.
-
Looks like its coming to NestCLI so it would be great for Nx to also provide it as an option https://twitter.com/kammysliwiec/status/1664192006019506178?s=20 |
Beta Was this translation helpful? Give feedback.
-
I think many of us would love to see this. |
Beta Was this translation helpful? Give feedback.
-
NestJS CLI shipped this in v10 https://trilon.io/blog/nestjs-10-is-now-available#nestjs-%EF%B8%8F-swc |
Beta Was this translation helpful? Give feedback.
-
Given that the latest version of Nx seems to be slowing down the NestJS development process, I was wondering if there are any plans to integrate SWC to potentially improve performance. 🤔 |
Beta Was this translation helpful? Give feedback.
-
Is there anyone willing to work on this? |
Beta Was this translation helpful? Give feedback.
-
+1 on this. Adding support for SWC would be great for NestJs apps. I've managed to get SWC working with NestJs, but compilation fails on NX library imports. |
Beta Was this translation helpful? Give feedback.
-
+1. This will make development experience so much better. |
Beta Was this translation helpful? Give feedback.
-
Is it possible to use this |
Beta Was this translation helpful? Give feedback.
-
I thought I made it working with nest start -b swc, but when I tried to import an nx generated library, the paths were not compiled at all |
Beta Was this translation helpful? Give feedback.
-
@c0dewriter can you make public repo with this? |
Beta Was this translation helpful? Give feedback.
-
@c0dewriter thanks for these snippets. I can compile a new standalone NestJS app in NX, however imports from libs aren't working for me with this error at build time
|
Beta Was this translation helpful? Give feedback.
-
This is the main issue here and probably why it takes so long. Executor do more stuff than just wrapping underlying tech (like swc). It also has to rewrite your imports depending on the command you run. If you want all the nice things that nx gives you for monorepo management you have to accept that you won't always be able to use latest and greatest from the framework that nx wraps. |
Beta Was this translation helpful? Give feedback.
-
@pf1gura thanks for your insight. Given the solution above uses the existing '@nx/js:swc' executor I made an assumption that this executor would already handle imports from libs. @c0dewriter posted a potential solution, I tried it and gave feedback, I'm just keen for a solution because my NestJS build times have been very slow after the release of v10 and the nx monorepo I work with day to day has 6 different NestJS applications and the DX isn't great right now. |
Beta Was this translation helpful? Give feedback.
-
If I recall correctly existing swc executor is for libraries only. You can use it in your shared TypeScript libraries to speed up library build times but final build of your application still has to go through node executor (which does not use swc) |
Beta Was this translation helpful? Give feedback.
-
@wilson208 I'm actually seeing the same rootDir bug. Have you found a fix yet? |
Beta Was this translation helpful? Give feedback.
-
@quesurifn @wilson208 and anyone else, is it possible that your build target names (of two interdependent libs) are different? This bug can appear if you are importing one buildable lib into the other, and the build target names are different. related: #11289 For anyone having that error, solution: #17798 (comment) |
Beta Was this translation helpful? Give feedback.
-
I'm currently working on integrating SWC into my NestJS application using NX. In my setup, I have shared libraries that are non-buildable, so the solution you mentioned doesn't seem applicable in my case. Is there an alternative approach or workaround that could make this integration possible? |
Beta Was this translation helpful? Give feedback.
-
There are many things being discussed in this thread. Let's try to keep it focused on the original request (supporting swc). Anyone with the |
Beta Was this translation helpful? Give feedback.
-
@mandarini Indeed that was the issue. I encountered this with TS now. For some reason TS didn't trigger the same error until I did a complete refactor but I indeed did have circular dependencies that were two buildable libs referencing each other. The fix was to put them into one lib and then break them up with ts paths so semantically, at least, there is some differentiation. |
Beta Was this translation helpful? Give feedback.
-
@ggagosh I would try looking even if they are not buildable. Also if you're using TS they are indeed buildable. I fixed mine from putting libs that imported each other into the same lib. |
Beta Was this translation helpful? Give feedback.
-
I also used the https://github.com/pahen/madge tool to help find some circular deps issues that was blocking swc from being able to compile my projects |
Beta Was this translation helpful? Give feedback.
-
SWC support for NestJS apps is still required |
Beta Was this translation helpful? Give feedback.
-
Any plan to support this in nx? :( |
Beta Was this translation helpful? Give feedback.
-
Description
As swc-project/swc#3459 has fixed the use of legacy-decorators, it'd awesome to be able of use
swc
as compiler/bundler to reduce typescript compilation time 🚀Motivation
Reduce time of tsc.
Suggested Implementation
swc is used with @nrwl/js and others, use it with @nrwl/node (nestjs) too
Alternate Implementations
esbuild
doesn't supportlegacy decoratorsemitDecoratorMetadata
😢Beta Was this translation helpful? Give feedback.
All reactions