fix(core): update

This commit is contained in:
Philipp Kunz 2021-07-23 15:45:23 +02:00
parent 07718ba618
commit ba44efe4cc
7 changed files with 449 additions and 147 deletions

240
package-lock.json generated
View File

@ -21,6 +21,8 @@
"@pushrocks/smartlog": "^2.0.44",
"@pushrocks/smartlog-destination-local": "^8.0.8",
"@pushrocks/smartparcel": "^1.0.9",
"@pushrocks/smartpromise": "^3.1.6",
"@pushrocks/smartspawn": "^2.0.9",
"@rollup/plugin-commonjs": "^19.0.1",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.0.2",
@ -2623,6 +2625,17 @@
"@tsclass/tsclass": "^3.0.29"
}
},
"node_modules/@pushrocks/smartspawn": {
"version": "2.0.9",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartspawn/-/smartspawn-2.0.9.tgz",
"integrity": "sha512-PKg4UWmIBc4kE92V91VNsarxaDu3EWvhNtxybvnka/V82m4iZVWKpxGYt0fLsUj6vqJDla/wnkZImiBTlYGLcg==",
"license": "MIT",
"dependencies": {
"@pushrocks/smartpromise": "^3.0.2",
"spawn-wrap": "^1.4.2",
"threads": "1.0.0-beta.4"
}
},
"node_modules/@pushrocks/smartstring": {
"version": "3.0.24",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartstring/-/smartstring-3.0.24.tgz",
@ -3279,6 +3292,12 @@
"@types/node": "*"
}
},
"node_modules/@types/zen-observable": {
"version": "0.8.3",
"resolved": "https://verdaccio.lossless.one/@types%2fzen-observable/-/zen-observable-0.8.3.tgz",
"integrity": "sha512-fbF6oTd4sGGy0xjHPKAt+eS2CrxJ3+6gQ3FGcBoIJR2TLAyCkCyI8JqZNy+FeON0AhVgNJoUumVoZQjBFUqHkw==",
"license": "MIT"
},
"node_modules/abab": {
"version": "2.0.5",
"resolved": "https://verdaccio.lossless.one/abab/-/abab-2.0.5.tgz",
@ -6026,6 +6045,16 @@
"node": ">=0.10.0"
}
},
"node_modules/esm": {
"version": "3.2.25",
"resolved": "https://verdaccio.lossless.one/esm/-/esm-3.2.25.tgz",
"integrity": "sha512-U1suiZ2oDVWv4zPO56S0NcR5QriEahGtdN2OR6FiOG4WJvcjBVFB0qI4+eKoWFH483PKGuLuu6V8Z4T5g63UVA==",
"license": "MIT",
"optional": true,
"engines": {
"node": ">=6"
}
},
"node_modules/esprima": {
"version": "3.1.3",
"resolved": "https://verdaccio.lossless.one/esprima/-/esprima-3.1.3.tgz",
@ -6559,6 +6588,26 @@
"integrity": "sha1-C+4AUBiusmDQo6865ljdATbsG5k=",
"license": "MIT"
},
"node_modules/foreground-child": {
"version": "1.5.6",
"resolved": "https://verdaccio.lossless.one/foreground-child/-/foreground-child-1.5.6.tgz",
"integrity": "sha1-T9ca0t/elnibmApcCilZN8svXOk=",
"license": "ISC",
"dependencies": {
"cross-spawn": "^4",
"signal-exit": "^3.0.0"
}
},
"node_modules/foreground-child/node_modules/cross-spawn": {
"version": "4.0.2",
"resolved": "https://verdaccio.lossless.one/cross-spawn/-/cross-spawn-4.0.2.tgz",
"integrity": "sha1-e5JHYhwjrf3ThWAEqCPL45dCTUE=",
"license": "MIT",
"dependencies": {
"lru-cache": "^4.0.1",
"which": "^1.2.9"
}
},
"node_modules/forever-agent": {
"version": "0.6.1",
"resolved": "https://verdaccio.lossless.one/forever-agent/-/forever-agent-0.6.1.tgz",
@ -7793,6 +7842,18 @@
"node": ">=8"
}
},
"node_modules/is-observable": {
"version": "1.1.0",
"resolved": "https://verdaccio.lossless.one/is-observable/-/is-observable-1.1.0.tgz",
"integrity": "sha512-NqCa4Sa2d+u7BWc6CukaObG3Fh+CU9bvixbpcXYhy2VvYS7vVGIdAgnIS5Ks3A/cqk4rebLJ9s8zBstT2aKnIA==",
"license": "MIT",
"dependencies": {
"symbol-observable": "^1.1.0"
},
"engines": {
"node": ">=4"
}
},
"node_modules/is-plain-object": {
"version": "2.0.4",
"resolved": "https://verdaccio.lossless.one/is-plain-object/-/is-plain-object-2.0.4.tgz",
@ -9407,6 +9468,15 @@
"integrity": "sha1-hUNzx/XCMVkU/Jv8a9gjj92h7Cc=",
"license": "MIT"
},
"node_modules/os-homedir": {
"version": "1.0.2",
"resolved": "https://verdaccio.lossless.one/os-homedir/-/os-homedir-1.0.2.tgz",
"integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M=",
"license": "MIT",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/p-cancelable": {
"version": "1.1.0",
"resolved": "https://verdaccio.lossless.one/p-cancelable/-/p-cancelable-1.1.0.tgz",
@ -12040,6 +12110,20 @@
"integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==",
"license": "MIT"
},
"node_modules/spawn-wrap": {
"version": "1.4.3",
"resolved": "https://verdaccio.lossless.one/spawn-wrap/-/spawn-wrap-1.4.3.tgz",
"integrity": "sha512-IgB8md0QW/+tWqcavuFgKYR/qIRvJkRLPJDFaoXtLLUaVcCDK0+HeFTkmQHj3eprcYhc+gOl0aEA1w7qZlYezw==",
"license": "ISC",
"dependencies": {
"foreground-child": "^1.5.6",
"mkdirp": "^0.5.0",
"os-homedir": "^1.0.1",
"rimraf": "^2.6.2",
"signal-exit": "^3.0.2",
"which": "^1.3.0"
}
},
"node_modules/split-string": {
"version": "3.1.0",
"resolved": "https://verdaccio.lossless.one/split-string/-/split-string-3.1.0.tgz",
@ -12530,6 +12614,15 @@
"js-yaml": "bin/js-yaml.js"
}
},
"node_modules/symbol-observable": {
"version": "1.2.0",
"resolved": "https://verdaccio.lossless.one/symbol-observable/-/symbol-observable-1.2.0.tgz",
"integrity": "sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ==",
"license": "MIT",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/symbol-tree": {
"version": "3.2.4",
"resolved": "https://verdaccio.lossless.one/symbol-tree/-/symbol-tree-3.2.4.tgz",
@ -12633,6 +12726,31 @@
"node": ">=0.10.0"
}
},
"node_modules/threads": {
"version": "1.0.0-beta.4",
"resolved": "https://verdaccio.lossless.one/threads/-/threads-1.0.0-beta.4.tgz",
"integrity": "sha512-iQNEWLuOmdBwMLqKX357VT0hkFS8/fmHXntycnq24ZE8IRh+cAsLvriuhMuv2uRP/ftzK/G8GikyKHZov8nAmg==",
"license": "MIT",
"dependencies": {
"@types/zen-observable": "^0.8.0",
"callsites": "^3.1.0",
"debug": "^4.1.1",
"is-observable": "^1.1.0",
"zen-observable": "^0.8.14"
},
"optionalDependencies": {
"tiny-worker": ">= 2"
}
},
"node_modules/threads/node_modules/callsites": {
"version": "3.1.0",
"resolved": "https://verdaccio.lossless.one/callsites/-/callsites-3.1.0.tgz",
"integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==",
"license": "MIT",
"engines": {
"node": ">=6"
}
},
"node_modules/through": {
"version": "2.3.8",
"resolved": "https://verdaccio.lossless.one/through/-/through-2.3.8.tgz",
@ -12687,6 +12805,16 @@
"integrity": "sha512-pkY1fj1cKHb2seWDy0B16HeWyczlJA9/WW3u3c4z/NiWDsO3DOU5D7nhTLE9CF0yXv/QZFY7sEJmj24dK+Rrqw==",
"license": "MIT"
},
"node_modules/tiny-worker": {
"version": "2.3.0",
"resolved": "https://verdaccio.lossless.one/tiny-worker/-/tiny-worker-2.3.0.tgz",
"integrity": "sha512-pJ70wq5EAqTAEl9IkGzA+fN0836rycEuz2Cn6yeZ6FRzlVS5IDOkFHpIoEsksPRQV34GDqXm65+OlnZqUSyK2g==",
"license": "BSD-3-Clause",
"optional": true,
"dependencies": {
"esm": "^3.2.25"
}
},
"node_modules/to-arraybuffer": {
"version": "1.0.1",
"resolved": "https://verdaccio.lossless.one/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz",
@ -13852,6 +13980,12 @@
"engines": {
"node": ">=6"
}
},
"node_modules/zen-observable": {
"version": "0.8.15",
"resolved": "https://verdaccio.lossless.one/zen-observable/-/zen-observable-0.8.15.tgz",
"integrity": "sha512-PQ2PC7R9rslx84ndNBZB/Dkv8V8fZEpk83RLgXtYd0fwUgEjseMn1Dgajh2x6S8QbZAFa9p2qVCEuYZNgve0dQ==",
"license": "MIT"
}
},
"dependencies": {
@ -15661,6 +15795,16 @@
"@tsclass/tsclass": "^3.0.29"
}
},
"@pushrocks/smartspawn": {
"version": "2.0.9",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartspawn/-/smartspawn-2.0.9.tgz",
"integrity": "sha512-PKg4UWmIBc4kE92V91VNsarxaDu3EWvhNtxybvnka/V82m4iZVWKpxGYt0fLsUj6vqJDla/wnkZImiBTlYGLcg==",
"requires": {
"@pushrocks/smartpromise": "^3.0.2",
"spawn-wrap": "^1.4.2",
"threads": "1.0.0-beta.4"
}
},
"@pushrocks/smartstring": {
"version": "3.0.24",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartstring/-/smartstring-3.0.24.tgz",
@ -16204,6 +16348,11 @@
"@types/node": "*"
}
},
"@types/zen-observable": {
"version": "0.8.3",
"resolved": "https://verdaccio.lossless.one/@types%2fzen-observable/-/zen-observable-0.8.3.tgz",
"integrity": "sha512-fbF6oTd4sGGy0xjHPKAt+eS2CrxJ3+6gQ3FGcBoIJR2TLAyCkCyI8JqZNy+FeON0AhVgNJoUumVoZQjBFUqHkw=="
},
"abab": {
"version": "2.0.5",
"resolved": "https://verdaccio.lossless.one/abab/-/abab-2.0.5.tgz",
@ -18231,6 +18380,12 @@
}
}
},
"esm": {
"version": "3.2.25",
"resolved": "https://verdaccio.lossless.one/esm/-/esm-3.2.25.tgz",
"integrity": "sha512-U1suiZ2oDVWv4zPO56S0NcR5QriEahGtdN2OR6FiOG4WJvcjBVFB0qI4+eKoWFH483PKGuLuu6V8Z4T5g63UVA==",
"optional": true
},
"esprima": {
"version": "3.1.3",
"resolved": "https://verdaccio.lossless.one/esprima/-/esprima-3.1.3.tgz",
@ -18627,6 +18782,26 @@
"resolved": "https://verdaccio.lossless.one/foreach/-/foreach-2.0.5.tgz",
"integrity": "sha1-C+4AUBiusmDQo6865ljdATbsG5k="
},
"foreground-child": {
"version": "1.5.6",
"resolved": "https://verdaccio.lossless.one/foreground-child/-/foreground-child-1.5.6.tgz",
"integrity": "sha1-T9ca0t/elnibmApcCilZN8svXOk=",
"requires": {
"cross-spawn": "^4",
"signal-exit": "^3.0.0"
},
"dependencies": {
"cross-spawn": {
"version": "4.0.2",
"resolved": "https://verdaccio.lossless.one/cross-spawn/-/cross-spawn-4.0.2.tgz",
"integrity": "sha1-e5JHYhwjrf3ThWAEqCPL45dCTUE=",
"requires": {
"lru-cache": "^4.0.1",
"which": "^1.2.9"
}
}
}
},
"forever-agent": {
"version": "0.6.1",
"resolved": "https://verdaccio.lossless.one/forever-agent/-/forever-agent-0.6.1.tgz",
@ -19461,6 +19636,14 @@
"resolved": "https://verdaccio.lossless.one/is-obj/-/is-obj-2.0.0.tgz",
"integrity": "sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w=="
},
"is-observable": {
"version": "1.1.0",
"resolved": "https://verdaccio.lossless.one/is-observable/-/is-observable-1.1.0.tgz",
"integrity": "sha512-NqCa4Sa2d+u7BWc6CukaObG3Fh+CU9bvixbpcXYhy2VvYS7vVGIdAgnIS5Ks3A/cqk4rebLJ9s8zBstT2aKnIA==",
"requires": {
"symbol-observable": "^1.1.0"
}
},
"is-plain-object": {
"version": "2.0.4",
"resolved": "https://verdaccio.lossless.one/is-plain-object/-/is-plain-object-2.0.4.tgz",
@ -20627,6 +20810,11 @@
"resolved": "https://verdaccio.lossless.one/os-browserify/-/os-browserify-0.3.0.tgz",
"integrity": "sha1-hUNzx/XCMVkU/Jv8a9gjj92h7Cc="
},
"os-homedir": {
"version": "1.0.2",
"resolved": "https://verdaccio.lossless.one/os-homedir/-/os-homedir-1.0.2.tgz",
"integrity": "sha1-/7xJiDNuDoM94MFox+8VISGqf7M="
},
"p-cancelable": {
"version": "1.1.0",
"resolved": "https://verdaccio.lossless.one/p-cancelable/-/p-cancelable-1.1.0.tgz",
@ -22582,6 +22770,19 @@
"resolved": "https://verdaccio.lossless.one/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz",
"integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA=="
},
"spawn-wrap": {
"version": "1.4.3",
"resolved": "https://verdaccio.lossless.one/spawn-wrap/-/spawn-wrap-1.4.3.tgz",
"integrity": "sha512-IgB8md0QW/+tWqcavuFgKYR/qIRvJkRLPJDFaoXtLLUaVcCDK0+HeFTkmQHj3eprcYhc+gOl0aEA1w7qZlYezw==",
"requires": {
"foreground-child": "^1.5.6",
"mkdirp": "^0.5.0",
"os-homedir": "^1.0.1",
"rimraf": "^2.6.2",
"signal-exit": "^3.0.2",
"which": "^1.3.0"
}
},
"split-string": {
"version": "3.1.0",
"resolved": "https://verdaccio.lossless.one/split-string/-/split-string-3.1.0.tgz",
@ -22930,6 +23131,11 @@
}
}
},
"symbol-observable": {
"version": "1.2.0",
"resolved": "https://verdaccio.lossless.one/symbol-observable/-/symbol-observable-1.2.0.tgz",
"integrity": "sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ=="
},
"symbol-tree": {
"version": "3.2.4",
"resolved": "https://verdaccio.lossless.one/symbol-tree/-/symbol-tree-3.2.4.tgz",
@ -22996,6 +23202,26 @@
}
}
},
"threads": {
"version": "1.0.0-beta.4",
"resolved": "https://verdaccio.lossless.one/threads/-/threads-1.0.0-beta.4.tgz",
"integrity": "sha512-iQNEWLuOmdBwMLqKX357VT0hkFS8/fmHXntycnq24ZE8IRh+cAsLvriuhMuv2uRP/ftzK/G8GikyKHZov8nAmg==",
"requires": {
"@types/zen-observable": "^0.8.0",
"callsites": "^3.1.0",
"debug": "^4.1.1",
"is-observable": "^1.1.0",
"tiny-worker": ">= 2",
"zen-observable": "^0.8.14"
},
"dependencies": {
"callsites": {
"version": "3.1.0",
"resolved": "https://verdaccio.lossless.one/callsites/-/callsites-3.1.0.tgz",
"integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ=="
}
}
},
"through": {
"version": "2.3.8",
"resolved": "https://verdaccio.lossless.one/through/-/through-2.3.8.tgz",
@ -23040,6 +23266,15 @@
"resolved": "https://verdaccio.lossless.one/tiny-inflate/-/tiny-inflate-1.0.3.tgz",
"integrity": "sha512-pkY1fj1cKHb2seWDy0B16HeWyczlJA9/WW3u3c4z/NiWDsO3DOU5D7nhTLE9CF0yXv/QZFY7sEJmj24dK+Rrqw=="
},
"tiny-worker": {
"version": "2.3.0",
"resolved": "https://verdaccio.lossless.one/tiny-worker/-/tiny-worker-2.3.0.tgz",
"integrity": "sha512-pJ70wq5EAqTAEl9IkGzA+fN0836rycEuz2Cn6yeZ6FRzlVS5IDOkFHpIoEsksPRQV34GDqXm65+OlnZqUSyK2g==",
"optional": true,
"requires": {
"esm": "^3.2.25"
}
},
"to-arraybuffer": {
"version": "1.0.1",
"resolved": "https://verdaccio.lossless.one/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz",
@ -23853,6 +24088,11 @@
"resolved": "https://verdaccio.lossless.one/yn/-/yn-3.1.1.tgz",
"integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==",
"dev": true
},
"zen-observable": {
"version": "0.8.15",
"resolved": "https://verdaccio.lossless.one/zen-observable/-/zen-observable-0.8.15.tgz",
"integrity": "sha512-PQ2PC7R9rslx84ndNBZB/Dkv8V8fZEpk83RLgXtYd0fwUgEjseMn1Dgajh2x6S8QbZAFa9p2qVCEuYZNgve0dQ=="
}
}
}

View File

@ -8,7 +8,7 @@
"author": "Lossless GmbH",
"license": "MIT",
"scripts": {
"test": "(tstest test/) && (cd test && node ../cli.ts.js --production)",
"test": "npm run build && (tstest test/) && (cd test && node ../cli.js --production)",
"build": "(tsbuild --web)"
},
"bin": {
@ -35,6 +35,8 @@
"@pushrocks/smartlog": "^2.0.44",
"@pushrocks/smartlog-destination-local": "^8.0.8",
"@pushrocks/smartparcel": "^1.0.9",
"@pushrocks/smartpromise": "^3.1.6",
"@pushrocks/smartspawn": "^2.0.9",
"@rollup/plugin-commonjs": "^19.0.1",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.0.2",

View File

@ -1,15 +1,16 @@
import { expect, tap } from '@pushrocks/tapbundle';
import * as tsbundle from '../ts/index';
import * as tsbundle from '../dist_ts/index';
import * as path from 'path';
tap.skip.test('first test', async () => {
await tsbundle.runCli();
});
tap.test('should run a custom function', async () => {
tap.test('should bundle test', async () => {
const tsbundleInstance = new tsbundle.TsBundle();
await tsbundleInstance.buildProduction(process.cwd(), './test/ts_web/index.ts', './test/dist_manual/index.js')
await tsbundleInstance.buildTest(process.cwd() + '/test', './ts_web/index.ts', './dist_manual/test.js', 'rollup')
})
tap.test('should bundle production', async () => {
const tsbundleInstance = new tsbundle.TsBundle();
await tsbundleInstance.buildProduction(process.cwd(), './test/ts_web/index.ts', './test/dist_manual/production.js')
})
tap.start();

View File

@ -2,139 +2,40 @@ import * as plugins from './tsbundle.plugins';
import { logger } from './tsbundle.logging';
export class TsBundle {
/**
* the basic default options for rollup
*/
public getBaseOptions(
fromArg: string = `ts_web/index.ts`,
toArg: string = 'dist_bundle/bundle.js'
) {
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({
include: plugins.path.parse(fromArg).dir
? plugins.path.parse(fromArg).dir + '/**/*.ts'
: '**/*.ts',
declaration: false,
emitDecoratorMetadata: true,
experimentalDecorators: true,
inlineSourceMap: true,
noEmitOnError: true,
lib: ['esnext', 'dom', 'es2017.object'],
noImplicitAny: false,
target: 'es2018',
allowSyntheticDefaultImports: true,
}),
plugins.rollupJson(),
// 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({}),
// 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;
}
public getOptionsTest(fromArg: string, toArg: string): plugins.rollup.RollupOptions {
return this.getBaseOptions(fromArg, toArg);
}
public getOptionsProduction(fromArg: string, toArg: string): plugins.rollup.RollupOptions {
const productionOptions = this.getBaseOptions(fromArg, toArg);
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,
bundlerArg: 'rollup' | 'parcel' = 'rollup'
) {
// create a bundle
switch (bundlerArg) {
case 'rollup':
logger.log('info', `bundling for TEST!`);
const buildOptions = this.getOptionsTest(fromArg, toArg);
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!`);
break;
case 'parcel':
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 buildTest(cwdArg: string, fromArg: string, toArg: string, bundlerArg: 'rollup' | 'parcel') {
const done = plugins.smartpromise.defer();
const threadsimple = new plugins.smartspawn.ThreadSimple(plugins.path.join(__dirname, './tsbundle.class.tsbundleprocess.js'), [], {
env: {
...process.env,
tsbundleMode: 'test',
tsbundleCwd: cwdArg,
tsbundleFrom: fromArg,
tsbundleTo: toArg,
tsbundleBundler: bundlerArg
}
})
const childProcess = await threadsimple.start();
childProcess.on('exit', (status) => {
done.resolve();
})
await done.promise;
};
public async buildProduction(cwdArg: string, fromArg: string, toArg: string) {
process.chdir(cwdArg);
console.log(process.cwd())
// create a bundle
logger.log('info', `bundling for PRODUCTION!`);
const buildOptions = this.getOptionsProduction(fromArg, toArg);
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!`);
}
const done = plugins.smartpromise.defer();
const threadsimple = new plugins.smartspawn.ThreadSimple(plugins.path.join(__dirname, './tsbundle.class.tsbundleprocess.js'), [], {
env: {
...process.env,
tsbundleMode: 'production',
tsbundleCwd: cwdArg,
tsbundleFrom: fromArg,
tsbundleTo: toArg
}
})
const childProcess = await threadsimple.start();
childProcess.on('exit', (status) => {
done.resolve();
})
await done.promise;
};
}

View File

@ -0,0 +1,156 @@
import * as plugins from './tsbundle.plugins';
import { logger } from './tsbundle.logging';
export class TsBundleProcess {
/**
* the basic default options for rollup
*/
public getBaseOptions(
fromArg: string = `ts_web/index.ts`,
toArg: string = 'dist_bundle/bundle.js'
) {
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({
include: plugins.path.parse(fromArg).dir
? plugins.path.parse(fromArg).dir + '/**/*.ts'
: '**/*.ts',
declaration: false,
emitDecoratorMetadata: true,
experimentalDecorators: true,
inlineSourceMap: true,
noEmitOnError: true,
lib: ['esnext', 'dom', 'es2017.object'],
noImplicitAny: false,
target: 'es2018',
allowSyntheticDefaultImports: true,
}),
plugins.rollupJson(),
// 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({}),
// 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;
}
public getOptionsTest(fromArg: string, toArg: string): plugins.rollup.RollupOptions {
return this.getBaseOptions(fromArg, toArg);
}
public getOptionsProduction(fromArg: string, toArg: string): plugins.rollup.RollupOptions {
const productionOptions = this.getBaseOptions(fromArg, toArg);
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,
bundlerArg: 'rollup' | 'parcel' = 'rollup'
) {
// create a bundle
switch (bundlerArg) {
case 'rollup':
logger.log('info', `bundling for TEST!`);
const buildOptions = this.getOptionsTest(fromArg, toArg);
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!`);
break;
case 'parcel':
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) {
// create a bundle
logger.log('info', `bundling for PRODUCTION!`);
const buildOptions = this.getOptionsProduction(fromArg, toArg);
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!`);
}
}
const run = async () => {
console.log('running spawned compilation process');
console.log(`cwd: ${process.env.tsbundleCwd}`);
console.log(`from: ${process.env.tsbundleFrom}`);
console.log(`to: ${process.env.tsbundleTo}`);
console.log(`mode: ${process.env.tsbundleMode}`);
process.chdir(process.env.tsbundleCwd);
console.log(`switched to ${process.cwd()}`)
const tsbundleProcessInstance = new TsBundleProcess();
if (process.env.tsbundleMode === 'test') {
tsbundleProcessInstance.buildTest(process.env.tsbundleFrom, process.env.tsbundleTo, process.env.tsbundleBundler as 'rollup' | 'parcel');
} else {
tsbundleProcessInstance.buildProduction(process.env.tsbundleFrom, process.env.tsbundleTo);
}
}
run();

View File

@ -15,7 +15,7 @@ export const runCli = async () => {
break;
case argvArg.test:
default:
await tsbundle.buildTest(argvArg.from, argvArg.to);
await tsbundle.buildTest(process.cwd(), argvArg.from, argvArg.to, 'rollup');
// await htmlHandler.copyHtml();
return;
}
@ -31,7 +31,7 @@ export const runCli = async () => {
break;
case argvArg.test:
default:
await tsbundle.buildTest('./ts_web/index.ts', './dist_bundle/bundle.js');
await tsbundle.buildTest(process.cwd(), './ts_web/index.ts', './dist_bundle/bundle.js', 'rollup');
// await htmlHandler.copyHtml();
return;
}
@ -47,7 +47,7 @@ export const runCli = async () => {
break;
case argvArg.test:
default:
await tsbundle.buildTest('./ts/index.ts', './dist_bundle/bundle.js');
await tsbundle.buildTest(process.cwd(), './ts/index.ts', './dist_bundle/bundle.js', 'rollup');
// await htmlHandler.copyHtml();
return;
}
@ -63,7 +63,7 @@ export const runCli = async () => {
break;
case argvArg.test:
default:
await tsbundle.buildTest('./ts_web/index.ts', './dist_serve/bundle.js');
await tsbundle.buildTest(process.cwd(), './ts_web/index.ts', './dist_serve/bundle.js', 'rollup');
await htmlHandler.copyHtml();
return;
}

View File

@ -9,8 +9,10 @@ import * as smartfile from '@pushrocks/smartfile';
import * as smartlog from '@pushrocks/smartlog';
import * as smartlogDestinationLocal from '@pushrocks/smartlog-destination-local';
import * as smartparcel from '@pushrocks/smartparcel';
import * as smartpromise from '@pushrocks/smartpromise';
import * as smartspawn from '@pushrocks/smartspawn';
export { smartcli, smartfile, smartlog, smartlogDestinationLocal, smartparcel };
export { smartcli, smartfile, smartlog, smartlogDestinationLocal, smartparcel, smartpromise, smartspawn };
// third party scope
import * as rollup from 'rollup';