fix(core): update
This commit is contained in:
parent
687b83bafd
commit
cf9ca73cd8
@ -2,11 +2,12 @@ import * as plugins from './tsbundle.plugins.js';
|
||||
import { logger } from './tsbundle.logging.js';
|
||||
|
||||
export class TsBundle {
|
||||
public async buildTest(
|
||||
public async buildTest (
|
||||
cwdArg: string,
|
||||
fromArg: string,
|
||||
toArg: string,
|
||||
bundlerArg: 'rollup' | 'parcel'
|
||||
bundlerArg: 'rollup' | 'parcel',
|
||||
argvArg: any
|
||||
) {
|
||||
const done = plugins.smartpromise.defer();
|
||||
const threadsimple = new plugins.smartspawn.ThreadSimple(
|
||||
@ -20,6 +21,7 @@ export class TsBundle {
|
||||
tsbundleFrom: fromArg,
|
||||
tsbundleTo: toArg,
|
||||
tsbundleBundler: bundlerArg,
|
||||
tsbundleArgv: argvArg,
|
||||
},
|
||||
}
|
||||
);
|
||||
@ -30,7 +32,13 @@ export class TsBundle {
|
||||
await done.promise;
|
||||
}
|
||||
|
||||
public async buildProduction(cwdArg: string, fromArg: string, toArg: string) {
|
||||
public async buildProduction (
|
||||
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'),
|
||||
@ -42,6 +50,8 @@ export class TsBundle {
|
||||
tsbundleCwd: cwdArg,
|
||||
tsbundleFrom: fromArg,
|
||||
tsbundleTo: toArg,
|
||||
tsbundleBundler: bundlerArg,
|
||||
tsbundleArgv: argvArg,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
@ -7,7 +7,8 @@ export class TsBundleProcess {
|
||||
*/
|
||||
public getBaseOptions(
|
||||
fromArg: string = `ts_web/index.ts`,
|
||||
toArg: string = 'dist_bundle/bundle.js'
|
||||
toArg: string = 'dist_bundle/bundle.js',
|
||||
argvArg: any
|
||||
) {
|
||||
logger.log('info', `from: ${fromArg}`);
|
||||
logger.log('info', `to: ${toArg}`);
|
||||
@ -39,8 +40,20 @@ export class TsBundleProcess {
|
||||
lib: ['dom'],
|
||||
noImplicitAny: false,
|
||||
target: 'es2020',
|
||||
module: 'es2020',
|
||||
moduleResolution: 'node12',
|
||||
allowSyntheticDefaultImports: true,
|
||||
importsNotUsedAsValues: 'preserve',
|
||||
...argvArg && argvArg.skiplibcheck ? {
|
||||
skipLibCheck: true
|
||||
} : {},
|
||||
...argvArg && argvArg.allowimplicitany ? {
|
||||
noImplicitAny: false
|
||||
} : {},
|
||||
...argvArg && argvArg.commonjs ? {
|
||||
module: 'commonjs',
|
||||
moduleResolution: 'node',
|
||||
} : {},
|
||||
}),
|
||||
(plugins.rollupJson as any)(),
|
||||
// Allow node_modules resolution, so you can use 'external' to control
|
||||
@ -56,12 +69,12 @@ export class TsBundleProcess {
|
||||
return baseOptions;
|
||||
}
|
||||
|
||||
public getOptionsTest(fromArg: string, toArg: string): plugins.rollup.RollupOptions {
|
||||
return this.getBaseOptions(fromArg, toArg);
|
||||
public getOptionsTest(fromArg: string, toArg: string, argvArg: any): plugins.rollup.RollupOptions {
|
||||
return this.getBaseOptions(fromArg, toArg, argvArg);
|
||||
}
|
||||
|
||||
public getOptionsProduction(fromArg: string, toArg: string): plugins.rollup.RollupOptions {
|
||||
const productionOptions = this.getBaseOptions(fromArg, toArg);
|
||||
public getOptionsProduction(fromArg: string, toArg: string, argvArg: any): plugins.rollup.RollupOptions {
|
||||
const productionOptions = this.getBaseOptions(fromArg, toArg, argvArg);
|
||||
productionOptions.plugins.push(
|
||||
plugins.rollupTerser({
|
||||
compress: true,
|
||||
@ -81,13 +94,14 @@ export class TsBundleProcess {
|
||||
public async buildTest(
|
||||
fromArg: string,
|
||||
toArg: string,
|
||||
bundlerArg: 'rollup' | 'parcel' = 'rollup'
|
||||
bundlerArg: 'rollup' | 'parcel' = 'rollup',
|
||||
argvArg: any
|
||||
) {
|
||||
// create a bundle
|
||||
switch (bundlerArg) {
|
||||
case 'rollup':
|
||||
logger.log('info', `bundling for TEST!`);
|
||||
const buildOptions = this.getOptionsTest(fromArg, toArg);
|
||||
const buildOptions = this.getOptionsTest(fromArg, toArg, argvArg);
|
||||
const bundle = await plugins.rollup.rollup(buildOptions);
|
||||
bundle.generate(buildOptions.output as plugins.rollup.OutputOptions);
|
||||
await bundle.write(buildOptions.output as plugins.rollup.OutputOptions);
|
||||
@ -107,10 +121,10 @@ export class TsBundleProcess {
|
||||
/**
|
||||
* creates a bundle for the production environment
|
||||
*/
|
||||
public async buildProduction(fromArg: string, toArg: string) {
|
||||
public async buildProduction(fromArg: string, toArg: string, argvArg: any) {
|
||||
// create a bundle
|
||||
logger.log('info', `bundling for PRODUCTION!`);
|
||||
const buildOptions = this.getOptionsProduction(fromArg, toArg);
|
||||
const buildOptions = this.getOptionsProduction(fromArg, toArg, argvArg);
|
||||
const bundle = await plugins.rollup.rollup(buildOptions);
|
||||
bundle.generate(buildOptions.output as plugins.rollup.OutputOptions);
|
||||
await bundle.write(buildOptions.output as plugins.rollup.OutputOptions);
|
||||
@ -132,10 +146,11 @@ const run = async () => {
|
||||
tsbundleProcessInstance.buildTest(
|
||||
process.env.tsbundleFrom,
|
||||
process.env.tsbundleTo,
|
||||
process.env.tsbundleBundler as 'rollup' | 'parcel'
|
||||
process.env.tsbundleBundler as 'rollup' | 'parcel',
|
||||
process.env.tsbundleArgv
|
||||
);
|
||||
} else {
|
||||
tsbundleProcessInstance.buildProduction(process.env.tsbundleFrom, process.env.tsbundleTo);
|
||||
tsbundleProcessInstance.buildProduction(process.env.tsbundleFrom, process.env.tsbundleTo, process.env.tsbundleArgv);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -10,12 +10,12 @@ export const runCli = async () => {
|
||||
// const htmlHandler = new HtmlHandler();
|
||||
switch (true) {
|
||||
case argvArg.production || process.env.CI:
|
||||
await tsbundle.buildProduction(process.cwd(), argvArg.from, argvArg.to);
|
||||
await tsbundle.buildProduction(process.cwd(), argvArg.from, argvArg.to, 'rollup', argvArg);
|
||||
// await htmlHandler.minifyHtml();
|
||||
break;
|
||||
case argvArg.test:
|
||||
default:
|
||||
await tsbundle.buildTest(process.cwd(), argvArg.from, argvArg.to, 'rollup');
|
||||
await tsbundle.buildTest(process.cwd(), argvArg.from, argvArg.to, 'rollup', argvArg);
|
||||
// await htmlHandler.copyHtml();
|
||||
return;
|
||||
}
|
||||
@ -29,7 +29,9 @@ export const runCli = async () => {
|
||||
await tsbundle.buildProduction(
|
||||
process.cwd(),
|
||||
'./ts_web/index.ts',
|
||||
'./dist_bundle/bundle.js'
|
||||
'./dist_bundle/bundle.js',
|
||||
'rollup',
|
||||
argvArg
|
||||
);
|
||||
// await htmlHandler.minifyHtml();
|
||||
break;
|
||||
@ -39,7 +41,8 @@ export const runCli = async () => {
|
||||
process.cwd(),
|
||||
'./ts_web/index.ts',
|
||||
'./dist_bundle/bundle.js',
|
||||
'rollup'
|
||||
'rollup',
|
||||
argvArg
|
||||
);
|
||||
// await htmlHandler.copyHtml();
|
||||
return;
|
||||
@ -51,7 +54,13 @@ export const runCli = async () => {
|
||||
// const htmlHandler = new HtmlHandler();
|
||||
switch (true) {
|
||||
case argvArg.production || process.env.CI:
|
||||
await tsbundle.buildProduction(process.cwd(), './ts/index.ts', './dist_bundle/bundle.js');
|
||||
await tsbundle.buildProduction(
|
||||
process.cwd(),
|
||||
'./ts/index.ts',
|
||||
'./dist_bundle/bundle.js',
|
||||
'rollup',
|
||||
argvArg
|
||||
);
|
||||
// await htmlHandler.minifyHtml();
|
||||
break;
|
||||
case argvArg.test:
|
||||
@ -60,7 +69,8 @@ export const runCli = async () => {
|
||||
process.cwd(),
|
||||
'./ts/index.ts',
|
||||
'./dist_bundle/bundle.js',
|
||||
'rollup'
|
||||
'rollup',
|
||||
argvArg
|
||||
);
|
||||
// await htmlHandler.copyHtml();
|
||||
return;
|
||||
@ -75,7 +85,9 @@ export const runCli = async () => {
|
||||
await tsbundle.buildProduction(
|
||||
process.cwd(),
|
||||
'./ts_web/index.ts',
|
||||
'./dist_serve/bundle.js'
|
||||
'./dist_serve/bundle.js',
|
||||
'rollup',
|
||||
argvArg
|
||||
);
|
||||
await htmlHandler.minifyHtml();
|
||||
break;
|
||||
@ -85,7 +97,8 @@ export const runCli = async () => {
|
||||
process.cwd(),
|
||||
'./ts_web/index.ts',
|
||||
'./dist_serve/bundle.js',
|
||||
'rollup'
|
||||
'rollup',
|
||||
argvArg
|
||||
);
|
||||
await htmlHandler.copyHtml();
|
||||
return;
|
||||
|
@ -4,5 +4,6 @@
|
||||
"target": "ES2020",
|
||||
"module": "ES2020",
|
||||
"moduleResolution": "node12",
|
||||
"esModuleInterop": true
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user