diff --git a/changelog.md b/changelog.md index c93cf4e..28b1780 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,11 @@ # Changelog +## 2026-01-12 - 2.7.3 - fix(mod_output) +wrap long base64 file contents and format generated TypeScript output to avoid extremely long lines + +- Introduce MAX_LINE_LENGTH (200) and formatBase64 to split long base64 strings into chunks and join them with string concatenation +- Emit the files array as nicely indented object entries instead of a single JSON.stringify output to improve readability and avoid extremely long lines + ## 2026-01-12 - 2.7.2 - fix(readme) update README to add interactive setup (tsbundle init), expand quick start and usage examples, include pnpm install, document embedding/base64ts output with Deno example, add project structure recommendations, and clarify license/trademark wording diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index b886c84..053d5b9 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@git.zone/tsbundle', - version: '2.7.2', + version: '2.7.3', description: 'a multi-bundler tool supporting esbuild, rolldown, and rspack for painless bundling of web projects' } diff --git a/ts/mod_output/index.ts b/ts/mod_output/index.ts index 3071b0f..8095c12 100644 --- a/ts/mod_output/index.ts +++ b/ts/mod_output/index.ts @@ -79,9 +79,32 @@ export class Base64TsOutput { * Generate TypeScript file content */ public generateTypeScript(): string { - const filesJson = JSON.stringify(this.files, null, 2); + const MAX_LINE_LENGTH = 200; + + const formatBase64 = (base64: string): string => { + if (base64.length <= MAX_LINE_LENGTH) { + return `"${base64}"`; + } + + const chunks: string[] = []; + for (let i = 0; i < base64.length; i += MAX_LINE_LENGTH) { + chunks.push(base64.slice(i, i + MAX_LINE_LENGTH)); + } + + return `"" +\n "${chunks.join('" +\n "')}"`; + }; + + const filesFormatted = this.files.map(file => { + return ` { + "path": "${file.path}", + "contentBase64": ${formatBase64(file.contentBase64)} + }`; + }).join(',\n'); + return `// Auto-generated by tsbundle - do not edit -export const files: { path: string; contentBase64: string }[] = ${filesJson}; +export const files: { path: string; contentBase64: string }[] = [ +${filesFormatted} +]; `; }