Compare commits

...

44 Commits

Author SHA1 Message Date
6a33742e27 1.0.24 2019-06-16 17:03:47 +02:00
3d201016fd fix(core): update 2019-06-16 17:03:47 +02:00
57405ac944 1.0.23 2019-06-16 17:02:38 +02:00
508bb44348 fix(core): update 2019-06-16 17:02:38 +02:00
834934f10e 1.0.22 2019-05-08 11:05:14 +02:00
80dfe00743 fix(core): update 2019-05-08 11:05:13 +02:00
b5f6e8a2ca 1.0.21 2019-05-06 14:00:21 +02:00
ae375e30e3 fix(core): 2019-05-06 14:00:21 +02:00
a5d1927dcb 1.0.20 2019-04-30 16:08:10 +02:00
69bdb3796d fix(core): update 2019-04-30 16:08:09 +02:00
72af757ea0 1.0.19 2019-04-30 16:00:38 +02:00
a7d87f7e20 fix(core): update 2019-04-30 16:00:38 +02:00
4f556c35b3 1.0.18 2019-04-30 13:50:19 +02:00
8dc25d000f fix(core): update 2019-04-30 13:50:19 +02:00
b4f013d6c6 1.0.17 2019-04-30 13:38:17 +02:00
9c69c26d66 fix(core): update 2019-04-30 13:38:17 +02:00
2969d4ad7b 1.0.16 2019-04-30 13:12:58 +02:00
2dbc1bd1e1 fix(core): update 2019-04-30 13:12:57 +02:00
15c274be9e 1.0.15 2019-04-30 12:49:10 +02:00
0a6a49b7ad fix(core): update 2019-04-30 12:49:10 +02:00
0b6409b468 1.0.14 2019-04-30 11:37:06 +02:00
1c327e6526 fix(core): update 2019-04-30 11:37:05 +02:00
00ab4d3610 1.0.13 2019-04-30 11:23:00 +02:00
0adb181bbf fix(core): update 2019-04-30 11:22:59 +02:00
053ef1f770 1.0.12 2019-04-30 10:55:43 +02:00
d35f32d68f fix(core): update 2019-04-30 10:55:43 +02:00
fb6207d963 1.0.11 2019-04-30 10:54:03 +02:00
e6c2288c24 fix(core): update 2019-04-30 10:54:03 +02:00
b925fffc58 1.0.10 2019-04-30 10:39:54 +02:00
5289d2af92 fix(core): update 2019-04-30 10:39:54 +02:00
b7d1321f3f 1.0.9 2019-04-30 10:28:00 +02:00
3d32d703bf fix(core): update 2019-04-30 10:28:00 +02:00
f2c02e6afc 1.0.8 2019-04-30 10:01:23 +02:00
1a4ff7811c fix(core): update 2019-04-30 10:01:23 +02:00
93431fc2e1 1.0.7 2019-04-30 09:44:47 +02:00
1c039592ce fix(core): update 2019-04-30 09:44:46 +02:00
cb575d2427 1.0.6 2019-04-30 08:42:55 +02:00
d6ad2797cb fix(core): update 2019-04-30 08:42:55 +02:00
7256e3d0e3 1.0.5 2019-04-30 08:35:01 +02:00
fee9b56568 fix(core): update 2019-04-30 08:35:00 +02:00
14a273e5c4 1.0.4 2019-04-29 22:29:56 +02:00
453c72b87e fix(core): update 2019-04-29 22:29:56 +02:00
bf8b6e9fdb 1.0.3 2019-04-29 22:11:24 +02:00
204a4692ac fix(core): update 2019-04-29 22:11:24 +02:00
15 changed files with 3064 additions and 311 deletions

5
.gitignore vendored
View File

@ -8,9 +8,12 @@ pages/
# installs
node_modules/
# caches and builds
# caches
.yarn/
.cache/
.rpt2_cache
# builds
dist/
dist_web/
dist_serve/

View File

@ -1,4 +1,4 @@
# gitzone standard
# gitzone ci_default
image: hosttoday/ht-docker-node:npmci
cache:
@ -78,19 +78,11 @@ release:
# ====================
codequality:
stage: metadata
image: docker:stable
allow_failure: true
services:
- docker:stable-dind
script:
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
- docker run
--env SOURCE_CODE="$PWD"
--volume "$PWD":/code
--volume /var/run/docker.sock:/var/run/docker.sock
"registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
artifacts:
paths: [codeclimate.json]
- npmci command npm install -g tslint typescript
- npmci npm install
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
tags:
- docker
- priv
@ -109,10 +101,10 @@ pages:
image: hosttoday/ht-docker-node:npmci
stage: metadata
script:
- npmci command npm install -g typedoc typescript
- npmci command npm install -g @gitzone/tsdoc
- npmci npm prepare
- npmci npm install
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
- npmci command tsdoc
tags:
- docker
- notpriv

3
cli.js Normal file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env node
process.env.CLI_CALL = 'true';
require('./dist/index');

4
cli.ts.js Normal file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env node
process.env.CLI_CALL = 'true';
require('@gitzone/tsrun');
require('./ts/index');

3038
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "@gitzone/tsbundle",
"version": "1.0.2",
"version": "1.0.24",
"private": false,
"description": "a bundler using rollup for painless bundling of web projects",
"main": "dist/index.js",
@ -8,17 +8,49 @@
"author": "Lossless GmbH",
"license": "MIT",
"scripts": {
"test": "(tstest test/)",
"test": "cd test && node ../cli.ts.js --production",
"build": "(tsbuild)",
"format": "(gitzone format)"
},
"bin": {
"tsbundle": "cli.js"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.0.22",
"@gitzone/tsbuild": "^2.1.11",
"@gitzone/tsrun": "^1.2.6",
"@gitzone/tstest": "^1.0.15",
"@pushrocks/tapbundle": "^3.0.7",
"@types/node": "^10.11.7",
"@types/node": "^11.13.8",
"tslint": "^5.11.0",
"tslint-config-prettier": "^1.15.0"
},
"dependencies": {}
"dependencies": {
"@babel/core": "^7.4.4",
"@babel/plugin-proposal-class-properties": "^7.4.4",
"@babel/plugin-proposal-decorators": "^7.4.4",
"@babel/plugin-transform-runtime": "^7.4.4",
"@babel/preset-env": "^7.4.4",
"@babel/runtime": "^7.4.4",
"@pushrocks/early": "^3.0.3",
"@pushrocks/smartcli": "^3.0.7",
"@pushrocks/smartlog": "^2.0.19",
"@pushrocks/smartlog-destination-local": "^7.0.5",
"rollup": "^1.10.1",
"rollup-plugin-babel": "^4.3.2",
"rollup-plugin-commonjs": "^9.3.4",
"rollup-plugin-node-resolve": "^4.2.3",
"rollup-plugin-sourcemaps": "^0.4.2",
"rollup-plugin-terser": "^5.0.0",
"rollup-plugin-typescript2": "^0.21.0"
},
"files": [
"ts/*",
"ts_web/*",
"dist/*",
"dist_web/*",
"assets/*",
"cli.js",
"npmextra.json",
"readme.md"
]
}

View File

@ -18,6 +18,15 @@ a bundler using rollup for painless bundling of web projects
## Usage
Use TypeScript for best in class intellisense.
tsbundle will bundle modern JavaScript websites in an Google Bot conformant way so things like AdSense do work.
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
[![repo-footer](https://gitzone.gitlab.io/assets/repo-footer.svg)](https://maintainedby.lossless.com)
For further information read the linked docs at the top of this readme.
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)

57
rollup.config.js Normal file
View File

@ -0,0 +1,57 @@
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import sourceMaps from 'rollup-plugin-sourcemaps';
import typescript from 'rollup-plugin-typescript2';
import json from 'rollup-plugin-json';
import babel from 'rollup-plugin-babel';
const pkg = require('./package.json');
export default {
input: `ts_web/index.ts`,
output: {
name: 'tsbundle',
// file: 'dist_web/bundle.js',
file: 'dist_web/bundle.js',
format: 'iife',
sourcemap: true
},
// Indicate here external modules you don't wanna include in your bundle (i.e.: 'lodash')
external: [],
watch: {
include: 'src/**'
},
plugins: [
// Allow json resolution
json(),
// Compile TypeScript files
typescript({ useTsconfigDeclarationDir: true, tsconfigOverride: {
compilerOptions: {
declaration: true,
emitDecoratorMetadata: true,
experimentalDecorators: true,
inlineSourceMap: true,
noEmitOnError: true,
lib: ['es2016', 'es2017', 'dom'],
noImplicitAny: false
}
} }),
// 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
resolve(),
commonjs({
namedExports: {
'node_modules/@pushrocks/smartstate/dist/index.js': ['Smartstate']
}
}),
// Resolve source maps to the original source
sourceMaps(),
babel({
extensions: ['.js', '.jsx', '.ts', '.tsx'],
babelrc: false,
presets: [["@babel/preset-env", { modules: false }]]
})
]
};

View File

@ -2,7 +2,8 @@ import { expect, tap } from '@pushrocks/tapbundle';
import * as tsbundle from '../ts/index';
tap.test('first test', async () => {
console.log(tsbundle.standardExport);
tsbundle;
console.log('hi');
});
tap.start();

3
test/ts_web/index.ts Normal file
View File

@ -0,0 +1,3 @@
const myConst = 'hello';
console.log(myConst);

View File

@ -1,3 +1,12 @@
import * as plugins from './tsbundle.plugins';
import * as early from '@pushrocks/early';
early.start('tsbundle');
// lets import all plugins beforehand
import './tsbundle.plugins';
export let standardExport = 'Hi there! :) This is an exported string';
import { logger } from './tsbundle.logging';
import { runCli } from './tsbundle.cli';
early.stop();
if (process.env.CLI_CALL) {
runCli();
}

View File

@ -0,0 +1,113 @@
import * as plugins from './tsbundle.plugins';
import { logger } from './tsbundle.logging';
export class TsBundle {
public optionsTest: plugins.rollup.RollupOptions = this.getBaseOptions();
public optionsProduction: plugins.rollup.RollupOptions = (() => {
const productionOptions = this.getBaseOptions();
productionOptions.plugins.push(plugins.rollupTerser());
return productionOptions;
})();
constructor() {}
/**
* creates a bundle for the test enviroment
*/
public async buildTest() {
// create a bundle
logger.log('info', `bundling for TEST!`);
const bundle = await plugins.rollup.rollup(this.optionsTest);
bundle.generate(this.optionsTest.output);
bundle.write(this.optionsTest.output);
logger.log('ok', `Successfully bundled files!`);
}
/**
* creates a bundle for the production environment
*/
public async buildProduction() {
// create a bundle
logger.log('info', `bundling for PRODUCTION!`);
const bundle = await plugins.rollup.rollup(this.optionsProduction);
bundle.generate(this.optionsProduction.output);
bundle.write(this.optionsProduction.output);
logger.log('ok', `Successfully bundled files!`);
}
/**
* the basic default options for rollup
*/
public getBaseOptions() {
const baseOptions: plugins.rollup.RollupOptions = {
input: `ts_web/index.ts`,
output: {
name: 'tsbundle',
// file: 'dist_web/bundle.js',
file: 'dist_web/bundle.js',
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({
useTsconfigDeclarationDir: true,
tsconfigOverride: {
compilerOptions: {
declaration: true,
emitDecoratorMetadata: true,
experimentalDecorators: true,
inlineSourceMap: true,
noEmitOnError: true,
lib: ['es2017', 'dom'],
target: 'es2017',
noImplicitAny: false
}
}
}),
// 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({
namedExports: {
'node_modules/@pushrocks/smartstate/dist/index.js': ['Smartstate']
}
}),
// Resolve source maps to the original source
plugins.rollupSourceMaps(),
plugins.rollupBabel({
runtimeHelpers: true,
extensions: ['.js', '.jsx', '.ts', '.tsx'],
babelrc: false,
presets: [
[
'@babel/preset-env',
{
modules: false,
targets: {
chrome: '41'
}
}
]
],
plugins: [
[
'@babel/plugin-transform-runtime',
{
regenerator: true
}
]
]
})
]
};
return baseOptions;
}
}

23
ts/tsbundle.cli.ts Normal file
View File

@ -0,0 +1,23 @@
import * as plugins from './tsbundle.plugins';
import { TsBundle } from './tsbundle.class.tsbundle';
import { logger } from './tsbundle.logging';
export const runCli = async () => {
const tsBundleCli = new plugins.smartcli.Smartcli();
tsBundleCli.standardTask().subscribe(async argvArg => {
const tsbundle = new TsBundle();
switch (true) {
case argvArg.production:
await tsbundle.buildProduction();
break;
case argvArg.test:
await tsbundle.buildTest();
break;
default:
logger.log('error', `Can not determine build target environement. Please specify via --production or --test`)
return;
}
});
tsBundleCli.startParse();
};

15
ts/tsbundle.logging.ts Normal file
View File

@ -0,0 +1,15 @@
import * as plugins from './tsbundle.plugins';
export const logger = new plugins.smartlog.Smartlog({
logContext: {
company: 'Some Company',
companyunit: 'Some CompanyUnit',
containerName: 'Some Containername',
environment: 'local',
runtime: 'node',
zone: 'gitzone'
},
minimumLogLevel: 'silly'
});
logger.addLogDestination(new plugins.smartlogDestinationLocal.DestinationLocal());

View File

@ -1,2 +1,25 @@
const removeme = {};
export { removeme };
// pushrocks scope
import * as smartcli from '@pushrocks/smartcli';
import * as smartlog from '@pushrocks/smartlog';
import * as smartlogDestinationLocal from '@pushrocks/smartlog-destination-local';
export { smartcli, smartlog, smartlogDestinationLocal };
// third party scope
import * as rollup from 'rollup';
import rollupBabel from 'rollup-plugin-babel';
import rollupCommonjs from 'rollup-plugin-commonjs';
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-typescript2';
export {
rollup,
rollupBabel,
rollupCommonjs,
rollupResolve,
rollupSourceMaps,
rollupTerser,
rollupTypescript
};