Thursday 31 August 2023

How to build bundled scripts from a monolithic Node TypeScript repository?

I have a monolithic Node TypeScript project. Within this project, there's a scripts folder containing multiple files. Each file is intended to act as a separate service/script and these files share common libraries, methods, and classes.

For example, I have a HttpRequest class that is used across multiple files and internally utilizes the axios library.

Here's my challenge: I want to maintain the monolithic structure during development to minimize code redundancy. However, when I compile the project to a "/dist" folder, I'd like each file in the scripts folder to become a standalone, bundled JavaScript file that can be executed independently. Essentially, each built file should contain everything it needs to run on its own.

I've tried using Webpack, but it seems either too complex or not suited for this specific requirement. Is there a simpler or better way to achieve this?

Example folder structure:

> scripts/
  -------->test1.ts
  -------->test2.ts
  -------->test3.ts
> shared/
  -------->shared1.ts
  -------->shared2.ts
  -------->httpRequestAgnostic.ts

Thank you.



from How to build bundled scripts from a monolithic Node TypeScript repository?

No comments:

Post a Comment