fix(mod_custom): make base64ts bundle output deterministic and clean up generated temp sourcemaps
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
+2
-2
@@ -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": {
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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'
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user