fix(core): update

This commit is contained in:
2022-03-16 00:21:05 +01:00
parent d5753019cf
commit 63d35e2ce8
19 changed files with 817 additions and 285 deletions

View File

@ -1,63 +1,47 @@
import * as plugins from './tsbundle.plugins.js';
import * as plugins from './plugins.js';
import * as interfaces from './interfaces/index.js';
import { logger } from './tsbundle.logging.js';
export class TsBundle {
public async buildTest(
cwdArg: string,
fromArg: string,
toArg: string,
bundlerArg: 'rollup' | 'parcel',
argvArg: any
) {
const done = plugins.smartpromise.defer();
const threadsimple = new plugins.smartspawn.ThreadSimple(
plugins.path.join(
plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url),
'./tsbundle.class.tsbundleprocess.js'
),
[],
{
env: {
...process.env,
tsbundleMode: 'test',
tsbundleCwd: cwdArg,
tsbundleFrom: fromArg,
tsbundleTo: toArg,
tsbundleBundler: bundlerArg,
tsbundleArgv: argvArg ? JSON.stringify(argvArg) : '{}',
},
}
);
const childProcess = await threadsimple.start();
childProcess.on('exit', (status) => {
done.resolve();
});
await done.promise;
}
public async buildProduction(
public async build(
cwdArg: string,
fromArg: string,
toArg: string,
bundlerArg: 'rollup' | 'parcel',
argvArg: any
fromArg: string = './ts_web/index.ts',
toArg: string = './dist_bundle/bundle.js',
argvArg: interfaces.ICliOptions
) {
const done = plugins.smartpromise.defer();
const getBundlerPath = () => {
if (argvArg.bundler === 'esbuild') {
return './mod_esbuild/index.child.js'
}
if (argvArg.bundler === 'parcel') {
return './mod_parcel/index.child.js'
}
if (argvArg.bundler === 'rollup') {
return './mod_rollup/index.child.js'
}
return './mod_esbuild/index.child.js'
}
const transportOptions: interfaces.IEnvTransportOptions = {
cwd: cwdArg,
from: fromArg,
to: toArg,
mode: argvArg && argvArg.production ? 'production' : 'test',
argv: argvArg ? argvArg : {
bundler: 'esbuild'
}
}
const threadsimple = new plugins.smartspawn.ThreadSimple(
plugins.path.join(
plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url),
'./tsbundle.class.tsbundleprocess.js'
getBundlerPath()
),
[],
{
env: {
...process.env,
tsbundleMode: 'production',
tsbundleCwd: cwdArg,
tsbundleFrom: fromArg,
tsbundleTo: toArg,
tsbundleBundler: bundlerArg,
tsbundleArgv: argvArg ? JSON.stringify(argvArg) : '{}',
transportOptions: JSON.stringify(transportOptions),
},
}
);