Compare commits
70 Commits
Author | SHA1 | Date | |
---|---|---|---|
501d5f766f | |||
bf3ba08dde | |||
576ec20e3c | |||
6d48086266 | |||
e3a6e065ee | |||
63d35e2ce8 | |||
d5753019cf | |||
a3ab55cbc6 | |||
ae16fd8170 | |||
cf9ca73cd8 | |||
687b83bafd | |||
3c9b178c09 | |||
5f92b58353 | |||
ed75a7c695 | |||
59f32fed12 | |||
8e176ce2bd | |||
4ca2d2daed | |||
6581e3d662 | |||
827f23107c | |||
ad917bf2ad | |||
306a018efd | |||
a7935958b7 | |||
8818ca9370 | |||
85b1988383 | |||
10cbf125a9 | |||
d229e0ca37 | |||
f7b260f28b | |||
ba44efe4cc | |||
07718ba618 | |||
0af4e4cfb3 | |||
b54681f063 | |||
37f3df9deb | |||
4b0d99cf3a | |||
38426a24bc | |||
dadd0b70b3 | |||
516b0ff578 | |||
e5fa36fb06 | |||
228756951f | |||
a22c837eac | |||
a1a341b2de | |||
046d3107e8 | |||
956bcdf16e | |||
f61640b65a | |||
0125591149 | |||
6aa0d800b3 | |||
19160170a9 | |||
8bf9e3d691 | |||
737d43b59e | |||
7e5a225ae1 | |||
bb13c14d3b | |||
501a7417ba | |||
31a9249e0b | |||
9367ad2e05 | |||
8676f97843 | |||
f1b4e76a5b | |||
558edb8f09 | |||
e244ca30b9 | |||
104cdab0dc | |||
a935dc0b86 | |||
9a43d77fe6 | |||
e9ca5147f3 | |||
b418ccd10a | |||
eeeac6cb7f | |||
c0d05bab7f | |||
0cceb23987 | |||
1b91c7a46c | |||
bd9ec3b313 | |||
ada2ae72ee | |||
ceaabe35c8 | |||
0b0c36da1b |
@ -12,6 +12,9 @@ stages:
|
|||||||
- release
|
- release
|
||||||
- metadata
|
- metadata
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- npm install -g @shipzone/npmci
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# security stage
|
# security stage
|
||||||
# ====================
|
# ====================
|
||||||
@ -19,23 +22,36 @@ mirror:
|
|||||||
stage: security
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci git mirror
|
- npmci git mirror
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
|
|
||||||
audit:
|
auditProductionDependencies:
|
||||||
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
stage: security
|
||||||
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci command npm install --production --ignore-scripts
|
||||||
|
- npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
- npmci command npm audit --audit-level=high --only=prod --production
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
allow_failure: true
|
||||||
|
|
||||||
|
auditDevDependencies:
|
||||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
stage: security
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci command npm install --ignore-scripts
|
- npmci command npm install --ignore-scripts
|
||||||
- npmci command npm config set registry https://registry.npmjs.org
|
- npmci command npm config set registry https://registry.npmjs.org
|
||||||
- npmci command npm audit --audit-level=high
|
- npmci command npm audit --audit-level=high --only=dev
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
allow_failure: true
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# test stage
|
# test stage
|
||||||
@ -50,9 +66,7 @@ testStable:
|
|||||||
- npmci npm test
|
- npmci npm test
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
|
||||||
- docker
|
- docker
|
||||||
- priv
|
|
||||||
|
|
||||||
testBuild:
|
testBuild:
|
||||||
stage: test
|
stage: test
|
||||||
@ -63,9 +77,7 @@ testBuild:
|
|||||||
- npmci command npm run build
|
- npmci command npm run build
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
|
||||||
|
|
||||||
release:
|
release:
|
||||||
stage: release
|
stage: release
|
||||||
@ -85,6 +97,8 @@ release:
|
|||||||
codequality:
|
codequality:
|
||||||
stage: metadata
|
stage: metadata
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
script:
|
script:
|
||||||
- npmci command npm install -g tslint typescript
|
- npmci command npm install -g tslint typescript
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
|
4
.snyk
4
.snyk
@ -1,4 +0,0 @@
|
|||||||
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
|
|
||||||
version: v1.13.5
|
|
||||||
ignore: {}
|
|
||||||
patch: {}
|
|
24
.vscode/launch.json
vendored
24
.vscode/launch.json
vendored
@ -2,28 +2,10 @@
|
|||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"name": "current file",
|
"command": "npm test",
|
||||||
"type": "node",
|
"name": "Run npm test",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"args": [
|
"type": "node-terminal"
|
||||||
"${relativeFile}"
|
|
||||||
],
|
|
||||||
"runtimeArgs": ["-r", "@gitzone/tsrun"],
|
|
||||||
"cwd": "${workspaceRoot}",
|
|
||||||
"protocol": "inspector",
|
|
||||||
"internalConsoleOptions": "openOnSessionStart"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "test.ts",
|
|
||||||
"type": "node",
|
|
||||||
"request": "launch",
|
|
||||||
"args": [
|
|
||||||
"test/test.ts"
|
|
||||||
],
|
|
||||||
"runtimeArgs": ["-r", "@gitzone/tsrun"],
|
|
||||||
"cwd": "${workspaceRoot}",
|
|
||||||
"protocol": "inspector",
|
|
||||||
"internalConsoleOptions": "openOnSessionStart"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@ -15,7 +15,7 @@
|
|||||||
"properties": {
|
"properties": {
|
||||||
"projectType": {
|
"projectType": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": ["website", "element", "service", "npm"]
|
"enum": ["website", "element", "service", "npm", "wcc"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
4
cli.child.ts
Normal file
4
cli.child.ts
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
process.env.CLI_CALL = 'true';
|
||||||
|
import * as cliTool from './ts/index.js';
|
||||||
|
cliTool.runCli();
|
2
cli.js
2
cli.js
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
process.env.CLI_CALL = 'true';
|
process.env.CLI_CALL = 'true';
|
||||||
const cliTool = require('./dist_ts/index');
|
const cliTool = await import('./dist_ts/index.js');
|
||||||
cliTool.runCli();
|
cliTool.runCli();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
process.env.CLI_CALL = 'true';
|
process.env.CLI_CALL = 'true';
|
||||||
require('@gitzone/tsrun');
|
|
||||||
const cliTool = require('./ts/index');
|
import * as tsrun from '@gitzone/tsrun';
|
||||||
cliTool.runCli();
|
tsrun.runPath('./cli.child.js', import.meta.url);
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
"githost": "gitlab.com",
|
"githost": "gitlab.com",
|
||||||
"gitscope": "gitzone",
|
"gitscope": "gitzone",
|
||||||
"gitrepo": "tsbundle",
|
"gitrepo": "tsbundle",
|
||||||
"shortDescription": "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": "@gitzone/tsbundle",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"projectDomain": "git.zone"
|
"projectDomain": "git.zone"
|
||||||
|
18026
package-lock.json
generated
18026
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
67
package.json
67
package.json
@ -1,51 +1,57 @@
|
|||||||
{
|
{
|
||||||
"name": "@gitzone/tsbundle",
|
"name": "@gitzone/tsbundle",
|
||||||
"version": "1.0.62",
|
"version": "1.0.97",
|
||||||
"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",
|
||||||
"typings": "dist_ts/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
|
"type": "module",
|
||||||
"author": "Lossless GmbH",
|
"author": "Lossless GmbH",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "cd test && node ../cli.ts.js --production",
|
"test": "npm run build && (tstest test/) && (cd test && node ../cli.js --production)",
|
||||||
"build": "(tsbuild)",
|
"build": "(tsbuild --web --allowimplicitany)"
|
||||||
"format": "(gitzone format)"
|
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
"tsbundle": "cli.js"
|
"tsbundle": "cli.js"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.22",
|
"@gitzone/tsbuild": "^2.1.56",
|
||||||
"@gitzone/tsrun": "^1.2.8",
|
"@gitzone/tsrun": "^1.2.31",
|
||||||
"@gitzone/tstest": "^1.0.28",
|
"@gitzone/tstest": "^1.0.67",
|
||||||
"@pushrocks/tapbundle": "^3.2.1",
|
"@pushrocks/tapbundle": "^5.0.2",
|
||||||
"tslint": "^6.1.0",
|
"tslint": "^6.1.3",
|
||||||
"tslint-config-prettier": "^1.15.0"
|
"tslint-config-prettier": "^1.15.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/core": "^7.8.7",
|
"@babel/core": "^7.17.7",
|
||||||
"@babel/plugin-proposal-class-properties": "^7.8.3",
|
"@babel/plugin-proposal-class-properties": "^7.16.7",
|
||||||
"@babel/plugin-proposal-decorators": "^7.8.3",
|
"@babel/plugin-proposal-decorators": "^7.17.2",
|
||||||
"@babel/plugin-transform-runtime": "^7.8.3",
|
"@babel/plugin-transform-runtime": "^7.17.0",
|
||||||
"@babel/preset-env": "^7.8.7",
|
"@babel/preset-env": "^7.16.11",
|
||||||
"@babel/runtime": "^7.8.7",
|
"@babel/runtime": "^7.17.7",
|
||||||
"@pushrocks/early": "^3.0.3",
|
"@pushrocks/early": "^3.0.6",
|
||||||
"@pushrocks/smartcli": "^3.0.9",
|
"@pushrocks/smartcli": "^3.0.14",
|
||||||
"@pushrocks/smartfile": "^7.0.11",
|
"@pushrocks/smartfile": "^9.0.6",
|
||||||
"@pushrocks/smartlog": "^2.0.21",
|
"@pushrocks/smartlog": "^2.0.44",
|
||||||
"@pushrocks/smartlog-destination-local": "^8.0.2",
|
"@pushrocks/smartlog-destination-local": "^8.0.8",
|
||||||
"@rollup/plugin-commonjs": "^11.0.2",
|
"@pushrocks/smartparcel": "^1.0.13",
|
||||||
"@rollup/plugin-node-resolve": "^7.1.1",
|
"@pushrocks/smartpath": "^5.0.5",
|
||||||
"@rollup/plugin-typescript": "^4.0.0",
|
"@pushrocks/smartpromise": "^3.1.7",
|
||||||
"@types/html-minifier": "^3.5.3",
|
"@pushrocks/smartspawn": "^2.0.9",
|
||||||
"@types/node": "^13.9.1",
|
"@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.1.0",
|
"rollup": "^2.70.1",
|
||||||
"rollup-plugin-babel": "^4.4.0",
|
"rollup-plugin-babel": "^4.4.0",
|
||||||
"rollup-plugin-sourcemaps": "^0.5.0",
|
"rollup-plugin-sourcemaps": "^0.6.3",
|
||||||
"rollup-plugin-terser": "^5.3.0",
|
"rollup-plugin-terser": "^7.0.2",
|
||||||
"terser": "^4.6.7"
|
"typescript": "4.7.0"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"ts/**/*",
|
"ts/**/*",
|
||||||
@ -58,5 +64,8 @@
|
|||||||
"cli.js",
|
"cli.js",
|
||||||
"npmextra.json",
|
"npmextra.json",
|
||||||
"readme.md"
|
"readme.md"
|
||||||
|
],
|
||||||
|
"browserslist": [
|
||||||
|
"last 1 chrome versions"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
59
readme.md
59
readme.md
@ -8,13 +8,20 @@ a bundler using rollup for painless bundling of web projects
|
|||||||
* [docs (typedoc)](https://gitzone.gitlab.io/tsbundle/)
|
* [docs (typedoc)](https://gitzone.gitlab.io/tsbundle/)
|
||||||
|
|
||||||
## Status for master
|
## Status for master
|
||||||
[](https://gitlab.com/gitzone/tsbundle/commits/master)
|
|
||||||
[](https://gitlab.com/gitzone/tsbundle/commits/master)
|
Status Category | Status Badge
|
||||||
[](https://www.npmjs.com/package/@gitzone/tsbundle)
|
-- | --
|
||||||
[](https://snyk.io/test/npm/@gitzone/tsbundle)
|
GitLab Pipelines | [](https://lossless.cloud)
|
||||||
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
||||||
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
npm | [](https://lossless.cloud)
|
||||||
[](https://prettier.io/)
|
Snyk | [](https://lossless.cloud)
|
||||||
|
TypeScript Support | [](https://lossless.cloud)
|
||||||
|
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
|
Code Style | [](https://lossless.cloud)
|
||||||
|
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
||||||
|
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
||||||
|
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
||||||
|
Platform support | [](https://lossless.cloud) [](https://lossless.cloud)
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@ -22,10 +29,42 @@ 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)
|
tsbundle supports two modes of usage: CLI and API usage.
|
||||||
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
|
||||||
|
|
||||||
[](https://maintainedby.lossless.com)
|
### CLI
|
||||||
|
|
||||||
|
```shell
|
||||||
|
# Note: This is code that belongs into your terminal ;)
|
||||||
|
# Install the tool for cli usage
|
||||||
|
|
||||||
|
# Globally
|
||||||
|
npm install -g @gitzone/tsbundle
|
||||||
|
|
||||||
|
# Locally for use in your pacakge.json
|
||||||
|
npm install --save-dev @gitzone/tsbundle
|
||||||
|
|
||||||
|
# then use it
|
||||||
|
tsbundle --from="./ts/index.ts" --to="dist/bundle.js"
|
||||||
|
|
||||||
|
## note you can call tsbundle without arguments. Default values are --from="./ts_web/index.ts" --to="dist_bundle/bundle.js"
|
||||||
|
## You can use --production to enable minification using terser
|
||||||
|
```
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
You are using TypeScript, aren't you? Most of the stuff is apparent from the IDE intellisense.
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { TsBundle } from '@gitozne/tsbundle';
|
||||||
|
|
||||||
|
const myTsBundleInstance = new TsBundle();
|
||||||
|
|
||||||
|
const run = async () => {
|
||||||
|
await myTsBundleInstance.buildTest('./from/my.ts', './to/mybundle.js');
|
||||||
|
// OR
|
||||||
|
await myTsBundleInstance.buildProduction('./from/my.ts', './to/mybundle.js');
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
## Contribution
|
## Contribution
|
||||||
|
|
||||||
|
@ -1,57 +0,0 @@
|
|||||||
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 }]]
|
|
||||||
})
|
|
||||||
]
|
|
||||||
};
|
|
38
test/test.ts
38
test/test.ts
@ -1,8 +1,40 @@
|
|||||||
import { expect, tap } from '@pushrocks/tapbundle';
|
import { expect, tap } from '@pushrocks/tapbundle';
|
||||||
import * as tsbundle from '../ts/index';
|
import * as tsbundle from '../ts/index.js';
|
||||||
|
|
||||||
tap.test('first test', async () => {
|
import * as path from 'path';
|
||||||
await tsbundle.runCli();
|
|
||||||
|
tap.test('should bundle with esbuild', async () => {
|
||||||
|
const tsbundleInstance = new tsbundle.TsBundle();
|
||||||
|
await tsbundleInstance.build(
|
||||||
|
process.cwd() + '/test',
|
||||||
|
'./ts_web/index.ts',
|
||||||
|
'./dist_manual/test.js',
|
||||||
|
{
|
||||||
|
bundler: 'esbuild'
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
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,3 +1,18 @@
|
|||||||
const myConst = 'hello';
|
const myConst: string = 'hello';
|
||||||
|
|
||||||
|
function sealed(constructor: Function) {
|
||||||
|
Object.seal(constructor);
|
||||||
|
Object.seal(constructor.prototype);
|
||||||
|
}
|
||||||
|
|
||||||
|
@sealed
|
||||||
|
class BugReport {
|
||||||
|
type = 'report';
|
||||||
|
title: string;
|
||||||
|
|
||||||
|
constructor(t: string) {
|
||||||
|
this.title = t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
console.log(myConst);
|
console.log(myConst);
|
||||||
|
10
ts/index.ts
10
ts/index.ts
@ -1,13 +1,13 @@
|
|||||||
import * as early from '@pushrocks/early';
|
import * as early from '@pushrocks/early';
|
||||||
early.start('tsbundle');
|
early.start('tsbundle');
|
||||||
// lets import all plugins beforehand
|
// lets import all plugins beforehand
|
||||||
import './tsbundle.plugins';
|
import './plugins.js';
|
||||||
|
|
||||||
import { logger } from './tsbundle.logging';
|
import { logger } from './tsbundle.logging.js';
|
||||||
import { runCli } from './tsbundle.cli';
|
import { runCli } from './tsbundle.cli.js';
|
||||||
early.stop();
|
early.stop();
|
||||||
|
|
||||||
// lets make this usable programmatically
|
// lets make this usable programmatically
|
||||||
export * from './tsbundle.class.tsbundle';
|
export * from './tsbundle.class.tsbundle.js';
|
||||||
export * from './tsbundle.htmlhandler';
|
export * from './mod_rollup/htmlhandler.js';
|
||||||
export { runCli };
|
export { runCli };
|
||||||
|
14
ts/interfaces/index.ts
Normal file
14
ts/interfaces/index.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
export interface ICliOptions {
|
||||||
|
commonjs?: boolean;
|
||||||
|
skiplibcheck?: boolean;
|
||||||
|
production?: boolean;
|
||||||
|
bundler: 'parcel' | 'esbuild' | 'rollup'
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IEnvTransportOptions {
|
||||||
|
cwd: string;
|
||||||
|
from: string;
|
||||||
|
to: string;
|
||||||
|
mode: 'test' | 'production',
|
||||||
|
argv: ICliOptions
|
||||||
|
}
|
72
ts/mod_esbuild/index.child.ts
Normal file
72
ts/mod_esbuild/index.child.ts
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
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
|
||||||
|
) {
|
||||||
|
// create a bundle
|
||||||
|
const esbuild = await plugins.esbuild.build({
|
||||||
|
entryPoints: [fromArg],
|
||||||
|
bundle: true,
|
||||||
|
outfile: toArg
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* creates a bundle for the production environment
|
||||||
|
*/
|
||||||
|
public async buildProduction(
|
||||||
|
fromArg: string,
|
||||||
|
toArg: string,
|
||||||
|
argvArg: any
|
||||||
|
) {
|
||||||
|
// create a bundle
|
||||||
|
console.log('esbuild specific:');
|
||||||
|
console.log(`from: ${fromArg}`);
|
||||||
|
console.log((`to: ${toArg}`));
|
||||||
|
const esbuild = await plugins.esbuild.build({
|
||||||
|
entryPoints: [fromArg],
|
||||||
|
bundle: true,
|
||||||
|
outfile: toArg
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const run = async () => {
|
||||||
|
console.log('running spawned compilation process');
|
||||||
|
const transportOptions: interfaces.IEnvTransportOptions = JSON.parse(process.env.transportOptions);
|
||||||
|
console.log('bundling with esbuild:');
|
||||||
|
console.log(transportOptions);
|
||||||
|
process.chdir(transportOptions.cwd);
|
||||||
|
console.log(`switched to ${process.cwd()}`);
|
||||||
|
const tsbundleProcessInstance = new TsBundleProcess();
|
||||||
|
if (transportOptions.mode === 'test') {
|
||||||
|
console.log('building for test:')
|
||||||
|
tsbundleProcessInstance.buildTest(
|
||||||
|
plugins.smartpath.transform.makeAbsolute(transportOptions.from, process.cwd()),
|
||||||
|
plugins.smartpath.transform.makeAbsolute(transportOptions.to, process.cwd()),
|
||||||
|
transportOptions.argv
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
console.log('building for production:')
|
||||||
|
tsbundleProcessInstance.buildProduction(
|
||||||
|
plugins.smartpath.transform.makeAbsolute(transportOptions.from, process.cwd()),
|
||||||
|
plugins.smartpath.transform.makeAbsolute(transportOptions.to, process.cwd()),
|
||||||
|
transportOptions.argv
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
run();
|
7
ts/mod_esbuild/plugins.ts
Normal file
7
ts/mod_esbuild/plugins.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
export * from '../plugins.js';
|
||||||
|
|
||||||
|
import esbuild from 'esbuild';
|
||||||
|
|
||||||
|
export {
|
||||||
|
esbuild
|
||||||
|
}
|
70
ts/mod_parcel/index.child.ts
Normal file
70
ts/mod_parcel/index.child.ts
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
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();
|
7
ts/mod_parcel/plugins.ts
Normal file
7
ts/mod_parcel/plugins.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
export * from '../plugins.js'
|
||||||
|
|
||||||
|
import * as smartparcel from '@pushrocks/smartparcel';
|
||||||
|
|
||||||
|
export {
|
||||||
|
smartparcel
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
import * as plugins from './tsbundle.plugins';
|
import * as plugins from './plugins.js';
|
||||||
import * as paths from './tsbundle.paths';
|
import * as paths from '../paths.js';
|
||||||
|
|
||||||
export class HtmlHandler {
|
export class HtmlHandler {
|
||||||
public sourceFilePath: string = plugins.path.join(paths.htmlDir, 'index.html');
|
public sourceFilePath: string = plugins.path.join(paths.htmlDir, 'index.html');
|
||||||
@ -31,7 +31,7 @@ export class HtmlHandler {
|
|||||||
removeAttributeQuotes: true,
|
removeAttributeQuotes: true,
|
||||||
collapseWhitespace: true,
|
collapseWhitespace: true,
|
||||||
collapseInlineTagWhitespace: true,
|
collapseInlineTagWhitespace: true,
|
||||||
removeComments: true
|
removeComments: true,
|
||||||
});
|
});
|
||||||
plugins.smartfile.memory.toFsSync(minifiedHtml, targetPathArg);
|
plugins.smartfile.memory.toFsSync(minifiedHtml, targetPathArg);
|
||||||
}
|
}
|
162
ts/mod_rollup/index.child.ts
Normal file
162
ts/mod_rollup/index.child.ts
Normal file
@ -0,0 +1,162 @@
|
|||||||
|
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,20 +1,10 @@
|
|||||||
// node native
|
export * from '../plugins.js';
|
||||||
import * as path from 'path';
|
|
||||||
|
|
||||||
export { path };
|
|
||||||
|
|
||||||
// pushrocks scope
|
|
||||||
import * as smartcli from '@pushrocks/smartcli';
|
|
||||||
import * as smartfile from '@pushrocks/smartfile';
|
|
||||||
import * as smartlog from '@pushrocks/smartlog';
|
|
||||||
import * as smartlogDestinationLocal from '@pushrocks/smartlog-destination-local';
|
|
||||||
|
|
||||||
export { smartcli, smartfile, smartlog, smartlogDestinationLocal };
|
|
||||||
|
|
||||||
// third party scope
|
// third party scope
|
||||||
import * as rollup from 'rollup';
|
import * as rollup from 'rollup';
|
||||||
import rollupBabel from 'rollup-plugin-babel';
|
import rollupBabel from 'rollup-plugin-babel';
|
||||||
import rollupCommonjs from '@rollup/plugin-commonjs';
|
import rollupCommonjs from '@rollup/plugin-commonjs';
|
||||||
|
import rollupJson from '@rollup/plugin-json';
|
||||||
import rollupResolve from '@rollup/plugin-node-resolve';
|
import rollupResolve from '@rollup/plugin-node-resolve';
|
||||||
import rollupSourceMaps from 'rollup-plugin-sourcemaps';
|
import rollupSourceMaps from 'rollup-plugin-sourcemaps';
|
||||||
import { terser as rollupTerser } from 'rollup-plugin-terser';
|
import { terser as rollupTerser } from 'rollup-plugin-terser';
|
||||||
@ -26,9 +16,10 @@ export {
|
|||||||
rollup,
|
rollup,
|
||||||
rollupBabel,
|
rollupBabel,
|
||||||
rollupCommonjs,
|
rollupCommonjs,
|
||||||
|
rollupJson,
|
||||||
rollupResolve,
|
rollupResolve,
|
||||||
rollupSourceMaps,
|
rollupSourceMaps,
|
||||||
rollupTerser,
|
rollupTerser,
|
||||||
rollupTypescript,
|
rollupTypescript,
|
||||||
htmlMinifier
|
htmlMinifier,
|
||||||
};
|
};
|
@ -1,7 +1,10 @@
|
|||||||
import * as plugins from './tsbundle.plugins';
|
import * as plugins from './plugins.js';
|
||||||
|
|
||||||
export const cwd = process.cwd();
|
export const cwd = process.cwd();
|
||||||
export const packageDir = plugins.path.join(__dirname, '../');
|
export const packageDir = plugins.path.join(
|
||||||
|
plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url),
|
||||||
|
'../'
|
||||||
|
);
|
||||||
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');
|
23
ts/plugins.ts
Normal file
23
ts/plugins.ts
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
// node native
|
||||||
|
import * as path from 'path';
|
||||||
|
|
||||||
|
export { path };
|
||||||
|
|
||||||
|
// pushrocks scope
|
||||||
|
import * as smartcli from '@pushrocks/smartcli';
|
||||||
|
import * as smartfile from '@pushrocks/smartfile';
|
||||||
|
import * as smartlog from '@pushrocks/smartlog';
|
||||||
|
import * as smartlogDestinationLocal from '@pushrocks/smartlog-destination-local';
|
||||||
|
import * as smartpath from '@pushrocks/smartpath';
|
||||||
|
import * as smartpromise from '@pushrocks/smartpromise';
|
||||||
|
import * as smartspawn from '@pushrocks/smartspawn';
|
||||||
|
|
||||||
|
export {
|
||||||
|
smartcli,
|
||||||
|
smartfile,
|
||||||
|
smartlog,
|
||||||
|
smartlogDestinationLocal,
|
||||||
|
smartpath,
|
||||||
|
smartpromise,
|
||||||
|
smartspawn,
|
||||||
|
};
|
@ -1,127 +1,54 @@
|
|||||||
import * as plugins from './tsbundle.plugins';
|
import * as plugins from './plugins.js';
|
||||||
import { logger } from './tsbundle.logging';
|
import * as interfaces from './interfaces/index.js';
|
||||||
|
import { logger } from './tsbundle.logging.js';
|
||||||
|
|
||||||
export class TsBundle {
|
export class TsBundle {
|
||||||
/**
|
|
||||||
* the basic default options for rollup
|
public async build(
|
||||||
*/
|
cwdArg: string,
|
||||||
public getBaseOptions(
|
fromArg: string = './ts_web/index.ts',
|
||||||
fromArg: string = `ts_web/index.ts`,
|
toArg: string = './dist_bundle/bundle.js',
|
||||||
toArg: string = 'dist_bundle/bundle.js'
|
argvArg: interfaces.ICliOptions
|
||||||
) {
|
) {
|
||||||
logger.log('info', `from: ${fromArg}`);
|
const done = plugins.smartpromise.defer();
|
||||||
logger.log('info', `to: ${toArg}`);
|
const getBundlerPath = () => {
|
||||||
|
if (argvArg.bundler === 'esbuild') {
|
||||||
const baseOptions: plugins.rollup.RollupOptions = {
|
return './mod_esbuild/index.child.js'
|
||||||
input: fromArg,
|
}
|
||||||
output: {
|
if (argvArg.bundler === 'parcel') {
|
||||||
name: 'tsbundle',
|
return './mod_parcel/index.child.js'
|
||||||
file: toArg,
|
}
|
||||||
format: 'iife',
|
if (argvArg.bundler === 'rollup') {
|
||||||
sourcemap: true
|
return './mod_rollup/index.child.js'
|
||||||
},
|
}
|
||||||
// Indicate here external modules you don't wanna include in your bundle (i.e.: 'lodash')
|
return './mod_esbuild/index.child.js'
|
||||||
external: [],
|
}
|
||||||
watch: {
|
const transportOptions: interfaces.IEnvTransportOptions = {
|
||||||
include: ['src/**']
|
cwd: cwdArg,
|
||||||
},
|
from: fromArg,
|
||||||
plugins: [
|
to: toArg,
|
||||||
// Compile TypeScript files
|
mode: argvArg && argvArg.production ? 'production' : 'test',
|
||||||
plugins.rollupTypescript({
|
argv: argvArg ? argvArg : {
|
||||||
include: plugins.path.parse(fromArg).dir ? plugins.path.parse(fromArg).dir + '/**/*.ts' : '**/*.ts',
|
bundler: 'esbuild'
|
||||||
declaration: false,
|
}
|
||||||
emitDecoratorMetadata: true,
|
}
|
||||||
experimentalDecorators: true,
|
const threadsimple = new plugins.smartspawn.ThreadSimple(
|
||||||
inlineSourceMap: true,
|
plugins.path.join(
|
||||||
noEmitOnError: true,
|
plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url),
|
||||||
lib: ['esnext', 'dom', 'es2017.object'],
|
getBundlerPath()
|
||||||
noImplicitAny: false,
|
),
|
||||||
target: 'es2018'
|
[],
|
||||||
}),
|
{
|
||||||
// Allow node_modules resolution, so you can use 'external' to control
|
env: {
|
||||||
// which external modules to include in the bundle
|
...process.env,
|
||||||
// https://github.com/rollup/rollup-plugin-node-resolve#usage
|
transportOptions: JSON.stringify(transportOptions),
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
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,
|
|
||||||
sourcemap: true
|
|
||||||
})
|
|
||||||
);
|
);
|
||||||
return productionOptions;
|
const childProcess = await threadsimple.start();
|
||||||
}
|
childProcess.on('exit', (status) => {
|
||||||
|
done.resolve();
|
||||||
constructor() {
|
});
|
||||||
// Nothing here
|
await done.promise;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* creates a bundle for the test enviroment
|
|
||||||
*/
|
|
||||||
public async buildTest(fromArg: string, toArg: string) {
|
|
||||||
// create a bundle
|
|
||||||
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!`);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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!`);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,56 +1,44 @@
|
|||||||
import * as plugins from './tsbundle.plugins';
|
import * as plugins from './plugins.js';
|
||||||
import { TsBundle } from './tsbundle.class.tsbundle';
|
import { TsBundle } from './tsbundle.class.tsbundle.js';
|
||||||
import { HtmlHandler } from './tsbundle.htmlhandler';
|
import { logger } from './tsbundle.logging.js';
|
||||||
import { logger } from './tsbundle.logging';
|
|
||||||
|
|
||||||
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.standardTask().subscribe(async (argvArg) => {
|
||||||
const tsbundle = new TsBundle();
|
const tsbundle = new TsBundle();
|
||||||
// const htmlHandler = new HtmlHandler();
|
await tsbundle.build(process.cwd(), argvArg.from, argvArg.to, argvArg);
|
||||||
switch (true) {
|
return;
|
||||||
case argvArg.production || process.env.CI:
|
|
||||||
await tsbundle.buildProduction(argvArg.from, argvArg.to);
|
|
||||||
// await htmlHandler.minifyHtml();
|
|
||||||
break;
|
|
||||||
case argvArg.test:
|
|
||||||
default:
|
|
||||||
await tsbundle.buildTest(argvArg.from, argvArg.to);
|
|
||||||
// await htmlHandler.copyHtml();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
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();
|
||||||
switch (true) {
|
await tsbundle.build(
|
||||||
case argvArg.production || process.env.CI:
|
process.cwd(),
|
||||||
await tsbundle.buildProduction('./ts_web/index.ts', './dist_bundle/bundle.js');
|
'./ts_web/index.ts',
|
||||||
// await htmlHandler.minifyHtml();
|
'./dist_bundle/bundle.js',
|
||||||
break;
|
argvArg
|
||||||
case argvArg.test:
|
);
|
||||||
default:
|
|
||||||
await tsbundle.buildTest('./ts_web/index.ts', './dist_bundle/bundle.js');
|
|
||||||
// await htmlHandler.copyHtml();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
tsBundleCli.addCommand('website').subscribe(async argvArg => {
|
tsBundleCli.addCommand('npm').subscribe(async (argvArg) => {
|
||||||
const tsbundle = new TsBundle();
|
const tsbundle = new TsBundle();
|
||||||
const htmlHandler = new HtmlHandler();
|
await tsbundle.build(
|
||||||
switch (true) {
|
process.cwd(),
|
||||||
case argvArg.production || process.env.CI:
|
'./ts/index.ts',
|
||||||
await tsbundle.buildProduction('./ts_web/index.ts', './dist_serve/bundle.js');
|
'./dist_bundle/bundle.js',
|
||||||
await htmlHandler.minifyHtml();
|
argvArg
|
||||||
break;
|
);
|
||||||
case argvArg.test:
|
});
|
||||||
default:
|
|
||||||
await tsbundle.buildTest('./ts_web/index.ts', './dist_serve/bundle.js');
|
tsBundleCli.addCommand('website').subscribe(async (argvArg) => {
|
||||||
await htmlHandler.copyHtml();
|
const tsbundle = new TsBundle();
|
||||||
return;
|
await tsbundle.build(
|
||||||
}
|
process.cwd(),
|
||||||
|
'./ts_web/index.ts',
|
||||||
|
'./dist_serve/bundle.js',
|
||||||
|
argvArg
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
tsBundleCli.startParse();
|
tsBundleCli.startParse();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import * as plugins from './tsbundle.plugins';
|
import * as plugins from './plugins.js';
|
||||||
|
|
||||||
export const logger = new plugins.smartlog.Smartlog({
|
export const logger = new plugins.smartlog.Smartlog({
|
||||||
logContext: {
|
logContext: {
|
||||||
@ -7,9 +7,9 @@ export const logger = new plugins.smartlog.Smartlog({
|
|||||||
containerName: 'Some Containername',
|
containerName: 'Some Containername',
|
||||||
environment: 'local',
|
environment: 'local',
|
||||||
runtime: 'node',
|
runtime: 'node',
|
||||||
zone: 'gitzone'
|
zone: 'gitzone',
|
||||||
},
|
},
|
||||||
minimumLogLevel: 'silly'
|
minimumLogLevel: 'silly',
|
||||||
});
|
});
|
||||||
|
|
||||||
logger.addLogDestination(new plugins.smartlogDestinationLocal.DestinationLocal());
|
logger.addLogDestination(new plugins.smartlogDestinationLocal.DestinationLocal());
|
||||||
|
9
tsconfig.json
Normal file
9
tsconfig.json
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"target": "ES2020",
|
||||||
|
"module": "ES2020",
|
||||||
|
"moduleResolution": "node12",
|
||||||
|
"esModuleInterop": true
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user