Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8f129527d9 | |||
| 5d9052018e | |||
| 12c5655251 | |||
| 801cab9001 | |||
| 971cb685a7 | |||
| 0900d1a605 | |||
| f0fb99c8ae | |||
| 6d88adcd1e | |||
| 4349571112 |
25
changelog.md
25
changelog.md
@@ -1,5 +1,30 @@
|
||||
# Changelog
|
||||
|
||||
## 2026-02-24 - 2.8.4 - fix()
|
||||
no changes — empty diff, nothing to commit
|
||||
|
||||
- Diff contained no modifications; no release required
|
||||
|
||||
## 2026-01-23 - 2.8.3 - fix(mod_output)
|
||||
use pattern base dir when computing relative paths for files to serve
|
||||
|
||||
- Compute relativePath using the pattern base directory (dirPath) instead of this.cwd to ensure correct web-serving paths for absolute or relative entry.path values.
|
||||
- File changed: ts/mod_output/index.ts — replaces plugins.path.relative(this.cwd, fullPath) with plugins.path.relative(dirPath, fullPath) and adds clarifying comment.
|
||||
|
||||
## 2026-01-23 - 2.8.2 - fix(mod_output)
|
||||
resolve absolute and relative entry.path correctly when adding files
|
||||
|
||||
- Add check for plugins.path.isAbsolute(entry.path) to avoid incorrectly joining absolute paths with dirPath
|
||||
- Use entry.path directly when it's absolute, otherwise join with dirPath
|
||||
- Ensures correct relativePath calculation and prevents invalid file reads
|
||||
|
||||
## 2026-01-12 - 2.8.1 - fix(readme)
|
||||
document maxLineLength option for base64ts output and add example and tip
|
||||
|
||||
- Add documented `maxLineLength` configuration option (number, default 0 = unlimited) for `base64ts` output.
|
||||
- Include example config showing `maxLineLength: 200`.
|
||||
- Add a tip recommending setting `maxLineLength` to split long base64 strings when using AI tools with line-length limits.
|
||||
|
||||
## 2026-01-12 - 2.8.0 - feat(tsbundle)
|
||||
add configurable maxLineLength for base64ts output and improve build/error handling in child builds
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@git.zone/tsbundle",
|
||||
"version": "2.8.0",
|
||||
"version": "2.8.4",
|
||||
"private": false,
|
||||
"description": "a multi-bundler tool supporting esbuild, rolldown, and rspack for painless bundling of web projects",
|
||||
"main": "dist_ts/index.js",
|
||||
|
||||
@@ -91,6 +91,7 @@ tsbundle uses `npmextra.json` for configuration. Here's an example:
|
||||
| `bundler` | `"esbuild"` \| `"rolldown"` \| `"rspack"` | `"esbuild"` | Which bundler to use |
|
||||
| `production` | `boolean` | `false` | Enable minification |
|
||||
| `includeFiles` | `string[]` | `[]` | Glob patterns for additional files (HTML, assets) |
|
||||
| `maxLineLength` | `number` | `0` (unlimited) | For `base64ts` mode: max chars per line in output |
|
||||
|
||||
### Output Modes
|
||||
|
||||
@@ -108,6 +109,8 @@ export const files: { path: string; contentBase64: string }[] = [
|
||||
];
|
||||
```
|
||||
|
||||
**Tip:** If you're working with AI tools that have line length limitations, set `maxLineLength` (e.g., `200`) to split long base64 strings across multiple lines.
|
||||
|
||||
## Available Bundlers 🔧
|
||||
|
||||
tsbundle supports three modern bundlers:
|
||||
@@ -241,7 +244,8 @@ Config:
|
||||
"outputMode": "base64ts",
|
||||
"bundler": "esbuild",
|
||||
"production": true,
|
||||
"includeFiles": ["./html/index.html"]
|
||||
"includeFiles": ["./html/index.html"],
|
||||
"maxLineLength": 200
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@git.zone/tsbundle',
|
||||
version: '2.8.0',
|
||||
version: '2.8.4',
|
||||
description: 'a multi-bundler tool supporting esbuild, rolldown, and rspack for painless bundling of web projects'
|
||||
}
|
||||
|
||||
@@ -17,13 +17,15 @@ export interface IEnvTransportOptions {
|
||||
export type TOutputMode = 'bundle' | 'base64ts';
|
||||
export type TBundler = 'esbuild' | 'rolldown' | 'rspack';
|
||||
|
||||
export type TIncludeFile = string | { from: string; to: string };
|
||||
|
||||
export interface IBundleConfig {
|
||||
from: string;
|
||||
to: string;
|
||||
outputMode?: TOutputMode;
|
||||
bundler?: TBundler;
|
||||
production?: boolean;
|
||||
includeFiles?: string[];
|
||||
includeFiles?: TIncludeFile[];
|
||||
maxLineLength?: number; // For base64ts output: max chars per line. 0 or undefined = unlimited (default)
|
||||
}
|
||||
|
||||
|
||||
@@ -105,8 +105,12 @@ export class CustomBundleHandler {
|
||||
|
||||
// Add included files
|
||||
if (bundleConfig.includeFiles && bundleConfig.includeFiles.length > 0) {
|
||||
for (const pattern of bundleConfig.includeFiles) {
|
||||
await base64Output.addFilesFromGlob(pattern);
|
||||
for (const entry of bundleConfig.includeFiles) {
|
||||
if (typeof entry === 'string') {
|
||||
await base64Output.addFilesFromGlob(entry);
|
||||
} else {
|
||||
await base64Output.addFileWithServePath(entry.from, entry.to);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,7 +139,8 @@ export class CustomBundleHandler {
|
||||
const htmlHandler = new HtmlHandler();
|
||||
const outputDir = plugins.path.dirname(toPath);
|
||||
|
||||
for (const pattern of bundleConfig.includeFiles) {
|
||||
for (const entry of bundleConfig.includeFiles) {
|
||||
const pattern = typeof entry === 'string' ? entry : entry.from;
|
||||
await this.copyIncludedFiles(pattern, outputDir);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,7 +123,8 @@ export class InitHandler {
|
||||
console.log(` Mode: ${bundle.outputMode || 'bundle'}`);
|
||||
console.log(` Bundler: ${bundle.bundler || 'esbuild'}`);
|
||||
if (bundle.includeFiles && bundle.includeFiles.length > 0) {
|
||||
console.log(` Include: ${bundle.includeFiles.join(', ')}`);
|
||||
const display = bundle.includeFiles.map(f => typeof f === 'string' ? f : `${f.from} -> ${f.to}`);
|
||||
console.log(` Include: ${display.join(', ')}`);
|
||||
}
|
||||
console.log('');
|
||||
});
|
||||
@@ -168,7 +169,8 @@ export class InitHandler {
|
||||
console.log(` Mode: ${preset.config.outputMode}`);
|
||||
console.log(` Bundler: ${preset.config.bundler}`);
|
||||
if (preset.config.includeFiles && preset.config.includeFiles.length > 0) {
|
||||
console.log(` Include: ${preset.config.includeFiles.join(', ')}`);
|
||||
const display = preset.config.includeFiles.map(f => typeof f === 'string' ? f : `${f.from} -> ${f.to}`);
|
||||
console.log(` Include: ${display.join(', ')}`);
|
||||
}
|
||||
|
||||
const confirmInteract = new plugins.smartinteract.SmartInteract();
|
||||
@@ -293,14 +295,14 @@ export class InitHandler {
|
||||
/**
|
||||
* Configure files to include
|
||||
*/
|
||||
private async configureIncludeFiles(prefill?: string[]): Promise<string[]> {
|
||||
const includeFiles: string[] = [];
|
||||
private async configureIncludeFiles(prefill?: interfaces.TIncludeFile[]): Promise<interfaces.TIncludeFile[]> {
|
||||
const includeFiles: interfaces.TIncludeFile[] = [];
|
||||
let addMore = true;
|
||||
|
||||
// If we have prefilled values, show them first
|
||||
if (prefill && prefill.length > 0) {
|
||||
console.log('\nPre-configured include patterns:');
|
||||
prefill.forEach((p) => console.log(` - ${p}`));
|
||||
prefill.forEach((p) => console.log(` - ${typeof p === 'string' ? p : `${p.from} -> ${p.to}`}`));
|
||||
|
||||
const keepInteract = new plugins.smartinteract.SmartInteract();
|
||||
keepInteract.addQuestions([
|
||||
|
||||
@@ -22,6 +22,20 @@ export class Base64TsOutput {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a file with a custom serve path
|
||||
*/
|
||||
public async addFileWithServePath(fromPath: string, servePath: string): Promise<void> {
|
||||
const absolutePath = plugins.smartpath.transform.toAbsolute(fromPath, this.cwd) as string;
|
||||
const fileExists = await plugins.fs.file(absolutePath).exists();
|
||||
if (!fileExists) {
|
||||
console.log(`File does not exist: ${absolutePath}`);
|
||||
return;
|
||||
}
|
||||
const content = await plugins.fs.file(absolutePath).read();
|
||||
this.addFile(servePath, content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add files matching a glob pattern
|
||||
*/
|
||||
@@ -56,8 +70,12 @@ export class Base64TsOutput {
|
||||
|
||||
for (const entry of entries) {
|
||||
if (!entry.isDirectory && regex.test(entry.name)) {
|
||||
const fullPath = plugins.path.join(dirPath, entry.path);
|
||||
const relativePath = plugins.path.relative(this.cwd, fullPath);
|
||||
// entry.path may be absolute or relative - handle both cases
|
||||
const fullPath = plugins.path.isAbsolute(entry.path)
|
||||
? entry.path
|
||||
: plugins.path.join(dirPath, entry.path);
|
||||
// Use path relative to pattern's base dir (not cwd) for web serving
|
||||
const relativePath = plugins.path.relative(dirPath, fullPath);
|
||||
const content = await plugins.fs.file(fullPath).read();
|
||||
this.addFile(relativePath, content);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user