diff --git a/changelog.md b/changelog.md index 0ced316..953f9ba 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,13 @@ # 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) migrate project configuration to smartconfig.json and update bundler dependencies diff --git a/package.json b/package.json index 9c803f3..f3262e6 100644 --- a/package.json +++ b/package.json @@ -9,8 +9,8 @@ "author": "Lossless GmbH", "license": "MIT", "scripts": { - "test": "npm run build && (tstest test/ --verbose)", - "build": "(tsbuild --web --allowimplicitany)", + "test": "pnpm run build && (tstest test/ --verbose)", + "build": "(tsbuild --web)", "buildDocs": "tsdoc" }, "bin": { diff --git a/test/test.ts b/test/test.ts index cff5d37..07c545b 100644 --- a/test/test.ts +++ b/test/test.ts @@ -1,5 +1,6 @@ import { expect, tap } from '@git.zone/tstest/tapbundle'; import * as tsbundle from '../dist_ts/index.js'; +import { CustomBundleHandler } from '../dist_ts/mod_custom/index.js'; import * as path from 'path'; import * as fs from 'fs'; @@ -61,6 +62,30 @@ tap.test('should bundle with rspack in production mode', async () => { 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 tap.test('should show bundle size comparison', async () => { const testDir = path.join(process.cwd(), 'test'); diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index 91e36df..ea5e10c 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.10.0', + version: '2.10.1', description: 'a multi-bundler tool supporting esbuild, rolldown, and rspack for painless bundling of web projects' } diff --git a/ts/mod_custom/index.ts b/ts/mod_custom/index.ts index dfe005c..1d135ad 100644 --- a/ts/mod_custom/index.ts +++ b/ts/mod_custom/index.ts @@ -9,7 +9,7 @@ const TEMP_DIR = '.nogit/tsbundle-temp'; export class CustomBundleHandler { private cwd: string; - private config: interfaces.ITsbundleConfig; + private config!: interfaces.ITsbundleConfig; constructor(cwd: string = paths.cwd) { this.cwd = cwd; @@ -54,7 +54,7 @@ export class CustomBundleHandler { // Determine temp output path 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 await plugins.fs.directory(tempDir).create(); @@ -88,6 +88,11 @@ export class CustomBundleHandler { if (tempFileExists) { 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(); + } } /**