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": [ "browserslist": [
"last 1 chrome versions" "last 1 chrome versions"
] ]
} }

View File

@ -9,7 +9,8 @@ tap.test('should bundle test', async () => {
process.cwd() + '/test', process.cwd() + '/test',
'./ts_web/index.ts', './ts_web/index.ts',
'./dist_manual/test.js', './dist_manual/test.js',
'rollup' 'rollup',
{}
); );
}); });
@ -18,7 +19,9 @@ tap.test('should bundle production', async () => {
await tsbundleInstance.buildProduction( await tsbundleInstance.buildProduction(
process.cwd(), process.cwd(),
'./test/ts_web/index.ts', './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'; import { logger } from './tsbundle.logging.js';
export class TsBundle { export class TsBundle {
public async buildTest ( public async buildTest(
cwdArg: string, cwdArg: string,
fromArg: string, fromArg: string,
toArg: string, toArg: string,
@ -11,7 +11,10 @@ export class TsBundle {
) { ) {
const done = plugins.smartpromise.defer(); const done = plugins.smartpromise.defer();
const threadsimple = new plugins.smartspawn.ThreadSimple( 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: { env: {
@ -21,7 +24,7 @@ export class TsBundle {
tsbundleFrom: fromArg, tsbundleFrom: fromArg,
tsbundleTo: toArg, tsbundleTo: toArg,
tsbundleBundler: bundlerArg, tsbundleBundler: bundlerArg,
tsbundleArgv: argvArg, tsbundleArgv: argvArg ? JSON.stringify(argvArg) : '{}',
}, },
} }
); );
@ -32,7 +35,7 @@ export class TsBundle {
await done.promise; await done.promise;
} }
public async buildProduction ( public async buildProduction(
cwdArg: string, cwdArg: string,
fromArg: string, fromArg: string,
toArg: string, toArg: string,
@ -41,7 +44,10 @@ export class TsBundle {
) { ) {
const done = plugins.smartpromise.defer(); const done = plugins.smartpromise.defer();
const threadsimple = new plugins.smartspawn.ThreadSimple( 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: { env: {
@ -51,7 +57,7 @@ export class TsBundle {
tsbundleFrom: fromArg, tsbundleFrom: fromArg,
tsbundleTo: toArg, tsbundleTo: toArg,
tsbundleBundler: bundlerArg, tsbundleBundler: bundlerArg,
tsbundleArgv: argvArg, tsbundleArgv: argvArg ? JSON.stringify(argvArg) : '{}',
}, },
} }
); );

View File

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