2022-03-14 15:32:12 +00:00
|
|
|
import * as plugins from './tsbundle.plugins.js';
|
|
|
|
import { logger } from './tsbundle.logging.js';
|
2019-06-16 15:02:38 +00:00
|
|
|
|
|
|
|
export class TsBundle {
|
2022-03-15 12:01:18 +00:00
|
|
|
public async buildTest (
|
2022-03-14 15:32:12 +00:00
|
|
|
cwdArg: string,
|
|
|
|
fromArg: string,
|
|
|
|
toArg: string,
|
2022-03-15 12:01:18 +00:00
|
|
|
bundlerArg: 'rollup' | 'parcel',
|
|
|
|
argvArg: any
|
2022-03-14 15:32:12 +00:00
|
|
|
) {
|
2021-07-23 13:45:23 +00:00
|
|
|
const done = plugins.smartpromise.defer();
|
2022-03-14 15:32:12 +00:00
|
|
|
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,
|
2022-03-15 12:01:18 +00:00
|
|
|
tsbundleArgv: argvArg,
|
2022-03-14 15:32:12 +00:00
|
|
|
},
|
2021-07-23 13:45:23 +00:00
|
|
|
}
|
2022-03-14 15:32:12 +00:00
|
|
|
);
|
2021-07-23 13:45:23 +00:00
|
|
|
const childProcess = await threadsimple.start();
|
|
|
|
childProcess.on('exit', (status) => {
|
|
|
|
done.resolve();
|
2022-03-14 15:32:12 +00:00
|
|
|
});
|
2021-07-23 13:45:23 +00:00
|
|
|
await done.promise;
|
2022-03-14 15:32:12 +00:00
|
|
|
}
|
|
|
|
|
2022-03-15 12:01:18 +00:00
|
|
|
public async buildProduction (
|
|
|
|
cwdArg: string,
|
|
|
|
fromArg: string,
|
|
|
|
toArg: string,
|
|
|
|
bundlerArg: 'rollup' | 'parcel',
|
|
|
|
argvArg: any
|
|
|
|
) {
|
2021-07-23 13:45:23 +00:00
|
|
|
const done = plugins.smartpromise.defer();
|
2022-03-14 15:32:12 +00:00
|
|
|
const threadsimple = new plugins.smartspawn.ThreadSimple(
|
|
|
|
plugins.path.join(plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url), './tsbundle.class.tsbundleprocess.js'),
|
|
|
|
[],
|
|
|
|
{
|
|
|
|
env: {
|
|
|
|
...process.env,
|
|
|
|
tsbundleMode: 'production',
|
|
|
|
tsbundleCwd: cwdArg,
|
|
|
|
tsbundleFrom: fromArg,
|
|
|
|
tsbundleTo: toArg,
|
2022-03-15 12:01:18 +00:00
|
|
|
tsbundleBundler: bundlerArg,
|
|
|
|
tsbundleArgv: argvArg,
|
2022-03-14 15:32:12 +00:00
|
|
|
},
|
2021-07-23 13:45:23 +00:00
|
|
|
}
|
2022-03-14 15:32:12 +00:00
|
|
|
);
|
2021-07-23 13:45:23 +00:00
|
|
|
const childProcess = await threadsimple.start();
|
|
|
|
childProcess.on('exit', (status) => {
|
|
|
|
done.resolve();
|
2022-03-14 15:32:12 +00:00
|
|
|
});
|
2021-07-23 13:45:23 +00:00
|
|
|
await done.promise;
|
2022-03-14 15:32:12 +00:00
|
|
|
}
|
2019-06-16 15:02:38 +00:00
|
|
|
}
|