feat(core): Integrate Rolldown as optional bundler, migrate filesystem to smartfs, and update bundler/tooling

This commit is contained in:
2025-11-23 13:12:17 +00:00
parent 1bb05bfd2e
commit cd53bdb6f4
32 changed files with 3152 additions and 5142 deletions

View File

@@ -11,14 +11,23 @@ export class TsBundleProcess {
public async getAliases() {
try {
const aliasObject: Record<string, string> = {};
const localTsConfig = plugins.smartfile.fs.toObjectSync(
plugins.path.join(paths.cwd, 'tsconfig.json')
);
if (localTsConfig.compilerOptions && localTsConfig.compilerOptions.paths) {
const tsconfigPath = plugins.path.join(paths.cwd, 'tsconfig.json');
const tsconfigContent = await plugins.fs
.file(tsconfigPath)
.encoding('utf8')
.read();
const localTsConfig = JSON.parse(tsconfigContent as string);
if (
localTsConfig.compilerOptions &&
localTsConfig.compilerOptions.paths
) {
for (const alias of Object.keys(localTsConfig.compilerOptions.paths)) {
const aliasPath = localTsConfig.compilerOptions.paths[alias][0];
// Convert TypeScript path to absolute path for rspack
aliasObject[alias.replace('/*', '')] = plugins.path.resolve(paths.cwd, aliasPath.replace('/*', ''));
aliasObject[alias.replace('/*', '')] = plugins.path.resolve(
paths.cwd,
aliasPath.replace('/*', ''),
);
}
}
return aliasObject;
@@ -34,7 +43,7 @@ export class TsBundleProcess {
const aliases = await this.getAliases();
const outputDir = plugins.path.dirname(toArg);
const outputFilename = plugins.path.basename(toArg);
const config = {
mode: 'development' as const,
entry: {
@@ -96,13 +105,15 @@ export class TsBundleProcess {
return;
}
console.log(stats.toString({
colors: true,
modules: false,
children: false,
chunks: false,
chunkModules: false,
}));
console.log(
stats.toString({
colors: true,
modules: false,
children: false,
chunks: false,
chunkModules: false,
}),
);
resolve(undefined);
});
@@ -116,11 +127,11 @@ export class TsBundleProcess {
console.log('rspack specific:');
console.log(`from: ${fromArg}`);
console.log(`to: ${toArg}`);
const aliases = await this.getAliases();
const outputDir = plugins.path.dirname(toArg);
const outputFilename = plugins.path.basename(toArg);
const config = {
mode: 'production' as const,
entry: {
@@ -192,13 +203,15 @@ export class TsBundleProcess {
return;
}
console.log(stats.toString({
colors: true,
modules: false,
children: false,
chunks: false,
chunkModules: false,
}));
console.log(
stats.toString({
colors: true,
modules: false,
children: false,
chunks: false,
chunkModules: false,
}),
);
resolve(undefined);
});
@@ -209,7 +222,7 @@ export class TsBundleProcess {
const run = async () => {
console.log('running spawned compilation process');
const transportOptions: interfaces.IEnvTransportOptions = JSON.parse(
process.env.transportOptions
process.env.transportOptions,
);
console.log('=======> RSPACK');
console.log(transportOptions);
@@ -219,18 +232,30 @@ const run = async () => {
if (transportOptions.mode === 'test') {
console.log('building for test:');
await tsbundleProcessInstance.buildTest(
plugins.smartpath.transform.makeAbsolute(transportOptions.from, process.cwd()),
plugins.smartpath.transform.makeAbsolute(transportOptions.to, process.cwd()),
transportOptions.argv
plugins.smartpath.transform.makeAbsolute(
transportOptions.from,
process.cwd(),
),
plugins.smartpath.transform.makeAbsolute(
transportOptions.to,
process.cwd(),
),
transportOptions.argv,
);
} else {
console.log('building for production:');
await tsbundleProcessInstance.buildProduction(
plugins.smartpath.transform.makeAbsolute(transportOptions.from, process.cwd()),
plugins.smartpath.transform.makeAbsolute(transportOptions.to, process.cwd()),
transportOptions.argv
plugins.smartpath.transform.makeAbsolute(
transportOptions.from,
process.cwd(),
),
plugins.smartpath.transform.makeAbsolute(
transportOptions.to,
process.cwd(),
),
transportOptions.argv,
);
}
};
run();
run();