Compare commits
42 Commits
Author | SHA1 | Date | |
---|---|---|---|
866c203856 | |||
3e673bca6b | |||
5c3dfe0920 | |||
c08a9065a1 | |||
f4071f0b64 | |||
335cc19211 | |||
25851c2b64 | |||
73a6ce2786 | |||
8bd279637b | |||
1e37857c26 | |||
93a1052bf5 | |||
6e6452df61 | |||
3de5a91885 | |||
f7ca1b2135 | |||
3076e13179 | |||
f3b50d384a | |||
6dcb3f7c2a | |||
daba025307 | |||
00383171ff | |||
2ce9b08911 | |||
d603baf65e | |||
50e4909984 | |||
7208274156 | |||
41ec42d068 | |||
d159b9a6a8 | |||
45d0d74559 | |||
661fdf75cf | |||
6f17a76b6e | |||
324ef71b6f | |||
58a7dca142 | |||
e243e17acb | |||
d788bdc78b | |||
3ef8a145a5 | |||
3377554969 | |||
c53d9023fe | |||
1112cfe793 | |||
fc97fac77e | |||
1530f0ad74 | |||
d6d1b063af | |||
98f8aad9c2 | |||
b37315b4ee | |||
6d1dbbb638 |
@ -124,7 +124,7 @@ pages:
|
|||||||
stage: metadata
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
- npmci node install lts
|
- npmci node install lts
|
||||||
- npmci command npm install -g @gitzone/tsdoc
|
- npmci command npm install -g @git.zone/tsdoc
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci command tsdoc
|
- npmci command tsdoc
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
process.env.CLI_CALL = 'true';
|
process.env.CLI_CALL = 'true';
|
||||||
|
|
||||||
import * as tsrun from '@gitzone/tsrun';
|
import * as tsrun from '@git.zone/tsrun';
|
||||||
tsrun.runPath('./cli.child.js', import.meta.url);
|
tsrun.runPath('./cli.child.js', import.meta.url);
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
"gitscope": "gitzone",
|
"gitscope": "gitzone",
|
||||||
"gitrepo": "tsbundle",
|
"gitrepo": "tsbundle",
|
||||||
"description": "a bundler using rollup for painless bundling of web projects",
|
"description": "a bundler using rollup for painless bundling of web projects",
|
||||||
"npmPackagename": "@gitzone/tsbundle",
|
"npmPackagename": "@git.zone/tsbundle",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"projectDomain": "git.zone"
|
"projectDomain": "git.zone"
|
||||||
}
|
}
|
||||||
|
18146
package-lock.json
generated
18146
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
54
package.json
54
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@gitzone/tsbundle",
|
"name": "@git.zone/tsbundle",
|
||||||
"version": "1.0.97",
|
"version": "2.0.13",
|
||||||
"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,42 +16,26 @@
|
|||||||
"tsbundle": "cli.js"
|
"tsbundle": "cli.js"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.56",
|
"@git.zone/tsbuild": "^2.1.70",
|
||||||
"@gitzone/tsrun": "^1.2.31",
|
"@git.zone/tsrun": "^1.2.46",
|
||||||
"@gitzone/tstest": "^1.0.67",
|
"@git.zone/tstest": "^1.0.84",
|
||||||
"@pushrocks/tapbundle": "^5.0.2",
|
"@push.rocks/tapbundle": "^5.0.15",
|
||||||
"tslint": "^6.1.3",
|
"@types/node": "^20.10.7"
|
||||||
"tslint-config-prettier": "^1.15.0"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/core": "^7.17.7",
|
"@push.rocks/early": "^4.0.4",
|
||||||
"@babel/plugin-proposal-class-properties": "^7.16.7",
|
"@push.rocks/smartcli": "^4.0.8",
|
||||||
"@babel/plugin-proposal-decorators": "^7.17.2",
|
"@push.rocks/smartdelay": "^3.0.5",
|
||||||
"@babel/plugin-transform-runtime": "^7.17.0",
|
"@push.rocks/smartfile": "^11.0.4",
|
||||||
"@babel/preset-env": "^7.16.11",
|
"@push.rocks/smartlog": "^3.0.3",
|
||||||
"@babel/runtime": "^7.17.7",
|
"@push.rocks/smartlog-destination-local": "^9.0.0",
|
||||||
"@pushrocks/early": "^3.0.6",
|
"@push.rocks/smartpath": "^5.0.11",
|
||||||
"@pushrocks/smartcli": "^3.0.14",
|
"@push.rocks/smartpromise": "^4.0.2",
|
||||||
"@pushrocks/smartfile": "^9.0.6",
|
"@push.rocks/smartspawn": "^3.0.2",
|
||||||
"@pushrocks/smartlog": "^2.0.44",
|
"@types/html-minifier": "^4.0.5",
|
||||||
"@pushrocks/smartlog-destination-local": "^8.0.8",
|
"esbuild": "^0.19.11",
|
||||||
"@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",
|
"html-minifier": "^4.0.0",
|
||||||
"rollup": "^2.70.1",
|
"typescript": "5.3.3"
|
||||||
"rollup-plugin-babel": "^4.4.0",
|
|
||||||
"rollup-plugin-sourcemaps": "^0.6.3",
|
|
||||||
"rollup-plugin-terser": "^7.0.2",
|
|
||||||
"typescript": "4.7.0"
|
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"ts/**/*",
|
"ts/**/*",
|
||||||
|
5541
pnpm-lock.yaml
generated
Normal file
5541
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
16
readme.md
16
readme.md
@ -1,8 +1,8 @@
|
|||||||
# @gitzone/tsbundle
|
# @git.zone/tsbundle
|
||||||
a bundler using rollup for painless bundling of web projects
|
a bundler using rollup for painless bundling of web projects
|
||||||
|
|
||||||
## Availabililty and Links
|
## Availabililty and Links
|
||||||
* [npmjs.org (npm package)](https://www.npmjs.com/package/@gitzone/tsbundle)
|
* [npmjs.org (npm package)](https://www.npmjs.com/package/@git.zone/tsbundle)
|
||||||
* [gitlab.com (source)](https://gitlab.com/gitzone/tsbundle)
|
* [gitlab.com (source)](https://gitlab.com/gitzone/tsbundle)
|
||||||
* [github.com (source mirror)](https://github.com/gitzone/tsbundle)
|
* [github.com (source mirror)](https://github.com/gitzone/tsbundle)
|
||||||
* [docs (typedoc)](https://gitzone.gitlab.io/tsbundle/)
|
* [docs (typedoc)](https://gitzone.gitlab.io/tsbundle/)
|
||||||
@ -13,14 +13,14 @@ Status Category | Status Badge
|
|||||||
-- | --
|
-- | --
|
||||||
GitLab Pipelines | [](https://lossless.cloud)
|
GitLab Pipelines | [](https://lossless.cloud)
|
||||||
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
||||||
npm | [](https://lossless.cloud)
|
npm | [](https://lossless.cloud)
|
||||||
Snyk | [](https://lossless.cloud)
|
Snyk | [](https://lossless.cloud)
|
||||||
TypeScript Support | [](https://lossless.cloud)
|
TypeScript Support | [](https://lossless.cloud)
|
||||||
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
Code Style | [](https://lossless.cloud)
|
Code Style | [](https://lossless.cloud)
|
||||||
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
||||||
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
||||||
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
||||||
Platform support | [](https://lossless.cloud) [](https://lossless.cloud)
|
Platform support | [](https://lossless.cloud) [](https://lossless.cloud)
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
@ -38,10 +38,10 @@ tsbundle supports two modes of usage: CLI and API usage.
|
|||||||
# Install the tool for cli usage
|
# Install the tool for cli usage
|
||||||
|
|
||||||
# Globally
|
# Globally
|
||||||
npm install -g @gitzone/tsbundle
|
npm install -g @git.zone/tsbundle
|
||||||
|
|
||||||
# Locally for use in your pacakge.json
|
# Locally for use in your pacakge.json
|
||||||
npm install --save-dev @gitzone/tsbundle
|
npm install --save-dev @git.zone/tsbundle
|
||||||
|
|
||||||
# then use it
|
# then use it
|
||||||
tsbundle --from="./ts/index.ts" --to="dist/bundle.js"
|
tsbundle --from="./ts/index.ts" --to="dist/bundle.js"
|
||||||
|
25
test/test.ts
25
test/test.ts
@ -1,8 +1,6 @@
|
|||||||
import { expect, tap } from '@pushrocks/tapbundle';
|
import { expect, tap } from '@push.rocks/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();
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
|
import * as smartdelay from '@push.rocks/smartdelay';
|
||||||
|
|
||||||
const myConst: string = 'hello';
|
const myConst: string = 'hello';
|
||||||
|
|
||||||
|
await smartdelay.delayFor(1000);
|
||||||
|
|
||||||
function sealed(constructor: Function) {
|
function sealed(constructor: Function) {
|
||||||
Object.seal(constructor);
|
Object.seal(constructor);
|
||||||
Object.seal(constructor.prototype);
|
Object.seal(constructor.prototype);
|
||||||
@ -15,4 +19,6 @@ class BugReport {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
console.log(myConst);
|
console.log(myConst);
|
||||||
|
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: '@git.zone/tsbundle',
|
||||||
|
version: '2.0.13',
|
||||||
|
description: 'a bundler using rollup for painless bundling of web projects'
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
import * as early from '@pushrocks/early';
|
import * as early from '@push.rocks/early';
|
||||||
early.start('tsbundle');
|
early.start('tsbundle');
|
||||||
// lets import all plugins beforehand
|
// lets import all plugins beforehand
|
||||||
import './plugins.js';
|
import './plugins.js';
|
||||||
@ -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';
|
||||||
|
|
||||||
@ -20,7 +21,13 @@ export class TsBundleProcess {
|
|||||||
const esbuild = await plugins.esbuild.build({
|
const esbuild = await plugins.esbuild.build({
|
||||||
entryPoints: [fromArg],
|
entryPoints: [fromArg],
|
||||||
bundle: true,
|
bundle: true,
|
||||||
outfile: toArg
|
sourcemap: true,
|
||||||
|
format: 'esm',
|
||||||
|
target: 'es2022',
|
||||||
|
entryNames: plugins.path.parse(toArg).name,
|
||||||
|
outdir: plugins.path.parse(toArg).dir,
|
||||||
|
splitting: true,
|
||||||
|
tsconfig: paths.tsconfigPath
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,7 +46,16 @@ export class TsBundleProcess {
|
|||||||
const esbuild = await plugins.esbuild.build({
|
const esbuild = await plugins.esbuild.build({
|
||||||
entryPoints: [fromArg],
|
entryPoints: [fromArg],
|
||||||
bundle: true,
|
bundle: true,
|
||||||
outfile: toArg
|
sourcemap: true,
|
||||||
|
format: 'esm',
|
||||||
|
target: 'es2022',
|
||||||
|
minify: true,
|
||||||
|
// outfile: toArg,
|
||||||
|
entryNames: 'bundle',
|
||||||
|
outdir: plugins.path.parse(toArg).dir,
|
||||||
|
tsconfig: paths.tsconfigPath,
|
||||||
|
splitting: true,
|
||||||
|
chunkNames: 'chunks/[name]-[hash]',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -47,7 +63,7 @@ export class TsBundleProcess {
|
|||||||
const run = async () => {
|
const run = async () => {
|
||||||
console.log('running spawned compilation process');
|
console.log('running spawned compilation process');
|
||||||
const transportOptions: interfaces.IEnvTransportOptions = JSON.parse(process.env.transportOptions);
|
const transportOptions: interfaces.IEnvTransportOptions = JSON.parse(process.env.transportOptions);
|
||||||
console.log('bundling with esbuild:');
|
console.log('=======> ESBUILD');
|
||||||
console.log(transportOptions);
|
console.log(transportOptions);
|
||||||
process.chdir(transportOptions.cwd);
|
process.chdir(transportOptions.cwd);
|
||||||
console.log(`switched to ${process.cwd()}`);
|
console.log(`switched to ${process.cwd()}`);
|
||||||
|
47
ts/mod_html/index.ts
Normal file
47
ts/mod_html/index.ts
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
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 processHtml(optionsArg: {
|
||||||
|
from?: string;
|
||||||
|
to?: string;
|
||||||
|
minify?: boolean;
|
||||||
|
}) {
|
||||||
|
optionsArg = {
|
||||||
|
... {
|
||||||
|
from: this.defaultFromPath,
|
||||||
|
to: this.defaultToPath,
|
||||||
|
minify: false,
|
||||||
|
},
|
||||||
|
...optionsArg
|
||||||
|
}
|
||||||
|
if (await this.checkIfExists()) {
|
||||||
|
console.log(`${optionsArg.from} replaces file at ${optionsArg.to}`);
|
||||||
|
}
|
||||||
|
optionsArg.from = plugins.smartpath.transform.toAbsolute(optionsArg.from, paths.cwd) as string;
|
||||||
|
optionsArg.to = plugins.smartpath.transform.toAbsolute(optionsArg.to, paths.cwd) as string;
|
||||||
|
let fileString = plugins.smartfile.fs.toStringSync(optionsArg.from);
|
||||||
|
if (optionsArg.minify) {
|
||||||
|
fileString = 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(fileString, optionsArg.to);
|
||||||
|
console.log(`html processing 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');
|
||||||
|
@ -4,13 +4,13 @@ import * as path from 'path';
|
|||||||
export { path };
|
export { path };
|
||||||
|
|
||||||
// pushrocks scope
|
// pushrocks scope
|
||||||
import * as smartcli from '@pushrocks/smartcli';
|
import * as smartcli from '@push.rocks/smartcli';
|
||||||
import * as smartfile from '@pushrocks/smartfile';
|
import * as smartfile from '@push.rocks/smartfile';
|
||||||
import * as smartlog from '@pushrocks/smartlog';
|
import * as smartlog from '@push.rocks/smartlog';
|
||||||
import * as smartlogDestinationLocal from '@pushrocks/smartlog-destination-local';
|
import * as smartlogDestinationLocal from '@push.rocks/smartlog-destination-local';
|
||||||
import * as smartpath from '@pushrocks/smartpath';
|
import * as smartpath from '@push.rocks/smartpath';
|
||||||
import * as smartpromise from '@pushrocks/smartpromise';
|
import * as smartpromise from '@push.rocks/smartpromise';
|
||||||
import * as smartspawn from '@pushrocks/smartspawn';
|
import * as smartspawn from '@push.rocks/smartspawn';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
smartcli,
|
smartcli,
|
||||||
|
@ -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,10 +1,11 @@
|
|||||||
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 () => {
|
||||||
const tsBundleCli = new plugins.smartcli.Smartcli();
|
const tsBundleCli = new plugins.smartcli.Smartcli();
|
||||||
tsBundleCli.standardTask().subscribe(async (argvArg) => {
|
tsBundleCli.standardCommand().subscribe(async (argvArg) => {
|
||||||
const tsbundle = new TsBundle();
|
const tsbundle = new TsBundle();
|
||||||
await tsbundle.build(process.cwd(), argvArg.from, argvArg.to, argvArg);
|
await tsbundle.build(process.cwd(), argvArg.from, argvArg.to, argvArg);
|
||||||
return;
|
return;
|
||||||
@ -12,7 +13,6 @@ 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();
|
|
||||||
await tsbundle.build(
|
await tsbundle.build(
|
||||||
process.cwd(),
|
process.cwd(),
|
||||||
'./ts_web/index.ts',
|
'./ts_web/index.ts',
|
||||||
@ -23,6 +23,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 +34,21 @@ 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
|
||||||
);
|
);
|
||||||
|
const htmlFiles = await plugins.smartfile.fs.listFiles('./html', /\.html/);
|
||||||
|
for (const htmlFile of htmlFiles) {
|
||||||
|
await htmlHandler.processHtml({
|
||||||
|
from: `./html/${htmlFile}`,
|
||||||
|
to: `./dist_serve/${htmlFile}`,
|
||||||
|
minify: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
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