fix(mod_custom): make base64ts bundle output deterministic and clean up generated temp sourcemaps

This commit is contained in:
2026-04-30 12:52:26 +00:00
parent 7f5de8797c
commit 3b2e0bebcd
5 changed files with 43 additions and 5 deletions
+8
View File
@@ -1,5 +1,13 @@
# Changelog # Changelog
## 2026-04-30 - 2.10.1 - fix(mod_custom)
make base64ts bundle output deterministic and clean up generated temp sourcemaps
- Use a stable temporary bundle filename instead of a timestamp-based name so repeated base64ts builds produce identical output.
- Delete the generated temporary sourcemap alongside the temp bundle to avoid leftover build artifacts.
- Add a test covering deterministic base64ts output generation.
- Update package scripts to use pnpm for tests and remove the allowimplicitany build flag.
## 2026-03-24 - 2.10.0 - feat(config) ## 2026-03-24 - 2.10.0 - feat(config)
migrate project configuration to smartconfig.json and update bundler dependencies migrate project configuration to smartconfig.json and update bundler dependencies
+2 -2
View File
@@ -9,8 +9,8 @@
"author": "Lossless GmbH", "author": "Lossless GmbH",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"test": "npm run build && (tstest test/ --verbose)", "test": "pnpm run build && (tstest test/ --verbose)",
"build": "(tsbuild --web --allowimplicitany)", "build": "(tsbuild --web)",
"buildDocs": "tsdoc" "buildDocs": "tsdoc"
}, },
"bin": { "bin": {
+25
View File
@@ -1,5 +1,6 @@
import { expect, tap } from '@git.zone/tstest/tapbundle'; import { expect, tap } from '@git.zone/tstest/tapbundle';
import * as tsbundle from '../dist_ts/index.js'; import * as tsbundle from '../dist_ts/index.js';
import { CustomBundleHandler } from '../dist_ts/mod_custom/index.js';
import * as path from 'path'; import * as path from 'path';
import * as fs from 'fs'; import * as fs from 'fs';
@@ -61,6 +62,30 @@ tap.test('should bundle with rspack in production mode', async () => {
await testBundler('rspack', 'production'); await testBundler('rspack', 'production');
}); });
tap.test('should generate deterministic base64ts output', async () => {
const testDir = path.join(process.cwd(), 'test');
const outputPath = path.join(testDir, 'dist_manual/base64-output.ts');
const bundleConfig = {
from: './ts_web/index.ts',
to: './dist_manual/base64-output.ts',
outputMode: 'base64ts' as const,
bundler: 'esbuild' as const,
};
const handler = new CustomBundleHandler(testDir);
if (fs.existsSync(outputPath)) {
fs.rmSync(outputPath, { force: true });
}
await handler.processSingleBundle(bundleConfig);
const firstOutput = fs.readFileSync(outputPath, 'utf8');
await handler.processSingleBundle(bundleConfig);
const secondOutput = fs.readFileSync(outputPath, 'utf8');
expect(secondOutput).toEqual(firstOutput);
});
// Test size comparison // Test size comparison
tap.test('should show bundle size comparison', async () => { tap.test('should show bundle size comparison', async () => {
const testDir = path.join(process.cwd(), 'test'); const testDir = path.join(process.cwd(), 'test');
+1 -1
View File
@@ -3,6 +3,6 @@
*/ */
export const commitinfo = { export const commitinfo = {
name: '@git.zone/tsbundle', name: '@git.zone/tsbundle',
version: '2.10.0', version: '2.10.1',
description: 'a multi-bundler tool supporting esbuild, rolldown, and rspack for painless bundling of web projects' description: 'a multi-bundler tool supporting esbuild, rolldown, and rspack for painless bundling of web projects'
} }
+7 -2
View File
@@ -9,7 +9,7 @@ const TEMP_DIR = '.nogit/tsbundle-temp';
export class CustomBundleHandler { export class CustomBundleHandler {
private cwd: string; private cwd: string;
private config: interfaces.ITsbundleConfig; private config!: interfaces.ITsbundleConfig;
constructor(cwd: string = paths.cwd) { constructor(cwd: string = paths.cwd) {
this.cwd = cwd; this.cwd = cwd;
@@ -54,7 +54,7 @@ export class CustomBundleHandler {
// Determine temp output path // Determine temp output path
const tempDir = plugins.path.join(this.cwd, TEMP_DIR); const tempDir = plugins.path.join(this.cwd, TEMP_DIR);
const tempBundlePath = plugins.path.join(tempDir, `bundle-${Date.now()}.js`); const tempBundlePath = plugins.path.join(tempDir, 'bundle.js');
// Ensure temp directory exists // Ensure temp directory exists
await plugins.fs.directory(tempDir).create(); await plugins.fs.directory(tempDir).create();
@@ -88,6 +88,11 @@ export class CustomBundleHandler {
if (tempFileExists) { if (tempFileExists) {
await plugins.fs.file(tempBundlePath).delete(); await plugins.fs.file(tempBundlePath).delete();
} }
const tempSourceMapPath = `${tempBundlePath}.map`;
const tempSourceMapExists = await plugins.fs.file(tempSourceMapPath).exists();
if (tempSourceMapExists) {
await plugins.fs.file(tempSourceMapPath).delete();
}
} }
/** /**