#Transpiling external TypeScript packages

5 messages · Page 1 of 1 (latest)

woeful viper
#

Having a monorepo project using multiple Next.JS apps, each are using private packages containing TypeScript modules which are directly transpiled and bundled in these applications. Everything works like a charm without any tsc --watch required. As the application grows, we plan on extracting the API's of these projects into separate NestJS projects. However, because NestJS does not execute TypeScript, but transpiles first, then executes JavaScript code, importing these external TypeScript packages fails.

Are there future plans for NestJS to work like Next.JS and enable the same feature? Next.JS's modern approach (i.e., no requiring a dist folder at run-time) seems to be the right way to go.

random sparrow
#

Can you maybe clarify what the difference is? So transpire and bundle sounds pretty much the same as what nestjs does. Typescript needs always be transpiled to run in a V8 no matter if it is at build time or on the fly

#

If you have a dist folder or not may depend on the probably we pack options maybe. Performance wise I'd argue that output into a J's file would be more performance than on the fly compilation

#

I guess there is also some way for webpack to mark packages as external if no compilation is needed

woeful viper
#

Next.JS uses a cache folder (i.e., .next) at run-time, storing all bundles there. So, all imports are also bundled in that directory. Meaning that external packages may be transpiled at run-time, then imported from that bundle. The difference with NestJS is that it creates a dist folder with a mirror-like structure, meaning that every dependency is still imported under the node_modules folder instead of being included in a cached bundle.