fix(core): update

This commit is contained in:
Philipp Kunz 2022-05-04 17:13:52 +02:00
parent e243e17acb
commit 58a7dca142
13 changed files with 878 additions and 458 deletions

1001
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -19,38 +19,21 @@
"@gitzone/tsbuild": "^2.1.59",
"@gitzone/tsrun": "^1.2.31",
"@gitzone/tstest": "^1.0.69",
"@pushrocks/tapbundle": "^5.0.2",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.15.0"
"@pushrocks/tapbundle": "^5.0.2"
},
"dependencies": {
"@babel/core": "^7.17.7",
"@babel/plugin-proposal-class-properties": "^7.16.7",
"@babel/plugin-proposal-decorators": "^7.17.2",
"@babel/plugin-transform-runtime": "^7.17.0",
"@babel/preset-env": "^7.16.11",
"@babel/runtime": "^7.17.7",
"@pushrocks/early": "^3.0.6",
"@pushrocks/smartcli": "^3.0.14",
"@pushrocks/smartfile": "^9.0.6",
"@pushrocks/smartlog": "^2.0.44",
"@pushrocks/smartlog-destination-local": "^8.0.8",
"@pushrocks/smartparcel": "^1.0.13",
"@pushrocks/smartpath": "^5.0.5",
"@pushrocks/smartpromise": "^3.1.7",
"@pushrocks/smartspawn": "^2.0.9",
"@rollup/plugin-commonjs": "^21.0.2",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.1.3",
"@rollup/plugin-typescript": "^8.3.1",
"@types/html-minifier": "^4.0.2",
"@types/node": "^17.0.21",
"esbuild": "0.14.27",
"html-minifier": "^4.0.0",
"rollup": "^2.70.1",
"rollup-plugin-babel": "^4.4.0",
"rollup-plugin-sourcemaps": "^0.6.3",
"rollup-plugin-terser": "^7.0.2",
"typescript": "4.7.0"
},
"files": [

View File

@ -1,8 +1,6 @@
import { expect, tap } from '@pushrocks/tapbundle';
import * as tsbundle from '../ts/index.js';
import * as path from 'path';
tap.test('should bundle with esbuild', async () => {
const tsbundleInstance = new tsbundle.TsBundle();
await tsbundleInstance.build(
@ -15,26 +13,5 @@ tap.test('should bundle with esbuild', async () => {
);
});
tap.test('should bundle with parcel', async () => {
const tsbundleInstance = new tsbundle.TsBundle();
await tsbundleInstance.build(
process.cwd() + '/test',
'./ts_web/index.ts',
'./dist_manual/test.js',
{
bundler: 'parcel'
}
);
});
tap.test('should bundle with rollup', async () => {
const tsbundleInstance = new tsbundle.TsBundle();
await tsbundleInstance.build(
process.cwd(),
'./test/ts_web/index.ts',
'./test/dist_manual/production.js',
{bundler: 'rollup'}
);
});
tap.start();

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@gitzone/tsbundle',
version: '1.0.103',
version: '1.0.104',
description: 'a bundler using rollup for painless bundling of web projects'
}

View File

@ -1,4 +1,5 @@
import * as plugins from './plugins.js';
import * as paths from '../paths.js';
import * as interfaces from '../interfaces/index.js';
import { logger } from '../tsbundle.logging.js';
@ -23,7 +24,8 @@ export class TsBundleProcess {
sourcemap: true,
format: 'esm',
target: 'es2020',
outfile: toArg
outfile: toArg,
tsconfig: paths.tsconfigPath
});
}

View File

@ -1,70 +0,0 @@
import * as plugins from './plugins.js';
import * as interfaces from '../interfaces/index.js';
import { logger } from '../tsbundle.logging.js';
export class TsBundleProcess {
constructor() {
// Nothing here
}
/**
* creates a bundle for the test enviroment
*/
public async buildTest (
fromArg: string,
toArg: string,
argvArg: any
) {
const parsedPath = plugins.path.parse(toArg);
const parcelInstance = new plugins.smartparcel.Parcel(
fromArg,
parsedPath.dir,
parsedPath.base
);
await parcelInstance.build();
}
/**
* creates a bundle for the production environment
*/
public async buildProduction (
fromArg: string,
toArg: string,
argvArg: any
) {
// create a bundle
const parsedPath = plugins.path.parse(toArg);
const parcelInstance = new plugins.smartparcel.Parcel(
fromArg,
parsedPath.dir,
parsedPath.base
);
await parcelInstance.build();
}
}
const run = async () => {
console.log('running spawned compilation process');
const transportOptions: interfaces.IEnvTransportOptions = JSON.parse(process.env.transportOptions);
console.log('bundling with parcel:');
console.log(transportOptions);
process.chdir(transportOptions.cwd);
console.log(`switched to ${process.cwd()}`);
const tsbundleProcessInstance = new TsBundleProcess();
if (transportOptions.mode === 'test') {
tsbundleProcessInstance.buildTest(
transportOptions.from,
transportOptions.to,
transportOptions.argv
);
} else {
tsbundleProcessInstance.buildProduction(
transportOptions.from,
transportOptions.to,
transportOptions.argv
);
}
};
run();

View File

@ -1,7 +0,0 @@
export * from '../plugins.js'
import * as smartparcel from '@pushrocks/smartparcel';
export {
smartparcel
}

View File

@ -1,162 +0,0 @@
import * as plugins from './plugins.js';
import * as interfaces from '../interfaces/index.js';
import { logger } from '../tsbundle.logging.js';
export class TsBundleProcess {
/**
* the basic default options for rollup
*/
public getBaseOptions(
fromArg: string = `ts_web/index.ts`,
toArg: string = 'dist_bundle/bundle.js',
argvArg: any
) {
logger.log('info', `from: ${fromArg}`);
logger.log('info', `to: ${toArg}`);
const baseOptions: plugins.rollup.RollupOptions = {
input: fromArg,
output: {
name: 'tsbundle',
file: toArg,
format: 'iife',
sourcemap: true,
},
// Indicate here external modules you don't wanna include in your bundle (i.e.: 'lodash')
external: [],
watch: {
include: ['src/**'],
},
plugins: [
// Compile TypeScript files
(plugins.rollupTypescript as any)({
include: plugins.path.parse(fromArg).dir
? plugins.path.parse(fromArg).dir + '/**/*.ts'
: '**/*.ts',
declaration: false,
emitDecoratorMetadata: true,
experimentalDecorators: true,
inlineSourceMap: true,
noEmitOnError: true,
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
// which external modules to include in the bundle
// https://github.com/rollup/rollup-plugin-node-resolve#usage
plugins.rollupResolve(),
(plugins.rollupCommonjs as any)({}),
// Resolve source maps to the original source
plugins.rollupSourceMaps(),
],
};
return baseOptions;
}
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 {
const productionOptions = this.getBaseOptions(fromArg, toArg, argvArg);
productionOptions.plugins.push(
plugins.rollupTerser({
compress: true,
mangle: true,
})
);
return productionOptions;
}
constructor() {
// Nothing here
}
/**
* creates a bundle for the test enviroment
*/
public async buildTest(
fromArg: string,
toArg: string,
argvArg: any
) {
// create a bundle
logger.log('info', `bundling for TEST!`);
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);
logger.log('ok', `Successfully bundled files!`);
process.exit(0);
}
/**
* creates a bundle for the production environment
*/
public async buildProduction(fromArg: string, toArg: string, argvArg: any) {
// create a bundle
logger.log('info', `bundling for PRODUCTION!`);
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);
logger.log('ok', `Successfully bundled files!`);
process.exit(0);
}
}
const run = async () => {
console.log('running spawned compilation process');
const transportOptions: interfaces.IEnvTransportOptions = JSON.parse(process.env.transportOptions);
console.log('bundling with rollup:');
console.log(transportOptions);
process.chdir(transportOptions.cwd);
console.log(`switched to ${process.cwd()}`);
const tsbundleProcessInstance = new TsBundleProcess();
if (transportOptions.mode === 'test') {
tsbundleProcessInstance.buildTest(
transportOptions.from,
transportOptions.to,
transportOptions.argv
);
} else {
tsbundleProcessInstance.buildProduction(
transportOptions.from,
transportOptions.to,
transportOptions.argv
);
}
};
run();

View File

@ -1,22 +0,0 @@
export * from '../plugins.js';
// third party scope
import * as rollup from 'rollup';
import rollupBabel from 'rollup-plugin-babel';
import rollupCommonjs from '@rollup/plugin-commonjs';
import rollupJson from '@rollup/plugin-json';
import rollupResolve from '@rollup/plugin-node-resolve';
import rollupSourceMaps from 'rollup-plugin-sourcemaps';
import { terser as rollupTerser } from 'rollup-plugin-terser';
import rollupTypescript from '@rollup/plugin-typescript';
export {
rollup,
rollupBabel,
rollupCommonjs,
rollupJson,
rollupResolve,
rollupSourceMaps,
rollupTerser,
rollupTypescript,
};

View File

@ -8,3 +8,4 @@ export const packageDir = plugins.path.join(
export const htmlDir = plugins.path.join(cwd, './html');
export const distServeDir = plugins.path.join(cwd, './dist_serve');
export const assetsDir = plugins.path.join(packageDir, 'assets');
export const tsconfigPath = plugins.path.join(packageDir, './tsconfig.json');

View File

@ -15,12 +15,6 @@ export class TsBundle {
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 = {

View File

@ -4,6 +4,8 @@
"target": "ES2020",
"module": "ES2020",
"moduleResolution": "node12",
"useDefineForClassFields": false,
"preserveValueImports": true,
"esModuleInterop": true
}
}

View File

@ -1,17 +0,0 @@
{
"extends": ["tslint:latest", "tslint-config-prettier"],
"rules": {
"semicolon": [true, "always"],
"no-console": false,
"ordered-imports": false,
"object-literal-sort-keys": false,
"member-ordering": {
"options":{
"order": [
"static-method"
]
}
}
},
"defaultSeverity": "warning"
}