TSBunch is a specialized TypeScript bundler designed to concatenate multiple `.ts` modules into a single `.ts` file without transpiling them to JavaScript. It is currently at version 0.4.25. Its primary use case is for platforms like CodinGame that require a single-file submission for TypeScript projects but do not allow or need JavaScript transpilation. Unlike mainstream bundlers (e.g., Webpack, Rollup, esbuild), TSBunch avoids generating JavaScript, instead leveraging TypeScript's `namespace` feature for module aggregation. This makes it unique for specific build workflows where the output must remain TypeScript. It has known limitations regarding full ES module import/export syntax support and does not resolve circular dependencies, operating primarily via string matching rather than a full AST analysis.
npm install tsbunchVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to use the `tsbunch` function to bundle a TypeScript entry file, specify an output path, and include an optional declaration file, illustrating its core command-line usage.
Review the 'Caveats' section in the TSBunch README for supported and unsupported import/export syntax. Adjust your module structure to conform to the supported patterns, typically favoring explicit named exports and avoiding dynamic imports or re-exports from other modules.
Instead of directly default exporting functions or classes, assign them to a `const` and then `export default` that constant. Example: `const MyFunc = () => {}; export default MyFunc;`Before bundling, ensure your TypeScript project's module graph is free of circular dependencies. Tools like `madge` or `depcheck` can help identify these cycles in your codebase.
Refactor your code to use only explicit named imports and exports for modules that will be bundled. Avoid advanced module patterns that rely on dynamic loading or re-exporting namespaces.
Verify that all imported modules use supported `import` syntax as outlined in the TSBunch 'Caveats' section. Ensure module paths are relative and correct within the project structure.
Identify and refactor any circular dependencies in your project's module graph. Use `madge --circular --ts` or similar tools to help pinpoint these issues before running TSBunch.
Review the 'Caveats' section for partially supported or unsupported import/export syntax. Specifically, avoid direct `export default function/class` and use a `const` variable for the default export instead. Ensure all module exports are explicitly named and simple.
No dependency data recorded yet.