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
+25
View File
@@ -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');