fix(core): update

This commit is contained in:
Philipp Kunz 2022-03-15 13:45:03 +01:00
parent ae16fd8170
commit a3ab55cbc6
4 changed files with 50 additions and 23 deletions

View File

@ -67,4 +67,4 @@
"browserslist": [
"last 1 chrome versions"
]
}
}

View File

@ -9,7 +9,8 @@ tap.test('should bundle test', async () => {
process.cwd() + '/test',
'./ts_web/index.ts',
'./dist_manual/test.js',
'rollup'
'rollup',
{}
);
});
@ -18,7 +19,9 @@ tap.test('should bundle production', async () => {
await tsbundleInstance.buildProduction(
process.cwd(),
'./test/ts_web/index.ts',
'./test/dist_manual/production.js'
'./test/dist_manual/production.js',
'rollup',
{}
);
});

View File

@ -2,7 +2,7 @@ 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,
@ -11,7 +11,10 @@ export class TsBundle {
) {
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'),
plugins.path.join(
plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url),
'./tsbundle.class.tsbundleprocess.js'
),
[],
{
env: {
@ -21,7 +24,7 @@ export class TsBundle {
tsbundleFrom: fromArg,
tsbundleTo: toArg,
tsbundleBundler: bundlerArg,
tsbundleArgv: argvArg,
tsbundleArgv: argvArg ? JSON.stringify(argvArg) : '{}',
},
}
);
@ -32,7 +35,7 @@ export class TsBundle {
await done.promise;
}
public async buildProduction (
public async buildProduction(
cwdArg: string,
fromArg: string,
toArg: string,
@ -41,7 +44,10 @@ export class TsBundle {
) {
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'),
plugins.path.join(
plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url),
'./tsbundle.class.tsbundleprocess.js'
),
[],
{
env: {
@ -51,7 +57,7 @@ export class TsBundle {
tsbundleFrom: fromArg,
tsbundleTo: toArg,
tsbundleBundler: bundlerArg,
tsbundleArgv: argvArg,
tsbundleArgv: argvArg ? JSON.stringify(argvArg) : '{}',
},
}
);

View File

@ -44,16 +44,22 @@ export class TsBundleProcess {
moduleResolution: 'node12',
allowSyntheticDefaultImports: true,
importsNotUsedAsValues: 'preserve',
...argvArg && argvArg.skiplibcheck ? {
skipLibCheck: true
} : {},
...argvArg && argvArg.allowimplicitany ? {
noImplicitAny: false
} : {},
...argvArg && argvArg.commonjs ? {
module: 'commonjs',
moduleResolution: 'node',
} : {},
...(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
@ -69,11 +75,19 @@ export class TsBundleProcess {
return baseOptions;
}
public getOptionsTest(fromArg: string, toArg: string, argvArg: any): plugins.rollup.RollupOptions {
public getOptionsTest(
fromArg: string,
toArg: string,
argvArg: any
): plugins.rollup.RollupOptions {
return this.getBaseOptions(fromArg, toArg, argvArg);
}
public getOptionsProduction(fromArg: string, toArg: string, argvArg: any): plugins.rollup.RollupOptions {
public getOptionsProduction(
fromArg: string,
toArg: string,
argvArg: any
): plugins.rollup.RollupOptions {
const productionOptions = this.getBaseOptions(fromArg, toArg, argvArg);
productionOptions.plugins.push(
plugins.rollupTerser({
@ -147,10 +161,14 @@ const run = async () => {
process.env.tsbundleFrom,
process.env.tsbundleTo,
process.env.tsbundleBundler as 'rollup' | 'parcel',
process.env.tsbundleArgv
JSON.parse(process.env.tsbundleArgv)
);
} else {
tsbundleProcessInstance.buildProduction(process.env.tsbundleFrom, process.env.tsbundleTo, process.env.tsbundleArgv);
tsbundleProcessInstance.buildProduction(
process.env.tsbundleFrom,
process.env.tsbundleTo,
JSON.parse(process.env.tsbundleArgv)
);
}
};