Compare commits
40 Commits
Author | SHA1 | Date | |
---|---|---|---|
6a33742e27 | |||
3d201016fd | |||
57405ac944 | |||
508bb44348 | |||
834934f10e | |||
80dfe00743 | |||
b5f6e8a2ca | |||
ae375e30e3 | |||
a5d1927dcb | |||
69bdb3796d | |||
72af757ea0 | |||
a7d87f7e20 | |||
4f556c35b3 | |||
8dc25d000f | |||
b4f013d6c6 | |||
9c69c26d66 | |||
2969d4ad7b | |||
2dbc1bd1e1 | |||
15c274be9e | |||
0a6a49b7ad | |||
0b6409b468 | |||
1c327e6526 | |||
00ab4d3610 | |||
0adb181bbf | |||
053ef1f770 | |||
d35f32d68f | |||
fb6207d963 | |||
e6c2288c24 | |||
b925fffc58 | |||
5289d2af92 | |||
b7d1321f3f | |||
3d32d703bf | |||
f2c02e6afc | |||
1a4ff7811c | |||
93431fc2e1 | |||
1c039592ce | |||
cb575d2427 | |||
d6ad2797cb | |||
7256e3d0e3 | |||
fee9b56568 |
5
.gitignore
vendored
5
.gitignore
vendored
@ -8,9 +8,12 @@ pages/
|
|||||||
# installs
|
# installs
|
||||||
node_modules/
|
node_modules/
|
||||||
|
|
||||||
# caches and builds
|
# caches
|
||||||
.yarn/
|
.yarn/
|
||||||
.cache/
|
.cache/
|
||||||
|
.rpt2_cache
|
||||||
|
|
||||||
|
# builds
|
||||||
dist/
|
dist/
|
||||||
dist_web/
|
dist_web/
|
||||||
dist_serve/
|
dist_serve/
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# gitzone standard
|
# gitzone ci_default
|
||||||
image: hosttoday/ht-docker-node:npmci
|
image: hosttoday/ht-docker-node:npmci
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
@ -78,19 +78,11 @@ release:
|
|||||||
# ====================
|
# ====================
|
||||||
codequality:
|
codequality:
|
||||||
stage: metadata
|
stage: metadata
|
||||||
image: docker:stable
|
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
services:
|
|
||||||
- docker:stable-dind
|
|
||||||
script:
|
script:
|
||||||
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
|
- npmci command npm install -g tslint typescript
|
||||||
- docker run
|
- npmci npm install
|
||||||
--env SOURCE_CODE="$PWD"
|
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
||||||
--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]
|
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
- priv
|
- priv
|
||||||
@ -109,10 +101,10 @@ pages:
|
|||||||
image: hosttoday/ht-docker-node:npmci
|
image: hosttoday/ht-docker-node:npmci
|
||||||
stage: metadata
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
- npmci command npm install -g typedoc typescript
|
- npmci command npm install -g @gitzone/tsdoc
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
|
- npmci command tsdoc
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
const plugins = [
|
|
||||||
'@babel/plugin-proposal-class-properties',
|
|
||||||
['@babel/plugin-proposal-decorators', { decoratorsBeforeExport: true } ],
|
|
||||||
];
|
|
||||||
|
|
||||||
module.exports = { plugins };
|
|
3
cli.js
Normal file
3
cli.js
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
process.env.CLI_CALL = 'true';
|
||||||
|
require('./dist/index');
|
4
cli.ts.js
Normal file
4
cli.ts.js
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
process.env.CLI_CALL = 'true';
|
||||||
|
require('@gitzone/tsrun');
|
||||||
|
require('./ts/index');
|
1583
package-lock.json
generated
1583
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
36
package.json
36
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@gitzone/tsbundle",
|
"name": "@gitzone/tsbundle",
|
||||||
"version": "1.0.4",
|
"version": "1.0.24",
|
||||||
"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/index.js",
|
"main": "dist/index.js",
|
||||||
@ -8,27 +8,49 @@
|
|||||||
"author": "Lossless GmbH",
|
"author": "Lossless GmbH",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(tstest test/)",
|
"test": "cd test && node ../cli.ts.js --production",
|
||||||
"build": "(tsbuild)",
|
"build": "(tsbuild)",
|
||||||
"format": "(gitzone format)"
|
"format": "(gitzone format)"
|
||||||
},
|
},
|
||||||
|
"bin": {
|
||||||
|
"tsbundle": "cli.js"
|
||||||
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.0.22",
|
"@gitzone/tsbuild": "^2.1.11",
|
||||||
|
"@gitzone/tsrun": "^1.2.6",
|
||||||
"@gitzone/tstest": "^1.0.15",
|
"@gitzone/tstest": "^1.0.15",
|
||||||
"@pushrocks/tapbundle": "^3.0.7",
|
"@pushrocks/tapbundle": "^3.0.7",
|
||||||
"@types/node": "^10.11.7",
|
"@types/node": "^11.13.8",
|
||||||
"tslint": "^5.11.0",
|
"tslint": "^5.11.0",
|
||||||
"tslint-config-prettier": "^1.15.0"
|
"tslint-config-prettier": "^1.15.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/core": "^7.4.3",
|
"@babel/core": "^7.4.4",
|
||||||
"@babel/plugin-proposal-class-properties": "^7.4.4",
|
"@babel/plugin-proposal-class-properties": "^7.4.4",
|
||||||
"@babel/plugin-proposal-decorators": "^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": "^1.10.1",
|
||||||
"rollup-plugin-babel": "^4.3.2",
|
"rollup-plugin-babel": "^4.3.2",
|
||||||
"rollup-plugin-commonjs": "^9.3.4",
|
"rollup-plugin-commonjs": "^9.3.4",
|
||||||
"rollup-plugin-node-resolve": "^4.2.3",
|
"rollup-plugin-node-resolve": "^4.2.3",
|
||||||
"rollup-plugin-sourcemaps": "^0.4.2",
|
"rollup-plugin-sourcemaps": "^0.4.2",
|
||||||
"rollup-plugin-typescript2": "^0.20.1"
|
"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"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
@ -17,10 +17,18 @@ a bundler using rollup for painless bundling of web projects
|
|||||||
[](https://prettier.io/)
|
[](https://prettier.io/)
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Use TypeScript for best in class intellisense.
|
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.
|
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)
|
||||||
|
|
||||||
|
[](https://maintainedby.lossless.com)
|
||||||
|
|
||||||
|
For further information read the linked docs at the top of this readme.
|
||||||
|
|
||||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
||||||
|
|
||||||
|
@ -1,38 +1,57 @@
|
|||||||
import resolve from 'rollup-plugin-node-resolve'
|
import resolve from 'rollup-plugin-node-resolve';
|
||||||
import commonjs from 'rollup-plugin-commonjs'
|
import commonjs from 'rollup-plugin-commonjs';
|
||||||
import sourceMaps from 'rollup-plugin-sourcemaps'
|
import sourceMaps from 'rollup-plugin-sourcemaps';
|
||||||
import camelCase from 'lodash.camelcase'
|
import typescript from 'rollup-plugin-typescript2';
|
||||||
import typescript from 'rollup-plugin-typescript2'
|
import json from 'rollup-plugin-json';
|
||||||
import json from 'rollup-plugin-json'
|
import babel from 'rollup-plugin-babel';
|
||||||
|
|
||||||
const pkg = require('./package.json')
|
const pkg = require('./package.json');
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
input: `src/index.ts`,
|
input: `ts_web/index.ts`,
|
||||||
output: {
|
output: {
|
||||||
file: 'ts/index.ts',
|
name: 'tsbundle',
|
||||||
format: 'es',
|
// file: 'dist_web/bundle.js',
|
||||||
sourcemap: true
|
file: 'dist_web/bundle.js',
|
||||||
},
|
format: 'iife',
|
||||||
|
sourcemap: true
|
||||||
|
},
|
||||||
// Indicate here external modules you don't wanna include in your bundle (i.e.: 'lodash')
|
// Indicate here external modules you don't wanna include in your bundle (i.e.: 'lodash')
|
||||||
external: [],
|
external: [],
|
||||||
watch: {
|
watch: {
|
||||||
include: 'src/**',
|
include: 'src/**'
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
// Allow json resolution
|
// Allow json resolution
|
||||||
json(),
|
json(),
|
||||||
// Compile TypeScript files
|
// Compile TypeScript files
|
||||||
typescript({ useTsconfigDeclarationDir: true }),
|
typescript({ useTsconfigDeclarationDir: true, tsconfigOverride: {
|
||||||
// Allow bundling cjs modules (unlike webpack, rollup doesn't understand cjs)
|
compilerOptions: {
|
||||||
commonjs(),
|
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
|
// Allow node_modules resolution, so you can use 'external' to control
|
||||||
// which external modules to include in the bundle
|
// which external modules to include in the bundle
|
||||||
// https://github.com/rollup/rollup-plugin-node-resolve#usage
|
// https://github.com/rollup/rollup-plugin-node-resolve#usage
|
||||||
resolve(),
|
resolve(),
|
||||||
|
commonjs({
|
||||||
|
namedExports: {
|
||||||
|
'node_modules/@pushrocks/smartstate/dist/index.js': ['Smartstate']
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
|
||||||
// Resolve source maps to the original source
|
// Resolve source maps to the original source
|
||||||
sourceMaps(),
|
sourceMaps(),
|
||||||
babel()
|
babel({
|
||||||
],
|
extensions: ['.js', '.jsx', '.ts', '.tsx'],
|
||||||
}
|
babelrc: false,
|
||||||
|
presets: [["@babel/preset-env", { modules: false }]]
|
||||||
|
})
|
||||||
|
]
|
||||||
|
};
|
||||||
|
@ -2,7 +2,8 @@ import { expect, tap } from '@pushrocks/tapbundle';
|
|||||||
import * as tsbundle from '../ts/index';
|
import * as tsbundle from '../ts/index';
|
||||||
|
|
||||||
tap.test('first test', async () => {
|
tap.test('first test', async () => {
|
||||||
console.log(tsbundle.standardExport);
|
tsbundle;
|
||||||
|
console.log('hi');
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.start();
|
tap.start();
|
||||||
|
3
test/ts_web/index.ts
Normal file
3
test/ts_web/index.ts
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
const myConst = 'hello';
|
||||||
|
|
||||||
|
console.log(myConst);
|
13
ts/index.ts
13
ts/index.ts
@ -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();
|
||||||
|
}
|
||||||
|
113
ts/tsbundle.class.tsbundle.ts
Normal file
113
ts/tsbundle.class.tsbundle.ts
Normal 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
23
ts/tsbundle.cli.ts
Normal 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
15
ts/tsbundle.logging.ts
Normal 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());
|
@ -1,2 +1,25 @@
|
|||||||
const removeme = {};
|
// pushrocks scope
|
||||||
export { removeme };
|
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
|
||||||
|
};
|
||||||
|
Reference in New Issue
Block a user