feat(core): Integrate Rolldown as optional bundler, migrate filesystem to smartfs, and update bundler/tooling
This commit is contained in:
@@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@git.zone/tsbundle',
|
||||
version: '2.5.2',
|
||||
version: '2.6.0',
|
||||
description: 'a multi-bundler tool supporting esbuild, rolldown, and rspack for painless bundling of web projects'
|
||||
}
|
||||
|
||||
@@ -2,13 +2,13 @@ export interface ICliOptions {
|
||||
commonjs?: boolean;
|
||||
skiplibcheck?: boolean;
|
||||
production?: boolean;
|
||||
bundler: 'esbuild' | 'rolldown' | 'rspack'
|
||||
bundler: 'esbuild' | 'rolldown' | 'rspack';
|
||||
}
|
||||
|
||||
export interface IEnvTransportOptions {
|
||||
cwd: string;
|
||||
from: string;
|
||||
to: string;
|
||||
mode: 'test' | 'production',
|
||||
argv: ICliOptions
|
||||
mode: 'test' | 'production';
|
||||
argv: ICliOptions;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,10 +11,16 @@ 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];
|
||||
aliasObject[alias] = aliasPath;
|
||||
@@ -75,7 +81,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('=======> ESBUILD');
|
||||
console.log(transportOptions);
|
||||
@@ -85,16 +91,28 @@ const run = async () => {
|
||||
if (transportOptions.mode === 'test') {
|
||||
console.log('building for test:');
|
||||
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:');
|
||||
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,
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2,6 +2,4 @@ export * from '../plugins.js';
|
||||
|
||||
import esbuild from 'esbuild';
|
||||
|
||||
export {
|
||||
esbuild
|
||||
}
|
||||
export { esbuild };
|
||||
|
||||
@@ -2,11 +2,17 @@ import * as plugins from './plugins.js';
|
||||
import * as paths from '../paths.js';
|
||||
|
||||
export class HtmlHandler {
|
||||
public defaultFromPath: string = plugins.path.join(paths.htmlDir, 'index.html');
|
||||
public defaultToPath: string = plugins.path.join(paths.distServeDir, 'index.html');
|
||||
public defaultFromPath: string = plugins.path.join(
|
||||
paths.htmlDir,
|
||||
'index.html',
|
||||
);
|
||||
public defaultToPath: string = plugins.path.join(
|
||||
paths.distServeDir,
|
||||
'index.html',
|
||||
);
|
||||
|
||||
public async checkIfExists() {
|
||||
return plugins.smartfile.fs.fileExists(this.defaultFromPath);
|
||||
return await plugins.fs.file(this.defaultFromPath).exists();
|
||||
}
|
||||
|
||||
// copies the html
|
||||
@@ -16,19 +22,28 @@ export class HtmlHandler {
|
||||
minify?: boolean;
|
||||
}) {
|
||||
optionsArg = {
|
||||
... {
|
||||
...{
|
||||
from: this.defaultFromPath,
|
||||
to: this.defaultToPath,
|
||||
minify: false,
|
||||
},
|
||||
...optionsArg
|
||||
}
|
||||
...optionsArg,
|
||||
};
|
||||
if (await this.checkIfExists()) {
|
||||
console.log(`${optionsArg.from} replaces file at ${optionsArg.to}`);
|
||||
}
|
||||
optionsArg.from = plugins.smartpath.transform.toAbsolute(optionsArg.from, paths.cwd) as string;
|
||||
optionsArg.to = plugins.smartpath.transform.toAbsolute(optionsArg.to, paths.cwd) as string;
|
||||
let fileString = plugins.smartfile.fs.toStringSync(optionsArg.from);
|
||||
optionsArg.from = plugins.smartpath.transform.toAbsolute(
|
||||
optionsArg.from,
|
||||
paths.cwd,
|
||||
) as string;
|
||||
optionsArg.to = plugins.smartpath.transform.toAbsolute(
|
||||
optionsArg.to,
|
||||
paths.cwd,
|
||||
) as string;
|
||||
let fileString = (await plugins.fs
|
||||
.file(optionsArg.from)
|
||||
.encoding('utf8')
|
||||
.read()) as string;
|
||||
if (optionsArg.minify) {
|
||||
fileString = plugins.htmlMinifier.minify(fileString, {
|
||||
minifyCSS: true,
|
||||
@@ -41,7 +56,9 @@ export class HtmlHandler {
|
||||
removeComments: true,
|
||||
});
|
||||
}
|
||||
await plugins.smartfile.memory.toFs(fileString, optionsArg.to);
|
||||
const toDir = plugins.path.dirname(optionsArg.to);
|
||||
await plugins.fs.directory(toDir).create();
|
||||
await plugins.fs.file(optionsArg.to).encoding('utf8').write(fileString);
|
||||
console.log(`html processing succeeded!`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,4 @@ export * from '../plugins.js';
|
||||
|
||||
import * as htmlMinifier from 'html-minifier';
|
||||
|
||||
export {
|
||||
htmlMinifier
|
||||
}
|
||||
export { htmlMinifier };
|
||||
|
||||
@@ -11,10 +11,16 @@ 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];
|
||||
aliasObject[alias] = aliasPath;
|
||||
@@ -38,10 +44,10 @@ export class TsBundleProcess {
|
||||
tsconfigFilename: paths.tsconfigPath,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
const outputDir = plugins.path.dirname(toArg);
|
||||
const outputFilename = plugins.path.basename(toArg);
|
||||
|
||||
|
||||
await result.write({
|
||||
dir: outputDir,
|
||||
entryFileNames: outputFilename,
|
||||
@@ -59,21 +65,18 @@ export class TsBundleProcess {
|
||||
console.log('rolldown specific:');
|
||||
console.log(`from: ${fromArg}`);
|
||||
console.log(`to: ${toArg}`);
|
||||
|
||||
|
||||
const result = await plugins.rolldown({
|
||||
input: fromArg,
|
||||
resolve: {
|
||||
alias: await this.getAliases(),
|
||||
tsconfigFilename: paths.tsconfigPath,
|
||||
},
|
||||
experimental: {
|
||||
enableComposingJsPlugins: true,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
const outputDir = plugins.path.dirname(toArg);
|
||||
const outputFilename = plugins.path.basename(toArg);
|
||||
|
||||
|
||||
await result.write({
|
||||
dir: outputDir,
|
||||
entryFileNames: outputFilename,
|
||||
@@ -88,7 +91,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('=======> ROLLDOWN');
|
||||
console.log(transportOptions);
|
||||
@@ -98,18 +101,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();
|
||||
|
||||
@@ -2,4 +2,4 @@ export * from '../plugins.js';
|
||||
|
||||
import { rolldown } from 'rolldown';
|
||||
|
||||
export { rolldown }
|
||||
export { rolldown };
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -2,4 +2,4 @@ export * from '../plugins.js';
|
||||
|
||||
import { rspack } from '@rspack/core';
|
||||
|
||||
export { rspack }
|
||||
export { rspack };
|
||||
|
||||
@@ -3,7 +3,7 @@ import * as plugins from './plugins.js';
|
||||
export const cwd = process.cwd();
|
||||
export const packageDir = plugins.path.join(
|
||||
plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url),
|
||||
'../'
|
||||
'../',
|
||||
);
|
||||
export const htmlDir = plugins.path.join(cwd, './html');
|
||||
export const distServeDir = plugins.path.join(cwd, './dist_serve');
|
||||
|
||||
@@ -5,7 +5,7 @@ export { path };
|
||||
|
||||
// pushrocks scope
|
||||
import * as smartcli from '@push.rocks/smartcli';
|
||||
import * as smartfile from '@push.rocks/smartfile';
|
||||
import * as smartfs from '@push.rocks/smartfs';
|
||||
import * as smartlog from '@push.rocks/smartlog';
|
||||
import * as smartlogDestinationLocal from '@push.rocks/smartlog-destination-local';
|
||||
import * as smartpath from '@push.rocks/smartpath';
|
||||
@@ -14,10 +14,13 @@ import * as smartspawn from '@push.rocks/smartspawn';
|
||||
|
||||
export {
|
||||
smartcli,
|
||||
smartfile,
|
||||
smartfs,
|
||||
smartlog,
|
||||
smartlogDestinationLocal,
|
||||
smartpath,
|
||||
smartpromise,
|
||||
smartspawn,
|
||||
};
|
||||
|
||||
// Create a shared SmartFs instance using Node provider
|
||||
export const fs = new smartfs.SmartFs(new smartfs.SmartFsProviderNode());
|
||||
|
||||
@@ -3,12 +3,11 @@ import * as interfaces from './interfaces/index.js';
|
||||
import { logger } from './tsbundle.logging.js';
|
||||
|
||||
export class TsBundle {
|
||||
|
||||
public async build(
|
||||
cwdArg: string,
|
||||
fromArg: string = './ts_web/index.ts',
|
||||
toArg: string = './dist_bundle/bundle.js',
|
||||
argvArg: interfaces.ICliOptions
|
||||
argvArg: interfaces.ICliOptions,
|
||||
) {
|
||||
const done = plugins.smartpromise.defer();
|
||||
const getBundlerPath = () => {
|
||||
@@ -21,20 +20,20 @@ export class TsBundle {
|
||||
default:
|
||||
return './mod_esbuild/index.child.js';
|
||||
}
|
||||
}
|
||||
};
|
||||
const transportOptions: interfaces.IEnvTransportOptions = {
|
||||
cwd: cwdArg,
|
||||
from: fromArg,
|
||||
to: toArg,
|
||||
mode: argvArg && argvArg.production ? 'production' : 'test',
|
||||
argv: {
|
||||
...argvArg
|
||||
}
|
||||
}
|
||||
argv: {
|
||||
...argvArg,
|
||||
},
|
||||
};
|
||||
const threadsimple = new plugins.smartspawn.ThreadSimple(
|
||||
plugins.path.join(
|
||||
plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url),
|
||||
getBundlerPath()
|
||||
getBundlerPath(),
|
||||
),
|
||||
[],
|
||||
{
|
||||
@@ -42,7 +41,7 @@ export class TsBundle {
|
||||
...process.env,
|
||||
transportOptions: JSON.stringify(transportOptions),
|
||||
},
|
||||
}
|
||||
},
|
||||
);
|
||||
const childProcess = await threadsimple.start();
|
||||
childProcess.on('exit', (status) => {
|
||||
|
||||
@@ -18,7 +18,7 @@ export const runCli = async () => {
|
||||
process.cwd(),
|
||||
'./ts_web/index.ts',
|
||||
'./dist_bundle/bundle.js',
|
||||
argvArg
|
||||
argvArg,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -29,7 +29,7 @@ export const runCli = async () => {
|
||||
process.cwd(),
|
||||
'./ts/index.ts',
|
||||
'./dist_bundle/bundle.js',
|
||||
argvArg
|
||||
argvArg,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -42,9 +42,18 @@ export const runCli = async () => {
|
||||
process.cwd(),
|
||||
'./ts_web/index.ts',
|
||||
'./dist_serve/bundle.js',
|
||||
argvArg
|
||||
argvArg,
|
||||
);
|
||||
const htmlFiles = await plugins.smartfile.fs.listFiles('./html', /\.html/);
|
||||
const htmlDirPath = plugins.path.join(process.cwd(), './html');
|
||||
let htmlFiles: string[] = [];
|
||||
const htmlDirExists = await plugins.fs.directory(htmlDirPath).exists();
|
||||
if (htmlDirExists) {
|
||||
const entries = await plugins.fs
|
||||
.directory(htmlDirPath)
|
||||
.filter(/\.html$/)
|
||||
.list();
|
||||
htmlFiles = entries.map((entry) => entry.path);
|
||||
}
|
||||
for (const htmlFile of htmlFiles) {
|
||||
await htmlHandler.processHtml({
|
||||
from: `./html/${htmlFile}`,
|
||||
|
||||
@@ -12,4 +12,6 @@ export const logger = new plugins.smartlog.Smartlog({
|
||||
minimumLogLevel: 'silly',
|
||||
});
|
||||
|
||||
logger.addLogDestination(new plugins.smartlogDestinationLocal.DestinationLocal());
|
||||
logger.addLogDestination(
|
||||
new plugins.smartlogDestinationLocal.DestinationLocal(),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user