feat(core): Integrate Rolldown as optional bundler, migrate filesystem to smartfs, and update bundler/tooling
This commit is contained in:
32
test/test.ts
32
test/test.ts
@@ -3,16 +3,19 @@ import * as tsbundle from '../dist_ts/index.js';
|
||||
import * as path from 'path';
|
||||
import * as fs from 'fs';
|
||||
|
||||
const testBundler = async (bundlerName: 'esbuild' | 'rolldown' | 'rspack', mode: 'test' | 'production') => {
|
||||
const testBundler = async (
|
||||
bundlerName: 'esbuild' | 'rolldown' | 'rspack',
|
||||
mode: 'test' | 'production',
|
||||
) => {
|
||||
const outputFile = `./dist_manual/${bundlerName}-${mode}.js`;
|
||||
const testDir = path.join(process.cwd(), 'test');
|
||||
|
||||
|
||||
// Clean up output directory
|
||||
const outputDir = path.join(testDir, 'dist_manual');
|
||||
if (!fs.existsSync(outputDir)) {
|
||||
fs.mkdirSync(outputDir, { recursive: true });
|
||||
}
|
||||
|
||||
|
||||
// Clean up output file if exists
|
||||
const outputPath = path.join(testDir, outputFile);
|
||||
if (fs.existsSync(outputPath)) {
|
||||
@@ -20,19 +23,14 @@ const testBundler = async (bundlerName: 'esbuild' | 'rolldown' | 'rspack', mode:
|
||||
}
|
||||
|
||||
const tsbundleInstance = new tsbundle.TsBundle();
|
||||
await tsbundleInstance.build(
|
||||
testDir,
|
||||
'./ts_web/index.ts',
|
||||
outputFile,
|
||||
{
|
||||
bundler: bundlerName,
|
||||
production: mode === 'production'
|
||||
}
|
||||
);
|
||||
await tsbundleInstance.build(testDir, './ts_web/index.ts', outputFile, {
|
||||
bundler: bundlerName,
|
||||
production: mode === 'production',
|
||||
});
|
||||
|
||||
// Verify output file was created
|
||||
expect(fs.existsSync(outputPath)).toBeTrue();
|
||||
|
||||
|
||||
console.log(`✅ ${bundlerName} ${mode} mode: success`);
|
||||
};
|
||||
|
||||
@@ -69,7 +67,7 @@ tap.test('should show bundle size comparison', async () => {
|
||||
const sizes: Record<string, { test: number; production: number }> = {
|
||||
esbuild: { test: 0, production: 0 },
|
||||
rolldown: { test: 0, production: 0 },
|
||||
rspack: { test: 0, production: 0 }
|
||||
rspack: { test: 0, production: 0 },
|
||||
};
|
||||
|
||||
for (const bundler of ['esbuild', 'rolldown', 'rspack'] as const) {
|
||||
@@ -89,10 +87,12 @@ tap.test('should show bundle size comparison', async () => {
|
||||
for (const bundler of ['esbuild', 'rolldown', 'rspack'] as const) {
|
||||
const testSize = (sizes[bundler].test / 1024).toFixed(1) + ' KB';
|
||||
const prodSize = (sizes[bundler].production / 1024).toFixed(1) + ' KB';
|
||||
console.log(`│ ${bundler.padEnd(11)} │ ${testSize.padEnd(10)} │ ${prodSize.padEnd(12)} │`);
|
||||
console.log(
|
||||
`│ ${bundler.padEnd(11)} │ ${testSize.padEnd(10)} │ ${prodSize.padEnd(12)} │`,
|
||||
);
|
||||
}
|
||||
console.log('└─────────────┴────────────┴──────────────┘');
|
||||
|
||||
|
||||
// Verify all sizes are reasonable
|
||||
for (const bundler of ['esbuild', 'rolldown', 'rspack'] as const) {
|
||||
expect(sizes[bundler].test).toBeGreaterThan(0);
|
||||
|
||||
Reference in New Issue
Block a user