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