Compare commits
18 Commits
Author | SHA1 | Date | |
---|---|---|---|
d603baf65e | |||
50e4909984 | |||
7208274156 | |||
41ec42d068 | |||
d159b9a6a8 | |||
45d0d74559 | |||
661fdf75cf | |||
6f17a76b6e | |||
324ef71b6f | |||
58a7dca142 | |||
e243e17acb | |||
d788bdc78b | |||
3ef8a145a5 | |||
3377554969 | |||
c53d9023fe | |||
1112cfe793 | |||
fc97fac77e | |||
1530f0ad74 |
11
assets/tsconfig.json
Normal file
11
assets/tsconfig.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"target": "ES2020",
|
||||||
|
"module": "ES2020",
|
||||||
|
"moduleResolution": "node12",
|
||||||
|
"useDefineForClassFields": false,
|
||||||
|
"preserveValueImports": true,
|
||||||
|
"esModuleInterop": true
|
||||||
|
}
|
||||||
|
}
|
1186
package-lock.json
generated
1186
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
27
package.json
27
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@gitzone/tsbundle",
|
"name": "@gitzone/tsbundle",
|
||||||
"version": "1.0.99",
|
"version": "2.0.3",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "a bundler using rollup for painless bundling of web projects",
|
"description": "a bundler using rollup for painless bundling of web projects",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
@ -16,41 +16,24 @@
|
|||||||
"tsbundle": "cli.js"
|
"tsbundle": "cli.js"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.56",
|
"@gitzone/tsbuild": "^2.1.59",
|
||||||
"@gitzone/tsrun": "^1.2.31",
|
"@gitzone/tsrun": "^1.2.31",
|
||||||
"@gitzone/tstest": "^1.0.67",
|
"@gitzone/tstest": "^1.0.69",
|
||||||
"@pushrocks/tapbundle": "^5.0.2",
|
"@pushrocks/tapbundle": "^5.0.2"
|
||||||
"tslint": "^6.1.3",
|
|
||||||
"tslint-config-prettier": "^1.15.0"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"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/early": "^3.0.6",
|
||||||
"@pushrocks/smartcli": "^3.0.14",
|
"@pushrocks/smartcli": "^3.0.14",
|
||||||
"@pushrocks/smartfile": "^9.0.6",
|
"@pushrocks/smartfile": "^9.0.6",
|
||||||
"@pushrocks/smartlog": "^2.0.44",
|
"@pushrocks/smartlog": "^2.0.44",
|
||||||
"@pushrocks/smartlog-destination-local": "^8.0.8",
|
"@pushrocks/smartlog-destination-local": "^8.0.8",
|
||||||
"@pushrocks/smartparcel": "^1.0.13",
|
|
||||||
"@pushrocks/smartpath": "^5.0.5",
|
"@pushrocks/smartpath": "^5.0.5",
|
||||||
"@pushrocks/smartpromise": "^3.1.7",
|
"@pushrocks/smartpromise": "^3.1.7",
|
||||||
"@pushrocks/smartspawn": "^2.0.9",
|
"@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/html-minifier": "^4.0.2",
|
||||||
"@types/node": "^17.0.21",
|
"@types/node": "^17.0.21",
|
||||||
"esbuild": "^0.14.27",
|
"esbuild": "0.14.27",
|
||||||
"html-minifier": "^4.0.0",
|
"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"
|
"typescript": "4.7.0"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
|
23
test/test.ts
23
test/test.ts
@ -1,8 +1,6 @@
|
|||||||
import { expect, tap } from '@pushrocks/tapbundle';
|
import { expect, tap } from '@pushrocks/tapbundle';
|
||||||
import * as tsbundle from '../ts/index.js';
|
import * as tsbundle from '../ts/index.js';
|
||||||
|
|
||||||
import * as path from 'path';
|
|
||||||
|
|
||||||
tap.test('should bundle with esbuild', async () => {
|
tap.test('should bundle with esbuild', async () => {
|
||||||
const tsbundleInstance = new tsbundle.TsBundle();
|
const tsbundleInstance = new tsbundle.TsBundle();
|
||||||
await tsbundleInstance.build(
|
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();
|
tap.start();
|
||||||
|
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
/**
|
||||||
|
* autocreated commitinfo by @pushrocks/commitinfo
|
||||||
|
*/
|
||||||
|
export const commitinfo = {
|
||||||
|
name: '@gitzone/tsbundle',
|
||||||
|
version: '2.0.3',
|
||||||
|
description: 'a bundler using rollup for painless bundling of web projects'
|
||||||
|
}
|
@ -9,5 +9,5 @@ early.stop();
|
|||||||
|
|
||||||
// lets make this usable programmatically
|
// lets make this usable programmatically
|
||||||
export * from './tsbundle.class.tsbundle.js';
|
export * from './tsbundle.class.tsbundle.js';
|
||||||
export * from './mod_rollup/htmlhandler.js';
|
export * from './mod_html/index.js';
|
||||||
export { runCli };
|
export { runCli };
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import * as plugins from './plugins.js';
|
import * as plugins from './plugins.js';
|
||||||
|
import * as paths from '../paths.js';
|
||||||
import * as interfaces from '../interfaces/index.js';
|
import * as interfaces from '../interfaces/index.js';
|
||||||
import { logger } from '../tsbundle.logging.js';
|
import { logger } from '../tsbundle.logging.js';
|
||||||
|
|
||||||
@ -22,7 +23,9 @@ export class TsBundleProcess {
|
|||||||
bundle: true,
|
bundle: true,
|
||||||
sourcemap: true,
|
sourcemap: true,
|
||||||
format: 'esm',
|
format: 'esm',
|
||||||
outfile: toArg
|
target: 'es2020',
|
||||||
|
outfile: toArg,
|
||||||
|
tsconfig: paths.tsconfigPath
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,8 +46,10 @@ export class TsBundleProcess {
|
|||||||
bundle: true,
|
bundle: true,
|
||||||
sourcemap: true,
|
sourcemap: true,
|
||||||
format: 'esm',
|
format: 'esm',
|
||||||
|
target: 'es2020',
|
||||||
minify: true,
|
minify: true,
|
||||||
outfile: toArg
|
outfile: toArg,
|
||||||
|
tsconfig: paths.tsconfigPath
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
44
ts/mod_html/index.ts
Normal file
44
ts/mod_html/index.ts
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
import * as plugins from './plugins.js';
|
||||||
|
import * as paths from '../paths.js';
|
||||||
|
|
||||||
|
export class HtmlHandler {
|
||||||
|
public defaultFromPath: string = plugins.path.join(paths.htmlDir, 'index.html');
|
||||||
|
public defaultToPath: string = plugins.path.join(paths.distServeDir, 'index.html');
|
||||||
|
|
||||||
|
public async checkIfExists() {
|
||||||
|
return plugins.smartfile.fs.fileExists(this.defaultFromPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
// copies the html
|
||||||
|
public async copyHtml(fromArg: string = this.defaultFromPath, toArg: string = this.defaultToPath) {
|
||||||
|
if (await this.checkIfExists()) {
|
||||||
|
console.log(`${fromArg} replaces file at ${toArg}`);
|
||||||
|
}
|
||||||
|
fromArg = plugins.smartpath.transform.toAbsolute(fromArg, paths.cwd) as string;
|
||||||
|
toArg = plugins.smartpath.transform.toAbsolute(toArg, paths.cwd) as string;
|
||||||
|
await plugins.smartfile.fs.copy(fromArg, toArg);
|
||||||
|
console.log(`html copy succeeded!`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// copies and minifies the html
|
||||||
|
public async minifyHtml(fromArg: string = this.defaultFromPath, toArg: string = this.defaultToPath) {
|
||||||
|
if (await this.checkIfExists()) {
|
||||||
|
console.log(`${fromArg} replaces file at ${toArg}`);
|
||||||
|
}
|
||||||
|
fromArg = plugins.smartpath.transform.toAbsolute(fromArg, paths.cwd) as string;
|
||||||
|
toArg = plugins.smartpath.transform.toAbsolute(toArg, paths.cwd) as string;
|
||||||
|
const fileString = plugins.smartfile.fs.toStringSync(fromArg);
|
||||||
|
const minifiedHtml = plugins.htmlMinifier.minify(fileString, {
|
||||||
|
minifyCSS: true,
|
||||||
|
minifyJS: true,
|
||||||
|
sortAttributes: true,
|
||||||
|
sortClassName: true,
|
||||||
|
removeAttributeQuotes: true,
|
||||||
|
collapseWhitespace: true,
|
||||||
|
collapseInlineTagWhitespace: true,
|
||||||
|
removeComments: true,
|
||||||
|
});
|
||||||
|
await plugins.smartfile.memory.toFs(minifiedHtml, toArg);
|
||||||
|
console.log(`html minification succeeded!`);
|
||||||
|
}
|
||||||
|
}
|
7
ts/mod_html/plugins.ts
Normal file
7
ts/mod_html/plugins.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
export * from '../plugins.js';
|
||||||
|
|
||||||
|
import * as htmlMinifier from 'html-minifier';
|
||||||
|
|
||||||
|
export {
|
||||||
|
htmlMinifier
|
||||||
|
}
|
@ -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();
|
|
@ -1,7 +0,0 @@
|
|||||||
export * from '../plugins.js'
|
|
||||||
|
|
||||||
import * as smartparcel from '@pushrocks/smartparcel';
|
|
||||||
|
|
||||||
export {
|
|
||||||
smartparcel
|
|
||||||
}
|
|
@ -1,38 +0,0 @@
|
|||||||
import * as plugins from './plugins.js';
|
|
||||||
import * as paths from '../paths.js';
|
|
||||||
|
|
||||||
export class HtmlHandler {
|
|
||||||
public sourceFilePath: string = plugins.path.join(paths.htmlDir, 'index.html');
|
|
||||||
public targetFilePath: string = plugins.path.join(paths.distServeDir, 'index.html');
|
|
||||||
|
|
||||||
public async checkIfExists() {
|
|
||||||
return plugins.smartfile.fs.fileExists(this.sourceFilePath);
|
|
||||||
}
|
|
||||||
|
|
||||||
// copies the html
|
|
||||||
public async copyHtml(targetPathArg = this.targetFilePath) {
|
|
||||||
if (!(await this.checkIfExists())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
await plugins.smartfile.fs.copy(this.sourceFilePath, targetPathArg);
|
|
||||||
}
|
|
||||||
|
|
||||||
// copies and minifies the html
|
|
||||||
public async minifyHtml(targetPathArg = this.targetFilePath) {
|
|
||||||
if (!(await this.checkIfExists())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const fileString = plugins.smartfile.fs.toStringSync(this.sourceFilePath);
|
|
||||||
const minifiedHtml = plugins.htmlMinifier.minify(fileString, {
|
|
||||||
minifyCSS: true,
|
|
||||||
minifyJS: true,
|
|
||||||
sortAttributes: true,
|
|
||||||
sortClassName: true,
|
|
||||||
removeAttributeQuotes: true,
|
|
||||||
collapseWhitespace: true,
|
|
||||||
collapseInlineTagWhitespace: true,
|
|
||||||
removeComments: true,
|
|
||||||
});
|
|
||||||
plugins.smartfile.memory.toFsSync(minifiedHtml, targetPathArg);
|
|
||||||
}
|
|
||||||
}
|
|
@ -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();
|
|
@ -1,25 +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';
|
|
||||||
|
|
||||||
import * as htmlMinifier from 'html-minifier';
|
|
||||||
|
|
||||||
export {
|
|
||||||
rollup,
|
|
||||||
rollupBabel,
|
|
||||||
rollupCommonjs,
|
|
||||||
rollupJson,
|
|
||||||
rollupResolve,
|
|
||||||
rollupSourceMaps,
|
|
||||||
rollupTerser,
|
|
||||||
rollupTypescript,
|
|
||||||
htmlMinifier,
|
|
||||||
};
|
|
@ -8,3 +8,4 @@ export const packageDir = plugins.path.join(
|
|||||||
export const htmlDir = plugins.path.join(cwd, './html');
|
export const htmlDir = plugins.path.join(cwd, './html');
|
||||||
export const distServeDir = plugins.path.join(cwd, './dist_serve');
|
export const distServeDir = plugins.path.join(cwd, './dist_serve');
|
||||||
export const assetsDir = plugins.path.join(packageDir, 'assets');
|
export const assetsDir = plugins.path.join(packageDir, 'assets');
|
||||||
|
export const tsconfigPath = plugins.path.join(assetsDir, './tsconfig.json');
|
||||||
|
@ -15,12 +15,6 @@ export class TsBundle {
|
|||||||
if (argvArg.bundler === 'esbuild') {
|
if (argvArg.bundler === 'esbuild') {
|
||||||
return './mod_esbuild/index.child.js'
|
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'
|
return './mod_esbuild/index.child.js'
|
||||||
}
|
}
|
||||||
const transportOptions: interfaces.IEnvTransportOptions = {
|
const transportOptions: interfaces.IEnvTransportOptions = {
|
||||||
@ -28,8 +22,9 @@ export class TsBundle {
|
|||||||
from: fromArg,
|
from: fromArg,
|
||||||
to: toArg,
|
to: toArg,
|
||||||
mode: argvArg && argvArg.production ? 'production' : 'test',
|
mode: argvArg && argvArg.production ? 'production' : 'test',
|
||||||
argv: argvArg ? argvArg : {
|
argv: {
|
||||||
bundler: 'esbuild'
|
bundler: 'esbuild',
|
||||||
|
...argvArg
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const threadsimple = new plugins.smartspawn.ThreadSimple(
|
const threadsimple = new plugins.smartspawn.ThreadSimple(
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import * as plugins from './plugins.js';
|
import * as plugins from './plugins.js';
|
||||||
import { TsBundle } from './tsbundle.class.tsbundle.js';
|
import { TsBundle } from './tsbundle.class.tsbundle.js';
|
||||||
|
import { HtmlHandler } from './mod_html/index.js';
|
||||||
import { logger } from './tsbundle.logging.js';
|
import { logger } from './tsbundle.logging.js';
|
||||||
|
|
||||||
export const runCli = async () => {
|
export const runCli = async () => {
|
||||||
@ -12,6 +13,7 @@ export const runCli = async () => {
|
|||||||
|
|
||||||
tsBundleCli.addCommand('element').subscribe(async (argvArg) => {
|
tsBundleCli.addCommand('element').subscribe(async (argvArg) => {
|
||||||
const tsbundle = new TsBundle();
|
const tsbundle = new TsBundle();
|
||||||
|
const htmlHandler = new HtmlHandler();
|
||||||
// const htmlHandler = new HtmlHandler();
|
// const htmlHandler = new HtmlHandler();
|
||||||
await tsbundle.build(
|
await tsbundle.build(
|
||||||
process.cwd(),
|
process.cwd(),
|
||||||
@ -23,6 +25,7 @@ export const runCli = async () => {
|
|||||||
|
|
||||||
tsBundleCli.addCommand('npm').subscribe(async (argvArg) => {
|
tsBundleCli.addCommand('npm').subscribe(async (argvArg) => {
|
||||||
const tsbundle = new TsBundle();
|
const tsbundle = new TsBundle();
|
||||||
|
const htmlHandler = new HtmlHandler();
|
||||||
await tsbundle.build(
|
await tsbundle.build(
|
||||||
process.cwd(),
|
process.cwd(),
|
||||||
'./ts/index.ts',
|
'./ts/index.ts',
|
||||||
@ -33,12 +36,14 @@ export const runCli = async () => {
|
|||||||
|
|
||||||
tsBundleCli.addCommand('website').subscribe(async (argvArg) => {
|
tsBundleCli.addCommand('website').subscribe(async (argvArg) => {
|
||||||
const tsbundle = new TsBundle();
|
const tsbundle = new TsBundle();
|
||||||
|
const htmlHandler = new HtmlHandler();
|
||||||
await tsbundle.build(
|
await tsbundle.build(
|
||||||
process.cwd(),
|
process.cwd(),
|
||||||
'./ts_web/index.ts',
|
'./ts_web/index.ts',
|
||||||
'./dist_serve/bundle.js',
|
'./dist_serve/bundle.js',
|
||||||
argvArg
|
argvArg
|
||||||
);
|
);
|
||||||
|
await htmlHandler.minifyHtml('./html/index.html', './dist_serve/index.html')
|
||||||
});
|
});
|
||||||
|
|
||||||
tsBundleCli.startParse();
|
tsBundleCli.startParse();
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
"target": "ES2020",
|
"useDefineForClassFields": false,
|
||||||
"module": "ES2020",
|
"target": "ES2022",
|
||||||
"moduleResolution": "node12",
|
"module": "ES2022",
|
||||||
"esModuleInterop": true
|
"moduleResolution": "nodenext"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
17
tslint.json
17
tslint.json
@ -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"
|
|
||||||
}
|
|
Reference in New Issue
Block a user