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

@@ -3,38 +3,66 @@ import * as paths from '../paths.js';
export class AssetsHandler {
public defaultFromDirPath: string = plugins.path.join(paths.cwd, './assets');
public defaultToDirPath: string = plugins.path.join(paths.cwd, './dist_serve/assets');
public defaultToDirPath: string = plugins.path.join(
paths.cwd,
'./dist_serve/assets',
);
public async ensureAssetsDir() {
const assetsDirExists = await plugins.smartfile.fs.isDirectory(this.defaultFromDirPath);
if (!assetsDirExists) {
await plugins.smartfile.fs.ensureDir(this.defaultFromDirPath);
const dirExists = await plugins.fs
.directory(this.defaultFromDirPath)
.exists();
if (!dirExists) {
await plugins.fs.directory(this.defaultFromDirPath).create();
console.log(`created assets directory at ${this.defaultFromDirPath}`);
}
}
// copies the assets directory recursively
private async copyDirectoryRecursive(from: string, to: string) {
const entries = await plugins.fs.directory(from).recursive().list();
await plugins.fs.directory(to).create();
for (const entry of entries) {
const fromPath = plugins.path.join(from, entry.path);
const toPath = plugins.path.join(to, entry.path);
if (entry.isDirectory) {
await plugins.fs.directory(toPath).create();
} else {
const toDir = plugins.path.dirname(toPath);
await plugins.fs.directory(toDir).create();
await plugins.fs.file(fromPath).copy(toPath);
}
}
}
// copies the html
public async processAssets(optionsArg?: {
from?: string;
to?: string;
}) {
public async processAssets(optionsArg?: { from?: string; to?: string }) {
// lets assemble the options
optionsArg = {
... {
...{
from: this.defaultFromDirPath,
to: this.defaultToDirPath,
},
...(optionsArg || {})
...(optionsArg || {}),
};
await this.ensureAssetsDir();
optionsArg.from = plugins.smartpath.transform.toAbsolute(
optionsArg.from,
paths.cwd,
) as string;
optionsArg.to = plugins.smartpath.transform.toAbsolute(
optionsArg.to,
paths.cwd,
) as string;
// lets clean the target directory
const toExists = await plugins.fs.directory(optionsArg.to).exists();
if (toExists) {
await plugins.fs.directory(optionsArg.to).delete();
}
await this.ensureAssetsDir()
optionsArg.from = plugins.smartpath.transform.toAbsolute(optionsArg.from, paths.cwd) as string;
optionsArg.to = plugins.smartpath.transform.toAbsolute(optionsArg.to, paths.cwd) as string;
// lets clean theh target directory
await plugins.smartfile.fs.ensureEmptyDir(optionsArg.to);
plugins.smartfile.fs.copySync(optionsArg.from, optionsArg.to, {
replaceTargetDir: true,
});
await this.copyDirectoryRecursive(optionsArg.from, optionsArg.to);
}
}
}