Compare commits

...

10 Commits

Author SHA1 Message Date
54f84ba114 v2.7.4
Some checks failed
Default (tags) / security (push) Successful in 38s
Default (tags) / test (push) Failing after 1m9s
Default (tags) / release (push) Has been skipped
Default (tags) / metadata (push) Has been skipped
2026-01-12 01:25:24 +00:00
e40d6477fd fix(deps): bump @push.rocks/smartcli dependency to ^4.0.20 2026-01-12 01:25:24 +00:00
a550d6e450 v2.7.3
Some checks failed
Default (tags) / security (push) Successful in 40s
Default (tags) / test (push) Failing after 36s
Default (tags) / release (push) Has been skipped
Default (tags) / metadata (push) Has been skipped
2026-01-12 00:57:34 +00:00
201f8aca38 fix(mod_output): wrap long base64 file contents and format generated TypeScript output to avoid extremely long lines 2026-01-12 00:57:34 +00:00
41091f1bee v2.7.2
Some checks failed
Default (tags) / security (push) Successful in 38s
Default (tags) / test (push) Failing after 34s
Default (tags) / release (push) Has been skipped
Default (tags) / metadata (push) Has been skipped
2026-01-12 00:06:11 +00:00
51b7b24607 fix(readme): update README to add interactive setup (tsbundle init), expand quick start and usage examples, include pnpm install, document embedding/base64ts output with Deno example, add project structure recommendations, and clarify license/trademark wording 2026-01-12 00:06:11 +00:00
e3f3dbe1f7 v2.7.1
Some checks failed
Default (tags) / security (push) Successful in 39s
Default (tags) / test (push) Failing after 35s
Default (tags) / release (push) Has been skipped
Default (tags) / metadata (push) Has been skipped
2026-01-11 19:35:20 +00:00
18660b9878 fix(package.json): update repository URL to code.foss.global 2026-01-11 19:35:20 +00:00
1ba76c2f9a v2.7.0
Some checks failed
Default (tags) / security (push) Successful in 39s
Default (tags) / test (push) Failing after 35s
Default (tags) / release (push) Has been skipped
Default (tags) / metadata (push) Has been skipped
2026-01-11 19:02:55 +00:00
5c53602842 feat(tsbundle): add npmextra-driven custom bundles, base64-ts output and interactive init wizard 2026-01-11 19:02:55 +00:00
15 changed files with 1330 additions and 282 deletions

View File

@@ -1,5 +1,43 @@
# Changelog
## 2026-01-12 - 2.7.4 - fix(deps)
bump @push.rocks/smartcli dependency to ^4.0.20
- @push.rocks/smartcli: ^4.0.19 → ^4.0.20
- Patch-level dependency update with no breaking changes
## 2026-01-12 - 2.7.3 - fix(mod_output)
wrap long base64 file contents and format generated TypeScript output to avoid extremely long lines
- Introduce MAX_LINE_LENGTH (200) and formatBase64 to split long base64 strings into chunks and join them with string concatenation
- Emit the files array as nicely indented object entries instead of a single JSON.stringify output to improve readability and avoid extremely long lines
## 2026-01-12 - 2.7.2 - fix(readme)
update README to add interactive setup (tsbundle init), expand quick start and usage examples, include pnpm install, document embedding/base64ts output with Deno example, add project structure recommendations, and clarify license/trademark wording
- Add interactive setup command: `tsbundle init` and updated Quick Start flow
- Include pnpm global install instruction in installation section
- Replace API example with clarified build instructions and new bundle presets (element, website, npm, custom)
- Document embedded bundle output (base64ts) and Deno usage example for decoding/serving files
- Add recommended project structure and formatting improvements (emoji/icons, section reorganizations)
- Clarify license link and expand trademark wording to mention third-party trademarks and approval requirements
## 2026-01-11 - 2.7.1 - fix(package.json)
update repository URL to code.foss.global
- repository.url changed from https://gitlab.com/gitzone/tsbundle.git to https://code.foss.global/git.zone/tsbundle.git
- bugs.url in package.json still points to https://gitlab.com/gitzone/tsbundle/issues
## 2026-01-11 - 2.7.0 - feat(tsbundle)
add npmextra-driven custom bundles, base64-ts output and interactive init wizard
- Add CustomBundleHandler to process bundle configs from npmextra.json (ts/mod_custom/*)
- Implement Base64TsOutput for embedding bundled files as base64 TypeScript (ts/mod_output/*)
- Add interactive 'init' wizard to scaffold npmextra.json bundle presets (ts/mod_init/*)
- Wire new features into CLI: default command runs custom bundles, added 'custom' and 'init' commands (ts/tsbundle.cli.ts)
- Expose @push.rocks/npmextra and @push.rocks/smartinteract in plugins and add them to package.json dependencies
- Update npmextra.json structure and release registries configuration
## 2025-12-02 - 2.6.3 - fix(cli)
Use basename when collecting HTML files for the website CLI command to ensure correct relative paths

View File

@@ -1,5 +1,5 @@
{
"gitzone": {
"@git.zone/cli": {
"projectType": "npm",
"module": {
"githost": "gitlab.com",
@@ -9,10 +9,16 @@
"npmPackagename": "@git.zone/tsbundle",
"license": "MIT",
"projectDomain": "git.zone"
},
"release": {
"registries": [
"https://verdaccio.lossless.one",
"https://registry.npmjs.org"
],
"accessLevel": "public"
}
},
"npmci": {
"npmGlobalTools": [],
"npmAccessLevel": "public"
"@ship.zone/szci": {
"npmGlobalTools": []
}
}
}

View File

@@ -1,6 +1,6 @@
{
"name": "@git.zone/tsbundle",
"version": "2.6.3",
"version": "2.7.4",
"private": false,
"description": "a multi-bundler tool supporting esbuild, rolldown, and rspack for painless bundling of web projects",
"main": "dist_ts/index.js",
@@ -24,9 +24,11 @@
},
"dependencies": {
"@push.rocks/early": "^4.0.4",
"@push.rocks/smartcli": "^4.0.19",
"@push.rocks/npmextra": "^5.1.3",
"@push.rocks/smartcli": "^4.0.20",
"@push.rocks/smartdelay": "^3.0.5",
"@push.rocks/smartfs": "^1.1.3",
"@push.rocks/smartinteract": "^2.0.16",
"@push.rocks/smartlog": "^3.1.8",
"@push.rocks/smartlog-destination-local": "^9.0.2",
"@push.rocks/smartpath": "^6.0.0",
@@ -57,7 +59,7 @@
"packageManager": "pnpm@10.11.0+sha512.6540583f41cc5f628eb3d9773ecee802f4f9ef9923cc45b69890fb47991d4b092964694ec3a4f738a420c918a333062c8b925d312f42e4f0c263eb603551f977",
"repository": {
"type": "git",
"url": "https://gitlab.com/gitzone/tsbundle.git"
"url": "https://code.foss.global/git.zone/tsbundle.git"
},
"bugs": {
"url": "https://gitlab.com/gitzone/tsbundle/issues"

328
pnpm-lock.yaml generated
View File

@@ -11,15 +11,21 @@ importers:
'@push.rocks/early':
specifier: ^4.0.4
version: 4.0.4
'@push.rocks/npmextra':
specifier: ^5.1.3
version: 5.3.3
'@push.rocks/smartcli':
specifier: ^4.0.19
version: 4.0.19
specifier: ^4.0.20
version: 4.0.20
'@push.rocks/smartdelay':
specifier: ^3.0.5
version: 3.0.5
'@push.rocks/smartfs':
specifier: ^1.1.3
version: 1.1.3
'@push.rocks/smartinteract':
specifier: ^2.0.16
version: 2.0.16
'@push.rocks/smartlog':
specifier: ^3.1.8
version: 3.1.10
@@ -695,6 +701,62 @@ packages:
resolution: {integrity: sha512-mfOoUlIw8VBiJYPrl5RZfMzkXC/z7gbSpi2ecycrj/gRWLq2CMV+Q+0G+JPjeOmuNFgg0skEIzkVFzVYFP6URw==}
engines: {node: '>=18.0.0'}
'@inquirer/checkbox@3.0.1':
resolution: {integrity: sha512-0hm2nrToWUdD6/UHnel/UKGdk1//ke5zGUpHIvk5ZWmaKezlGxZkOJXNSWsdxO/rEqTkbB3lNC2J6nBElV2aAQ==}
engines: {node: '>=18'}
'@inquirer/confirm@4.0.1':
resolution: {integrity: sha512-46yL28o2NJ9doViqOy0VDcoTzng7rAb6yPQKU7VDLqkmbCaH4JqK4yk4XqlzNWy9PVC5pG1ZUXPBQv+VqnYs2w==}
engines: {node: '>=18'}
'@inquirer/core@9.2.1':
resolution: {integrity: sha512-F2VBt7W/mwqEU4bL0RnHNZmC/OxzNx9cOYxHqnXX3MP6ruYvZUZAW9imgN9+h/uBT/oP8Gh888J2OZSbjSeWcg==}
engines: {node: '>=18'}
'@inquirer/editor@3.0.1':
resolution: {integrity: sha512-VA96GPFaSOVudjKFraokEEmUQg/Lub6OXvbIEZU1SDCmBzRkHGhxoFAVaF30nyiB4m5cEbDgiI2QRacXZ2hw9Q==}
engines: {node: '>=18'}
'@inquirer/expand@3.0.1':
resolution: {integrity: sha512-ToG8d6RIbnVpbdPdiN7BCxZGiHOTomOX94C2FaT5KOHupV40tKEDozp12res6cMIfRKrXLJyexAZhWVHgbALSQ==}
engines: {node: '>=18'}
'@inquirer/figures@1.0.15':
resolution: {integrity: sha512-t2IEY+unGHOzAaVM5Xx6DEWKeXlDDcNPeDyUpsRc6CUhBfU3VQOEl+Vssh7VNp1dR8MdUJBWhuObjXCsVpjN5g==}
engines: {node: '>=18'}
'@inquirer/input@3.0.1':
resolution: {integrity: sha512-BDuPBmpvi8eMCxqC5iacloWqv+5tQSJlUafYWUe31ow1BVXjW2a5qe3dh4X/Z25Wp22RwvcaLCc2siHobEOfzg==}
engines: {node: '>=18'}
'@inquirer/number@2.0.1':
resolution: {integrity: sha512-QpR8jPhRjSmlr/mD2cw3IR8HRO7lSVOnqUvQa8scv1Lsr3xoAMMworcYW3J13z3ppjBFBD2ef1Ci6AE5Qn8goQ==}
engines: {node: '>=18'}
'@inquirer/password@3.0.1':
resolution: {integrity: sha512-haoeEPUisD1NeE2IanLOiFr4wcTXGWrBOyAyPZi1FfLJuXOzNmxCJPgUrGYKVh+Y8hfGJenIfz5Wb/DkE9KkMQ==}
engines: {node: '>=18'}
'@inquirer/prompts@6.0.1':
resolution: {integrity: sha512-yl43JD/86CIj3Mz5mvvLJqAOfIup7ncxfJ0Btnl0/v5TouVUyeEdcpknfgc+yMevS/48oH9WAkkw93m7otLb/A==}
engines: {node: '>=18'}
'@inquirer/rawlist@3.0.1':
resolution: {integrity: sha512-VgRtFIwZInUzTiPLSfDXK5jLrnpkuSOh1ctfaoygKAdPqjcjKYmGh6sCY1pb0aGnCGsmhUxoqLDUAU0ud+lGXQ==}
engines: {node: '>=18'}
'@inquirer/search@2.0.1':
resolution: {integrity: sha512-r5hBKZk3g5MkIzLVoSgE4evypGqtOannnB3PKTG9NRZxyFRKcfzrdxXXPcoJQsxJPzvdSU2Rn7pB7lw0GCmGAg==}
engines: {node: '>=18'}
'@inquirer/select@3.0.1':
resolution: {integrity: sha512-lUDGUxPhdWMkN/fHy1Lk7pF3nK1fh/gqeyWXmctefhxLYxlDsc7vsPBEpxrfVGDsVdyYJsiJoD4bJ1b623cV1Q==}
engines: {node: '>=18'}
'@inquirer/type@2.0.0':
resolution: {integrity: sha512-XvJRx+2KR3YXyYtPUUy+qd9i7p+GO9Ko6VIIpWlBrpWwXDv8WLFeHTxz35CfQFUiBMLXlGHhGzys7lqit9gWag==}
engines: {node: '>=18'}
'@isaacs/balanced-match@4.0.1':
resolution: {integrity: sha512-yzMTt9lEb8Gv7zRioUilSglI0c0smZ9k5D65677DLWLtWJaXIS3CqcGyUFByYKlnUj6TkjLVs54fBl6+TiGQDQ==}
engines: {node: 20 || >=22}
@@ -824,6 +886,9 @@ packages:
'@push.rocks/mongodump@1.1.0':
resolution: {integrity: sha512-kW0ZUGyf1e4nwloVwBQjNId+MzgTcNS834C+RxH21i1NqyOubbpWZtJtPP+K+s35nSJRyCTy3ICfBMdDBTAm2w==}
'@push.rocks/npmextra@5.3.3':
resolution: {integrity: sha512-snLpSHwaQ5OXlZzF1KX/FY71W5LwajjBzor82Vue0smjEPnSeUPY5/JcVdMwtdprdJe13pc/EQQuIiL/zw4/yg==}
'@push.rocks/qenv@6.1.3':
resolution: {integrity: sha512-+z2hsAU/7CIgpYLFqvda8cn9rUBMHqLdQLjsFfRn5jPoD7dJ5rFlpkbhfM4Ws8mHMniwWaxGKo+q/YBhtzRBLg==}
@@ -848,8 +913,8 @@ packages:
'@push.rocks/smartchok@1.1.1':
resolution: {integrity: sha512-WmNigGmn1muBJMANVuJb4F8x3TzgYrnn6YZm6ixTsG+0WFbYevivEwp+J4S7npobLHsR7ynf+Ky8LxRYmsL50A==}
'@push.rocks/smartcli@4.0.19':
resolution: {integrity: sha512-s1jZSgDZWi/az26AY4TJ2HPuG1qZzGC5R9fKWaECLmwnSpk6y9JXL5dnJAUohcdu50kdXCWEcRmLfYxOt81vEA==}
'@push.rocks/smartcli@4.0.20':
resolution: {integrity: sha512-gCo4ItvsPj8WoVAJw/6vkuoGA5FtIoACux2ktcCeH0nrFe7/xGR6waJ1aZcYAi7QN4gi52TlsgwuKz7BzXqhmQ==}
'@push.rocks/smartclickhouse@2.0.17':
resolution: {integrity: sha512-IYO8Obor/Ruam2KQ2B/+5uQ+rL0exU5KZoSgOc3jkkrfjn+zZenN2xoV8lVqavAtxZVfG7MfxFrcv6I7I9ZMmA==}
@@ -902,6 +967,9 @@ packages:
'@push.rocks/smarthash@3.2.6':
resolution: {integrity: sha512-Mq/WNX0Tjjes3X1gHd/ZBwOOKSrAG/Z3Xoc0OcCm3P20WKpniihkMpsnlE7wGjvpHLi/ZRe/XkB3KC3d5r9X4g==}
'@push.rocks/smartinteract@2.0.16':
resolution: {integrity: sha512-eltvVRRUKBKd77DSFA4DPY2g4V4teZLNe8A93CDy/WglglYcUjxMoLY/b0DFTWCWKYT+yjk6Fe6p0FRrvX9Yvg==}
'@push.rocks/smartjson@5.2.0':
resolution: {integrity: sha512-710e8UwovRfPgUtaBHcd6unaODUjV5fjxtGcGCqtaTcmvOV6VpasdVfT66xMDzQmWH2E9ZfHDJeso9HdDQzNQA==}
@@ -1549,9 +1617,15 @@ packages:
'@types/ms@2.1.0':
resolution: {integrity: sha512-GsCCIZDE/p3i96vtEqx+7dBUGXrc7zeSK3wwPHIaRThS+9OhWIXRqzs4d6k1SVU8g91DrNRWxWUGhp5KXQb2VA==}
'@types/mute-stream@0.0.4':
resolution: {integrity: sha512-CPM9nzrCPPJHQNA9keH9CVkVI+WR5kMa+7XEs5jcGQ0VoAGnLv242w8lIVgwAEfmE4oufJRaTc9PNLQl0ioAow==}
'@types/node-forge@1.3.14':
resolution: {integrity: sha512-mhVF2BnD4BO+jtOp7z1CdzaK4mbuK0LLQYAvdOLqHTavxFNq4zA1EmYkpnFjP8HOUzedfQkRnp0E2ulSAYSzAw==}
'@types/node@22.19.5':
resolution: {integrity: sha512-HfF8+mYcHPcPypui3w3mvzuIErlNOh2OAG+BCeBZCEwyiD5ls2SiCwEyT47OELtf7M3nHxBdu0FsmzdKxkN52Q==}
'@types/node@24.10.1':
resolution: {integrity: sha512-GNWcUTRBgIRJD5zj+Tq0fKOJ5XZajIiBroOF0yvj2bSU1WvNdYS/dn9UxwsujGW4JX06dnHyjV2y9rRaybH0iQ==}
@@ -1615,6 +1689,9 @@ packages:
'@types/which@3.0.4':
resolution: {integrity: sha512-liyfuo/106JdlgSchJzXEQCVArk0CvevqPote8F8HgWgJ3dRCcTHgJIsLDuee0kxk/mhbInzIZk3QWSZJ8R+2w==}
'@types/wrap-ansi@3.0.0':
resolution: {integrity: sha512-ltIpx+kM7g/MLRZfkbL7EsCEjfzCcScLpkg37eXEtx5kmrAKBkTJwd1GIAjDSL8wTpM6Hzn5YO4pSb91BEwu1g==}
'@types/ws@8.18.1':
resolution: {integrity: sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg==}
@@ -1648,6 +1725,10 @@ packages:
resolution: {integrity: sha1-kQ3lDvzHwJ49gvL4er1rcAwYgYo=}
engines: {node: '>=0.10.0'}
ansi-escapes@4.3.2:
resolution: {integrity: sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ==}
engines: {node: '>=8'}
ansi-regex@5.0.1:
resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==}
engines: {node: '>=8'}
@@ -1832,6 +1913,9 @@ packages:
character-entities@2.0.2:
resolution: {integrity: sha512-shx7oQ0Awen/BRIdkjkvz54PnEEI/EjwXDSIZp86/KKdbafHh1Df/RYGBhn4hbe2+uKC9FnT5UCEdyPz3ai9hQ==}
chardet@0.7.0:
resolution: {integrity: sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==}
chokidar@4.0.3:
resolution: {integrity: sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==}
engines: {node: '>= 14.16.0'}
@@ -1849,6 +1933,10 @@ packages:
resolution: {integrity: sha1-noIVAa6XmYbEax1m0tQy2y/UrjE=}
engines: {node: '>=4'}
cli-width@4.1.0:
resolution: {integrity: sha512-ouuZd4/dm2Sw5Gmqy6bGyNNNe1qt9RpmxveLSO7KcgsTnU7RXfsw+/bukWGo1abgBiMAic068rclZsO4IWmmxQ==}
engines: {node: '>= 12'}
cliui@8.0.1:
resolution: {integrity: sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==}
engines: {node: '>=12'}
@@ -2129,6 +2217,10 @@ packages:
extend@3.0.2:
resolution: {integrity: sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==}
external-editor@3.1.0:
resolution: {integrity: sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew==}
engines: {node: '>=4'}
extract-zip@2.0.1:
resolution: {integrity: sha512-GDhU9ntwuKyGXdZBUgTIe+vXnWj0fppUEtMDL0+idd5Sta8TGpHssn/eusA9mrPr9qNDym6SxAYZjNvCn/9RBg==}
engines: {node: '>= 10.17.0'}
@@ -2369,6 +2461,10 @@ packages:
humanize-ms@1.2.1:
resolution: {integrity: sha1-xG4xWaKT9riW2ikxbYtv6Lt5u+0=}
iconv-lite@0.4.24:
resolution: {integrity: sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==}
engines: {node: '>=0.10.0'}
iconv-lite@0.6.3:
resolution: {integrity: sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==}
engines: {node: '>=0.10.0'}
@@ -2393,6 +2489,10 @@ packages:
ini@1.3.8:
resolution: {integrity: sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==}
inquirer@11.1.0:
resolution: {integrity: sha512-CmLAZT65GG/v30c+D2Fk8+ceP6pxD6RL+hIUOWAltCmeyEqWYwqu9v76q03OvjyZ3AB0C1Ala2stn1z/rMqGEw==}
engines: {node: '>=18'}
ip-address@10.1.0:
resolution: {integrity: sha512-XXADHxXmvT9+CRxhXg56LJovE+bmWnEWB78LB83VZTprKTmaC5QfruXocxzTZ2Kl0DNwKuBdlIhjL8LeY8Sf8Q==}
engines: {node: '>= 12'}
@@ -2834,6 +2934,10 @@ packages:
ms@2.1.3:
resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==}
mute-stream@1.0.0:
resolution: {integrity: sha512-avsJQhyd+680gKXyG/sQc0nXaC6rBkPOfyHYcFb9+hdkqQkR9bdnkJ0AMZhke0oesPqIO+mFFJ+IdBc7mst4IA==}
engines: {node: ^14.17.0 || ^16.13.0 || >=18.0.0}
nanoid@4.0.2:
resolution: {integrity: sha512-7ZtY5KTCNheRGfEFxnedV5zFiORN1+Y1N6zvPTnHQd8ENUvfaDBeuJDZb2bN/oXwXxu3qkTXDzy57W5vAmDTBw==}
engines: {node: ^14 || ^16 || >=18}
@@ -2900,6 +3004,10 @@ packages:
resolution: {integrity: sha512-7x81NCL719oNbsq/3mh+hVrAWmFuEYUqrq/Iw3kUzH8ReypT9QQ0BLoJS7/G9k6N81XjW4qHWtjWwe/9eLy1EQ==}
engines: {node: '>=12'}
os-tmpdir@1.0.2:
resolution: {integrity: sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=}
engines: {node: '>=0.10.0'}
p-cancelable@3.0.0:
resolution: {integrity: sha512-mlVgR3PGuzlo0MmTdk4cXqXWlwQDLnONTAg6sm62XkMJEiRxN3GL3SffkYvqwonbkJBcrI7Uvv5Zh9yjvn2iUw==}
engines: {node: '>=12.20'}
@@ -3163,6 +3271,10 @@ packages:
resolution: {integrity: sha512-nLTrUKm2UyiL7rlhapu/Zl45FwNgkZGaCpZbIHajDYgwlJCOzLSk+cIPAnsEqV955GjILJnKbdQC1nVPz+gAYQ==}
engines: {node: '>= 18'}
run-async@3.0.0:
resolution: {integrity: sha512-540WwVDOMxA6dN6We19EcT9sc3hkXPw5mzRNGM3FkdN/vtE9NFvj5lFAPNwUDmJjXidm3v7TC1cTE7t17Ulm1Q==}
engines: {node: '>=0.12.0'}
rxjs@7.8.2:
resolution: {integrity: sha512-dhKf903U/PQZY6boNNtAGdWbG85WAbjT/1xYoZIC7FAY0yWapOBQVsVrDl58W86//e1VpMNBtRV4MaXfdMySFA==}
@@ -3352,6 +3464,10 @@ packages:
tiny-worker@2.3.0:
resolution: {integrity: sha512-pJ70wq5EAqTAEl9IkGzA+fN0836rycEuz2Cn6yeZ6FRzlVS5IDOkFHpIoEsksPRQV34GDqXm65+OlnZqUSyK2g==}
tmp@0.0.33:
resolution: {integrity: sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==}
engines: {node: '>=0.6.0'}
toidentifier@1.0.1:
resolution: {integrity: sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==}
engines: {node: '>=0.6'}
@@ -3395,6 +3511,10 @@ packages:
turndown@7.2.2:
resolution: {integrity: sha512-1F7db8BiExOKxjSMU2b7if62D/XOyQyZbPKq/nUwopfgnHlqXHqQ0lvfUTeUIr1lZJzOPFn43dODyMSIfvWRKQ==}
type-fest@0.21.3:
resolution: {integrity: sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==}
engines: {node: '>=10'}
type-fest@2.19.0:
resolution: {integrity: sha512-RAH822pAdBgcNMAfWnCBU3CFZcfZ/i1eZjwFU/dsLKumyuuP3niueg2UAukXYF0E2AAoc82ZSSf9J0WQBinzHA==}
engines: {node: '>=12.20'}
@@ -3429,6 +3549,9 @@ packages:
resolution: {integrity: sha512-rvKSBiC5zqCCiDZ9kAOszZcDvdAHwwIKJG33Ykj43OKcWsnmcBRL09YTU4nOeHZ8Y2a7l1MgTd08SBe9A8Qj6A==}
engines: {node: '>=18'}
undici-types@6.21.0:
resolution: {integrity: sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==}
undici-types@7.16.0:
resolution: {integrity: sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==}
@@ -3510,6 +3633,10 @@ packages:
engines: {node: ^18.17.0 || >=20.5.0}
hasBin: true
wrap-ansi@6.2.0:
resolution: {integrity: sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==}
engines: {node: '>=8'}
wrap-ansi@7.0.0:
resolution: {integrity: sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==}
engines: {node: '>=10'}
@@ -3577,6 +3704,10 @@ packages:
resolution: {integrity: sha512-Ow9nuGZE+qp1u4JIPvg+uCiUr7xGQWdff7JQSk5VGYTAZMDe2q8lxJ10ygv10qmSj031Ty/6FNJpLO4o1Sgc+w==}
engines: {node: '>=12'}
yoctocolors-cjs@2.1.3:
resolution: {integrity: sha512-U/PBtDf35ff0D8X8D0jfdzHYEPFxAI7jJlxZXwCSez5M3190m+QobIfh+sWDWSHMCWWJN2AWamkegn6vr6YBTw==}
engines: {node: '>=18'}
zod@3.25.76:
resolution: {integrity: sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==}
@@ -4722,7 +4853,7 @@ snapshots:
dependencies:
'@git.zone/tspublish': 1.10.3
'@push.rocks/early': 4.0.4
'@push.rocks/smartcli': 4.0.19
'@push.rocks/smartcli': 4.0.20
'@push.rocks/smartdelay': 3.0.5
'@push.rocks/smartfile': 11.2.7
'@push.rocks/smartlog': 3.1.10
@@ -4741,7 +4872,7 @@ snapshots:
'@git.zone/tsbundle@2.5.2':
dependencies:
'@push.rocks/early': 4.0.4
'@push.rocks/smartcli': 4.0.19
'@push.rocks/smartcli': 4.0.20
'@push.rocks/smartdelay': 3.0.5
'@push.rocks/smartfile': 11.2.7
'@push.rocks/smartlog': 3.1.10
@@ -4762,7 +4893,7 @@ snapshots:
'@git.zone/tspublish@1.10.3':
dependencies:
'@push.rocks/consolecolor': 2.0.3
'@push.rocks/smartcli': 4.0.19
'@push.rocks/smartcli': 4.0.20
'@push.rocks/smartdelay': 3.0.5
'@push.rocks/smartfile': 11.2.7
'@push.rocks/smartlog': 3.1.10
@@ -4837,6 +4968,102 @@ snapshots:
dependencies:
happy-dom: 15.11.7
'@inquirer/checkbox@3.0.1':
dependencies:
'@inquirer/core': 9.2.1
'@inquirer/figures': 1.0.15
'@inquirer/type': 2.0.0
ansi-escapes: 4.3.2
yoctocolors-cjs: 2.1.3
'@inquirer/confirm@4.0.1':
dependencies:
'@inquirer/core': 9.2.1
'@inquirer/type': 2.0.0
'@inquirer/core@9.2.1':
dependencies:
'@inquirer/figures': 1.0.15
'@inquirer/type': 2.0.0
'@types/mute-stream': 0.0.4
'@types/node': 22.19.5
'@types/wrap-ansi': 3.0.0
ansi-escapes: 4.3.2
cli-width: 4.1.0
mute-stream: 1.0.0
signal-exit: 4.1.0
strip-ansi: 6.0.1
wrap-ansi: 6.2.0
yoctocolors-cjs: 2.1.3
'@inquirer/editor@3.0.1':
dependencies:
'@inquirer/core': 9.2.1
'@inquirer/type': 2.0.0
external-editor: 3.1.0
'@inquirer/expand@3.0.1':
dependencies:
'@inquirer/core': 9.2.1
'@inquirer/type': 2.0.0
yoctocolors-cjs: 2.1.3
'@inquirer/figures@1.0.15': {}
'@inquirer/input@3.0.1':
dependencies:
'@inquirer/core': 9.2.1
'@inquirer/type': 2.0.0
'@inquirer/number@2.0.1':
dependencies:
'@inquirer/core': 9.2.1
'@inquirer/type': 2.0.0
'@inquirer/password@3.0.1':
dependencies:
'@inquirer/core': 9.2.1
'@inquirer/type': 2.0.0
ansi-escapes: 4.3.2
'@inquirer/prompts@6.0.1':
dependencies:
'@inquirer/checkbox': 3.0.1
'@inquirer/confirm': 4.0.1
'@inquirer/editor': 3.0.1
'@inquirer/expand': 3.0.1
'@inquirer/input': 3.0.1
'@inquirer/number': 2.0.1
'@inquirer/password': 3.0.1
'@inquirer/rawlist': 3.0.1
'@inquirer/search': 2.0.1
'@inquirer/select': 3.0.1
'@inquirer/rawlist@3.0.1':
dependencies:
'@inquirer/core': 9.2.1
'@inquirer/type': 2.0.0
yoctocolors-cjs: 2.1.3
'@inquirer/search@2.0.1':
dependencies:
'@inquirer/core': 9.2.1
'@inquirer/figures': 1.0.15
'@inquirer/type': 2.0.0
yoctocolors-cjs: 2.1.3
'@inquirer/select@3.0.1':
dependencies:
'@inquirer/core': 9.2.1
'@inquirer/figures': 1.0.15
'@inquirer/type': 2.0.0
ansi-escapes: 4.3.2
yoctocolors-cjs: 2.1.3
'@inquirer/type@2.0.0':
dependencies:
mute-stream: 1.0.0
'@isaacs/balanced-match@4.0.1': {}
'@isaacs/brace-expansion@5.0.0':
@@ -5092,6 +5319,23 @@ snapshots:
- snappy
- socks
'@push.rocks/npmextra@5.3.3':
dependencies:
'@push.rocks/qenv': 6.1.3
'@push.rocks/smartfile': 11.2.7
'@push.rocks/smartjson': 5.2.0
'@push.rocks/smartlog': 3.1.10
'@push.rocks/smartpath': 6.0.0
'@push.rocks/smartpromise': 4.2.3
'@push.rocks/smartrx': 3.0.10
'@push.rocks/taskbuffer': 3.4.0
'@tsclass/tsclass': 9.3.0
transitivePeerDependencies:
- '@nuxt/kit'
- react
- supports-color
- vue
'@push.rocks/qenv@6.1.3':
dependencies:
'@api.global/typedrequest': 3.1.10
@@ -5184,7 +5428,7 @@ snapshots:
chokidar: 4.0.3
picomatch: 4.0.3
'@push.rocks/smartcli@4.0.19':
'@push.rocks/smartcli@4.0.20':
dependencies:
'@push.rocks/lik': 6.2.2
'@push.rocks/smartlog': 3.1.10
@@ -5342,6 +5586,13 @@ snapshots:
'@types/through2': 2.0.41
through2: 4.0.2
'@push.rocks/smartinteract@2.0.16':
dependencies:
'@push.rocks/lik': 6.2.2
'@push.rocks/smartobject': 1.0.12
'@push.rocks/smartpromise': 4.2.3
inquirer: 11.1.0
'@push.rocks/smartjson@5.2.0':
dependencies:
'@push.rocks/smartenv': 5.0.13
@@ -6340,10 +6591,18 @@ snapshots:
'@types/ms@2.1.0': {}
'@types/mute-stream@0.0.4':
dependencies:
'@types/node': 24.10.1
'@types/node-forge@1.3.14':
dependencies:
'@types/node': 24.10.1
'@types/node@22.19.5':
dependencies:
undici-types: 6.21.0
'@types/node@24.10.1':
dependencies:
undici-types: 7.16.0
@@ -6405,6 +6664,8 @@ snapshots:
'@types/which@3.0.4': {}
'@types/wrap-ansi@3.0.0': {}
'@types/ws@8.18.1':
dependencies:
'@types/node': 24.10.1
@@ -6444,6 +6705,10 @@ snapshots:
ansi-256-colors@1.1.0: {}
ansi-escapes@4.3.2:
dependencies:
type-fest: 0.21.3
ansi-regex@5.0.1: {}
ansi-regex@6.2.2: {}
@@ -6628,6 +6893,8 @@ snapshots:
character-entities@2.0.2: {}
chardet@0.7.0: {}
chokidar@4.0.3:
dependencies:
readdirp: 4.1.2
@@ -6644,6 +6911,8 @@ snapshots:
clean-stack@1.3.0: {}
cli-width@4.1.0: {}
cliui@8.0.1:
dependencies:
string-width: 4.2.3
@@ -6980,6 +7249,12 @@ snapshots:
extend@3.0.2: {}
external-editor@3.1.0:
dependencies:
chardet: 0.7.0
iconv-lite: 0.4.24
tmp: 0.0.33
extract-zip@2.0.1:
dependencies:
debug: 4.4.3
@@ -7290,6 +7565,10 @@ snapshots:
dependencies:
ms: 2.1.3
iconv-lite@0.4.24:
dependencies:
safer-buffer: 2.1.2
iconv-lite@0.6.3:
dependencies:
safer-buffer: 2.1.2
@@ -7314,6 +7593,17 @@ snapshots:
ini@1.3.8: {}
inquirer@11.1.0:
dependencies:
'@inquirer/core': 9.2.1
'@inquirer/prompts': 6.0.1
'@inquirer/type': 2.0.0
'@types/mute-stream': 0.0.4
ansi-escapes: 4.3.2
mute-stream: 1.0.0
run-async: 3.0.0
rxjs: 7.8.2
ip-address@10.1.0: {}
ipaddr.js@1.9.1: {}
@@ -7905,6 +8195,8 @@ snapshots:
ms@2.1.3: {}
mute-stream@1.0.0: {}
nanoid@4.0.2: {}
negotiator@0.6.3: {}
@@ -7955,6 +8247,8 @@ snapshots:
is-docker: 2.2.1
is-wsl: 2.2.0
os-tmpdir@1.0.2: {}
p-cancelable@3.0.0: {}
p-finally@1.0.0: {}
@@ -8280,6 +8574,8 @@ snapshots:
transitivePeerDependencies:
- supports-color
run-async@3.0.0: {}
rxjs@7.8.2:
dependencies:
tslib: 2.8.1
@@ -8550,6 +8846,10 @@ snapshots:
dependencies:
esm: 3.2.25
tmp@0.0.33:
dependencies:
os-tmpdir: 1.0.2
toidentifier@1.0.1: {}
token-types@6.1.1:
@@ -8589,6 +8889,8 @@ snapshots:
dependencies:
'@mixmark-io/domino': 2.2.0
type-fest@0.21.3: {}
type-fest@2.19.0: {}
type-fest@4.41.0: {}
@@ -8609,6 +8911,8 @@ snapshots:
uint8array-extras@1.5.0: {}
undici-types@6.21.0: {}
undici-types@7.16.0: {}
unified@11.0.5:
@@ -8692,6 +8996,12 @@ snapshots:
dependencies:
isexe: 3.1.1
wrap-ansi@6.2.0:
dependencies:
ansi-styles: 4.3.0
string-width: 4.2.3
strip-ansi: 6.0.1
wrap-ansi@7.0.0:
dependencies:
ansi-styles: 4.3.0
@@ -8740,6 +9050,8 @@ snapshots:
buffer-crc32: 0.2.13
pend: 1.2.0
yoctocolors-cjs@2.1.3: {}
zod@3.25.76: {}
zwitch@2.0.4: {}

402
readme.md
View File

@@ -1,6 +1,6 @@
# @git.zone/tsbundle
A powerful multi-bundler tool supporting esbuild, rolldown, and rspack for painless bundling of web projects.
A powerful multi-bundler tool supporting **esbuild**, **rolldown**, and **rspack** for painless bundling of web projects. 🚀
## Issue Reporting and Security
@@ -14,136 +14,128 @@ npm install -g @git.zone/tsbundle
# Local installation for project usage
npm install --save-dev @git.zone/tsbundle
# Or with pnpm
pnpm add -g @git.zone/tsbundle
```
## Quick Start
## Quick Start
### CLI Usage
### Interactive Setup
The simplest way to bundle your project:
The easiest way to get started is with the interactive wizard:
```bash
tsbundle init
```
This will guide you through setting up your bundle configuration with preset options:
- **element** - Web component / element bundle (`./ts_web/index.ts``./dist_bundle/bundle.js`)
- **website** - Full website with HTML and assets (`./ts_web/index.ts``./dist_serve/bundle.js`)
- **npm** - NPM package bundle (`./ts/index.ts``./dist_bundle/bundle.js`)
- **custom** - Configure everything manually
### Build Your Bundles
Once configured, simply run:
```bash
# Bundle with default settings (from ./ts_web/index.ts to ./dist_bundle/bundle.js)
tsbundle
# Bundle with custom paths
tsbundle --from="./src/index.ts" --to="./dist/bundle.js"
# Production build with minification
tsbundle --from="./src/index.ts" --to="./dist/bundle.js" --production
# Use a specific bundler
tsbundle --bundler=rolldown
```
### API Usage
```typescript
import { TsBundle } from '@git.zone/tsbundle';
const bundler = new TsBundle();
// Basic usage
await bundler.build(
process.cwd(), // working directory
'./src/index.ts', // entry point
'./dist/bundle.js', // output file
{ bundler: 'esbuild' }, // options
);
// Production build with rolldown
await bundler.build(process.cwd(), './src/index.ts', './dist/bundle.min.js', {
bundler: 'rolldown',
production: true,
});
```
## Available Bundlers
tsbundle supports three modern bundlers, each with its own strengths:
- **esbuild** (default): Extremely fast, great for development
- **rolldown**: Rust-based bundler with excellent tree-shaking
- **rspack**: High-performance bundler with webpack compatibility
Select your bundler using the `--bundler` flag in CLI or the `bundler` option in API.
That's it! Your bundles will be built according to your `npmextra.json` configuration.
## CLI Commands
### Default Command
| Command | Description |
|---------|-------------|
| `tsbundle` | Build all bundles from `npmextra.json` configuration |
| `tsbundle custom` | Same as above (explicit) |
| `tsbundle init` | Interactive wizard to create/update bundle configuration |
Bundle TypeScript/JavaScript projects:
## Configuration 📝
```bash
tsbundle [options]
tsbundle uses `npmextra.json` for configuration. Here's an example:
Options:
--from Source entry point (default: ./ts_web/index.ts)
--to Output bundle path (default: ./dist_bundle/bundle.js)
--production Enable production mode with minification
--bundler Choose bundler: esbuild, rolldown, or rspack
--commonjs Output CommonJS format instead of ESM
--skiplibcheck Skip TypeScript library checking
```json
{
"@git.zone/tsbundle": {
"bundles": [
{
"from": "./ts_web/index.ts",
"to": "./dist_bundle/bundle.js",
"outputMode": "bundle",
"bundler": "esbuild",
"production": false
},
{
"from": "./ts_web/index.ts",
"to": "./dist_serve/bundle.js",
"outputMode": "bundle",
"bundler": "esbuild",
"includeFiles": ["./html/**/*.html", "./assets/**/*"]
}
]
}
}
```
### Specialized Commands
### Bundle Configuration Options
#### `tsbundle element`
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| `from` | `string` | - | Entry point TypeScript file |
| `to` | `string` | - | Output file path |
| `outputMode` | `"bundle"` \| `"base64ts"` | `"bundle"` | Output format (see below) |
| `bundler` | `"esbuild"` \| `"rolldown"` \| `"rspack"` | `"esbuild"` | Which bundler to use |
| `production` | `boolean` | `false` | Enable minification |
| `includeFiles` | `string[]` | `[]` | Glob patterns for additional files (HTML, assets) |
Bundle web components with standard naming conventions:
### Output Modes
```bash
tsbundle element
# Bundles from ./ts_web/elements/<elementName>.ts to ./dist_bundle/bundle.js
#### `bundle` (default)
Standard JavaScript bundle output. Additional files specified in `includeFiles` are copied to the output directory.
#### `base64ts`
Generates a TypeScript file with base64-encoded content - perfect for **Deno compile** scenarios where you need everything embedded in a single executable:
```typescript
// Auto-generated by tsbundle
export const files: { path: string; contentBase64: string }[] = [
{ path: "bundle.js", contentBase64: "Y29uc3QgaGVsbG8gPSAid29ybGQi..." },
{ path: "index.html", contentBase64: "PCFET0NUWVBFIGh0bWw+..." },
];
```
#### `tsbundle npm`
## Available Bundlers 🔧
Bundle npm packages for distribution:
tsbundle supports three modern bundlers:
```bash
tsbundle npm
# Prepares your package for npm publishing
```
| Bundler | Speed | Best For |
|---------|-------|----------|
| **esbuild** | ⚡⚡⚡ Blazing fast | Development, quick iterations |
| **rolldown** | ⚡⚡ Fast | Production builds, tree-shaking |
| **rspack** | ⚡⚡ Fast | Webpack compatibility |
#### `tsbundle website`
Full website bundling with HTML processing and asset handling:
```bash
tsbundle website
# Bundles JavaScript, processes HTML, and copies assets
```
## API Reference
## API Usage
### TsBundle Class
The main bundler class for programmatic usage.
```typescript
import { TsBundle } from '@git.zone/tsbundle';
const bundler = new TsBundle();
// Method signature
await bundler.build(
cwdArg: string, // Working directory
fromArg?: string, // Entry point (default: './ts_web/index.ts')
toArg?: string, // Output path (default: './dist_bundle/bundle.js')
argvArg?: ICliOptions // Configuration options
): Promise<void>
```
#### ICliOptions Interface
```typescript
interface ICliOptions {
bundler: 'esbuild' | 'rolldown' | 'rspack'; // Bundler to use
production?: boolean; // Enable production optimizations
commonjs?: boolean; // Output CommonJS format
skiplibcheck?: boolean; // Skip TypeScript lib checking
}
process.cwd(), // Working directory
'./src/index.ts', // Entry point
'./dist/bundle.js', // Output path
{
bundler: 'esbuild',
production: true
}
);
```
### HtmlHandler Class
@@ -155,156 +147,152 @@ import { HtmlHandler } from '@git.zone/tsbundle';
const htmlHandler = new HtmlHandler();
// Check if HTML files exist
const exists = await htmlHandler.checkIfExists();
// Process HTML with options
await htmlHandler.processHtml({
from: './src/index.html', // Source HTML (default: './html/index.html')
to: './dist/index.html', // Output HTML (default: './dist_serve/index.html')
minify: true, // Enable minification
from: './html/index.html',
to: './dist/index.html',
minify: true
});
```
### AssetsHandler Class
Handle static assets (images, fonts, etc.):
Handle static assets:
```typescript
import { AssetsHandler } from '@git.zone/tsbundle';
const assetsHandler = new AssetsHandler();
// Ensure assets directory exists
await assetsHandler.ensureAssetsDir();
// Copy and process assets
await assetsHandler.processAssets({
from: './src/assets', // Source directory (default: './assets')
to: './dist/assets', // Output directory (default: './dist_serve/assets')
from: './assets',
to: './dist/assets'
});
```
## Advanced Examples
## Complete Example 🎯
### Building a Modern Web Application
### 1. Initialize your project
```typescript
import { TsBundle, HtmlHandler, AssetsHandler } from '@git.zone/tsbundle';
async function buildWebApp() {
const bundler = new TsBundle();
const htmlHandler = new HtmlHandler();
const assetsHandler = new AssetsHandler();
// Bundle the JavaScript
await bundler.build(process.cwd(), './src/app.ts', './dist/app.js', {
bundler: 'rolldown',
production: true,
});
// Process HTML
await htmlHandler.processHtml({
from: './src/index.html',
to: './dist/index.html',
minify: true,
});
// Copy assets
await assetsHandler.processAssets({
from: './src/assets',
to: './dist/assets',
});
console.log('Build complete!');
}
buildWebApp();
```bash
tsbundle init
```
### Multi-Entry Point Bundling
Select "website" preset for a full web application setup.
```typescript
import { TsBundle } from '@git.zone/tsbundle';
async function buildMultipleEntries() {
const bundler = new TsBundle();
const entries = [
{ from: './src/main.ts', to: './dist/main.js' },
{ from: './src/admin.ts', to: './dist/admin.js' },
{ from: './src/worker.ts', to: './dist/worker.js' },
];
for (const entry of entries) {
await bundler.build(process.cwd(), entry.from, entry.to, {
bundler: 'esbuild',
});
}
}
```
### Development vs Production Builds
```typescript
import { TsBundle } from '@git.zone/tsbundle';
const bundler = new TsBundle();
const isDev = process.env.NODE_ENV === 'development';
await bundler.build(
process.cwd(),
'./src/index.ts',
isDev ? './dist/dev/bundle.js' : './dist/prod/bundle.min.js',
{
bundler: isDev ? 'esbuild' : 'rolldown', // esbuild for speed in dev
production: !isDev, // minify in production
commonjs: false, // use ES modules
},
);
```
## TypeScript Configuration
tsbundle works best with the following TypeScript configuration:
### 2. Your generated config
```json
{
"compilerOptions": {
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "node",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true
"@git.zone/tsbundle": {
"bundles": [
{
"from": "./ts_web/index.ts",
"to": "./dist_serve/bundle.js",
"outputMode": "bundle",
"bundler": "esbuild",
"includeFiles": ["./html/**/*.html", "./assets/**/*"]
}
]
}
}
```
## Best Practices
### 3. Create your entry point
1. **Entry Points**: Keep your entry points in `ts_web/` for web bundles or `ts/` for library bundles
2. **Output Structure**: Use `dist_bundle/` for bundled files and `dist_serve/` for web-ready files
3. **Bundler Selection**:
- Use `esbuild` for development (fastest)
- Use `rolldown` or `rspack` for production (better optimization)
4. **Assets**: Place static assets in the `assets/` directory
5. **HTML**: Keep HTML templates in the `html/` directory
```typescript
// ts_web/index.ts
console.log('Hello from tsbundle! 🚀');
export const app = {
version: '1.0.0',
init() {
console.log('App initialized');
}
};
app.init();
```
### 4. Build
```bash
tsbundle
```
Your bundle is ready in `./dist_serve/bundle.js` along with any HTML and assets!
## Embedding for Deno Compile 🦕
For single-executable scenarios with Deno:
```bash
tsbundle init
# Select "custom", set outputMode to "base64ts"
```
Config:
```json
{
"@git.zone/tsbundle": {
"bundles": [
{
"from": "./ts_web/index.ts",
"to": "./ts/embedded-bundle.ts",
"outputMode": "base64ts",
"bundler": "esbuild",
"production": true,
"includeFiles": ["./html/index.html"]
}
]
}
}
```
Then in your Deno app:
```typescript
import { files } from './ts/embedded-bundle.ts';
// Decode and serve your embedded files
const bundle = files.find(f => f.path === 'bundle.js');
const html = files.find(f => f.path === 'html/index.html');
const bundleContent = atob(bundle.contentBase64);
const htmlContent = atob(html.contentBase64);
```
## Project Structure Recommendations 📁
```
your-project/
├── ts_web/ # Web bundle entry points
│ └── index.ts
├── ts/ # Library/node entry points
│ └── index.ts
├── html/ # HTML templates
│ └── index.html
├── assets/ # Static assets (images, fonts, etc.)
├── dist_bundle/ # Output for element/npm bundles
├── dist_serve/ # Output for website bundles
└── npmextra.json # tsbundle configuration
```
## License and Legal Information
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
This repository contains open-source code licensed under the MIT License. A copy of the license can be found in the [LICENSE](./LICENSE) file.
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
### Trademarks
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH or third parties, and are not included within the scope of the MIT license granted herein.
Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines or the guidelines of the respective third-party owners, and any usage must be approved in writing. Third-party trademarks used herein are the property of their respective owners and used only in a descriptive manner, e.g. for an implementation of an API or similar.
### Company Information
Task Venture Capital GmbH
Registered at District court Bremen HRB 35230 HB, Germany
Task Venture Capital GmbH
Registered at District Court Bremen HRB 35230 HB, Germany
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
For any legal inquiries or further information, please contact us via email at hello@task.vc.
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.

View File

@@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@git.zone/tsbundle',
version: '2.6.3',
version: '2.7.4',
description: 'a multi-bundler tool supporting esbuild, rolldown, and rspack for painless bundling of web projects'
}

View File

@@ -12,3 +12,25 @@ export interface IEnvTransportOptions {
mode: 'test' | 'production';
argv: ICliOptions;
}
// Custom bundle configuration types
export type TOutputMode = 'bundle' | 'base64ts';
export type TBundler = 'esbuild' | 'rolldown' | 'rspack';
export interface IBundleConfig {
from: string;
to: string;
outputMode?: TOutputMode;
bundler?: TBundler;
production?: boolean;
includeFiles?: string[];
}
export interface ITsbundleConfig {
bundles: IBundleConfig[];
}
export interface IBase64File {
path: string;
contentBase64: string;
}

203
ts/mod_custom/index.ts Normal file
View File

@@ -0,0 +1,203 @@
import * as plugins from './plugins.js';
import * as paths from '../paths.js';
import * as interfaces from '../interfaces/index.js';
import { TsBundle } from '../tsbundle.class.tsbundle.js';
import { HtmlHandler } from '../mod_html/index.js';
import { Base64TsOutput } from '../mod_output/index.js';
const TEMP_DIR = '.nogit/tsbundle-temp';
export class CustomBundleHandler {
private cwd: string;
private config: interfaces.ITsbundleConfig;
constructor(cwd: string = paths.cwd) {
this.cwd = cwd;
}
/**
* Load configuration from npmextra.json
*/
public async loadConfig(): Promise<boolean> {
const npmextraInstance = new plugins.npmextra.Npmextra(this.cwd);
this.config = npmextraInstance.dataFor<interfaces.ITsbundleConfig>('@git.zone/tsbundle', {
bundles: [],
});
if (!this.config.bundles || this.config.bundles.length === 0) {
console.log('No bundle configuration found.');
console.log('Run `tsbundle init` to create one.');
return false;
}
console.log(`Found ${this.config.bundles.length} bundle configuration(s)`);
return true;
}
/**
* Process all configured bundles
*/
public async processAllBundles(): Promise<void> {
for (let i = 0; i < this.config.bundles.length; i++) {
const bundleConfig = this.config.bundles[i];
console.log(`\nProcessing bundle ${i + 1}/${this.config.bundles.length}: ${bundleConfig.from} -> ${bundleConfig.to}`);
await this.processSingleBundle(bundleConfig);
}
}
/**
* Process a single bundle configuration
*/
private async processSingleBundle(bundleConfig: interfaces.IBundleConfig): Promise<void> {
const outputMode = bundleConfig.outputMode || 'bundle';
const bundler = bundleConfig.bundler || 'esbuild';
// Determine temp output path
const tempDir = plugins.path.join(this.cwd, TEMP_DIR);
const tempBundlePath = plugins.path.join(tempDir, `bundle-${Date.now()}.js`);
// Ensure temp directory exists
await plugins.fs.directory(tempDir).create();
// Build the bundle to temp location
const tsbundle = new TsBundle();
await tsbundle.build(
this.cwd,
bundleConfig.from,
tempBundlePath,
{
bundler,
production: bundleConfig.production || false,
}
);
if (outputMode === 'base64ts') {
await this.handleBase64TsOutput(bundleConfig, tempBundlePath);
} else {
await this.handleBundleOutput(bundleConfig, tempBundlePath);
}
// Clean up temp file
const tempFileExists = await plugins.fs.file(tempBundlePath).exists();
if (tempFileExists) {
await plugins.fs.file(tempBundlePath).delete();
}
}
/**
* Handle base64ts output mode
*/
private async handleBase64TsOutput(
bundleConfig: interfaces.IBundleConfig,
tempBundlePath: string
): Promise<void> {
const base64Output = new Base64TsOutput(this.cwd);
// Add the bundle itself
const bundleContent = await plugins.fs.file(tempBundlePath).read();
base64Output.addFile('bundle.js', bundleContent);
// Add included files
if (bundleConfig.includeFiles && bundleConfig.includeFiles.length > 0) {
for (const pattern of bundleConfig.includeFiles) {
await base64Output.addFilesFromGlob(pattern);
}
}
// Write the TypeScript output
await base64Output.writeToFile(bundleConfig.to);
}
/**
* Handle standard bundle output mode
*/
private async handleBundleOutput(
bundleConfig: interfaces.IBundleConfig,
tempBundlePath: string
): Promise<void> {
// Move bundle to final destination
const toPath = plugins.smartpath.transform.toAbsolute(bundleConfig.to, this.cwd) as string;
const toDir = plugins.path.dirname(toPath);
await plugins.fs.directory(toDir).create();
const bundleContent = await plugins.fs.file(tempBundlePath).read();
await plugins.fs.file(toPath).write(bundleContent);
console.log(`Bundle written to: ${bundleConfig.to}`);
// Process included files (copy them)
if (bundleConfig.includeFiles && bundleConfig.includeFiles.length > 0) {
const htmlHandler = new HtmlHandler();
const outputDir = plugins.path.dirname(toPath);
for (const pattern of bundleConfig.includeFiles) {
await this.copyIncludedFiles(pattern, outputDir);
}
}
}
/**
* Copy files matching a pattern to the output directory
*/
private async copyIncludedFiles(pattern: string, outputDir: string): Promise<void> {
const absolutePattern = plugins.smartpath.transform.toAbsolute(pattern, this.cwd) as string;
const patternDir = plugins.path.dirname(absolutePattern);
const patternBase = plugins.path.basename(absolutePattern);
const isGlobPattern = patternBase.includes('*');
if (isGlobPattern) {
const dirPath = patternDir.replace(/\/\*\*$/, '');
const dirExists = await plugins.fs.directory(dirPath).exists();
if (!dirExists) {
console.log(`Directory does not exist: ${dirPath}`);
return;
}
const isRecursive = pattern.includes('**');
let entries;
if (isRecursive) {
entries = await plugins.fs.directory(dirPath).recursive().list();
} else {
entries = await plugins.fs.directory(dirPath).list();
}
const filePattern = patternBase.replace('*', '.*');
const regex = new RegExp(filePattern);
for (const entry of entries) {
if (!entry.isDirectory && regex.test(entry.name)) {
const fullPath = plugins.path.join(dirPath, entry.path);
const relativePath = plugins.path.relative(this.cwd, fullPath);
const destPath = plugins.path.join(outputDir, plugins.path.basename(entry.path));
await plugins.fs.directory(plugins.path.dirname(destPath)).create();
await plugins.fs.file(fullPath).copy(destPath);
console.log(`Copied: ${relativePath} -> ${destPath}`);
}
}
} else {
const fileExists = await plugins.fs.file(absolutePattern).exists();
if (!fileExists) {
console.log(`File does not exist: ${absolutePattern}`);
return;
}
const fileName = plugins.path.basename(absolutePattern);
const destPath = plugins.path.join(outputDir, fileName);
await plugins.fs.file(absolutePattern).copy(destPath);
console.log(`Copied: ${pattern} -> ${destPath}`);
}
}
}
/**
* Run the custom bundle command
*/
export async function runCustomBundles(): Promise<void> {
const handler = new CustomBundleHandler();
const hasConfig = await handler.loadConfig();
if (!hasConfig) {
return;
}
await handler.processAllBundles();
console.log('\nCustom bundle processing complete!');
}

1
ts/mod_custom/plugins.ts Normal file
View File

@@ -0,0 +1 @@
export * from '../plugins.js';

377
ts/mod_init/index.ts Normal file
View File

@@ -0,0 +1,377 @@
import * as plugins from './plugins.js';
import * as paths from '../paths.js';
import * as interfaces from '../interfaces/index.js';
// Preset configurations
const PRESETS: Record<string, { description: string; config: interfaces.IBundleConfig }> = {
element: {
description: 'Web component / element bundle',
config: {
from: './ts_web/index.ts',
to: './dist_bundle/bundle.js',
outputMode: 'bundle',
bundler: 'esbuild',
},
},
website: {
description: 'Full website with HTML and assets',
config: {
from: './ts_web/index.ts',
to: './dist_serve/bundle.js',
outputMode: 'bundle',
bundler: 'esbuild',
includeFiles: ['./html/**/*.html', './assets/**/*'],
},
},
npm: {
description: 'NPM package bundle (from ts/)',
config: {
from: './ts/index.ts',
to: './dist_bundle/bundle.js',
outputMode: 'bundle',
bundler: 'esbuild',
},
},
};
export class InitHandler {
private cwd: string;
private npmextraPath: string;
constructor(cwd: string = paths.cwd) {
this.cwd = cwd;
this.npmextraPath = plugins.path.join(this.cwd, 'npmextra.json');
}
/**
* Load existing npmextra.json or create empty config
*/
private async loadExistingConfig(): Promise<any> {
const fileExists = await plugins.fs.file(this.npmextraPath).exists();
if (fileExists) {
const content = (await plugins.fs.file(this.npmextraPath).encoding('utf8').read()) as string;
try {
return JSON.parse(content);
} catch {
return {};
}
}
return {};
}
/**
* Save config to npmextra.json
*/
private async saveConfig(config: any): Promise<void> {
const content = JSON.stringify(config, null, 2);
await plugins.fs.file(this.npmextraPath).encoding('utf8').write(content);
console.log(`\n✅ Configuration saved to npmextra.json`);
}
/**
* Run the interactive init wizard
*/
public async runWizard(): Promise<void> {
console.log('\n🚀 tsbundle configuration wizard\n');
console.log('This wizard will help you configure bundle settings in npmextra.json.\n');
const npmextraJson = await this.loadExistingConfig();
if (!npmextraJson['@git.zone/tsbundle']) {
npmextraJson['@git.zone/tsbundle'] = { bundles: [] };
}
const existingBundles = npmextraJson['@git.zone/tsbundle'].bundles || [];
if (existingBundles.length > 0) {
console.log(`Found ${existingBundles.length} existing bundle configuration(s):\n`);
existingBundles.forEach((bundle: interfaces.IBundleConfig, i: number) => {
console.log(` ${i + 1}. ${bundle.from}${bundle.to} (${bundle.outputMode || 'bundle'})`);
});
console.log('');
}
let addMore = true;
while (addMore) {
const bundle = await this.configureSingleBundle();
if (bundle) {
npmextraJson['@git.zone/tsbundle'].bundles.push(bundle);
console.log(`\n✅ Bundle configuration added!`);
}
const continueInteract = new plugins.smartinteract.SmartInteract();
continueInteract.addQuestions([
{
type: 'confirm',
name: 'addAnother',
message: 'Would you like to add another bundle configuration?',
default: false,
},
]);
const answers = await continueInteract.runQueue();
addMore = answers.getAnswerFor('addAnother');
}
await this.saveConfig(npmextraJson);
console.log('\n📋 Final configuration:\n');
const bundles = npmextraJson['@git.zone/tsbundle'].bundles;
bundles.forEach((bundle: interfaces.IBundleConfig, i: number) => {
console.log(` Bundle ${i + 1}:`);
console.log(` From: ${bundle.from}`);
console.log(` To: ${bundle.to}`);
console.log(` Mode: ${bundle.outputMode || 'bundle'}`);
console.log(` Bundler: ${bundle.bundler || 'esbuild'}`);
if (bundle.includeFiles && bundle.includeFiles.length > 0) {
console.log(` Include: ${bundle.includeFiles.join(', ')}`);
}
console.log('');
});
console.log('Run `tsbundle` to build your bundles.\n');
}
/**
* Configure a single bundle interactively
*/
private async configureSingleBundle(): Promise<interfaces.IBundleConfig | null> {
// First, ask for preset or custom
const presetInteract = new plugins.smartinteract.SmartInteract();
presetInteract.addQuestions([
{
type: 'list',
name: 'preset',
message: 'Choose a configuration:',
choices: [
{ name: 'element - Web component / element bundle', value: 'element' },
{ name: 'website - Full website with HTML and assets', value: 'website' },
{ name: 'npm - NPM package bundle (from ts/)', value: 'npm' },
{ name: 'custom - Configure manually', value: 'custom' },
],
default: 'element',
},
]);
const presetAnswers = await presetInteract.runQueue();
const selectedPreset = presetAnswers.getAnswerFor('preset') as string;
// If custom, go to full manual configuration
if (selectedPreset === 'custom') {
return this.configureManualBundle();
}
// Show preset config and ask if user wants to use it or customize
const preset = PRESETS[selectedPreset];
console.log(`\n📦 ${preset.description}:`);
console.log(` From: ${preset.config.from}`);
console.log(` To: ${preset.config.to}`);
console.log(` Mode: ${preset.config.outputMode}`);
console.log(` Bundler: ${preset.config.bundler}`);
if (preset.config.includeFiles && preset.config.includeFiles.length > 0) {
console.log(` Include: ${preset.config.includeFiles.join(', ')}`);
}
const confirmInteract = new plugins.smartinteract.SmartInteract();
confirmInteract.addQuestions([
{
type: 'list',
name: 'action',
message: 'Use this configuration?',
choices: [
{ name: 'Yes, use as-is', value: 'use' },
{ name: 'Customize it', value: 'customize' },
],
default: 'use',
},
]);
const confirmAnswers = await confirmInteract.runQueue();
const action = confirmAnswers.getAnswerFor('action') as string;
if (action === 'use') {
// Return the preset config directly
return { ...preset.config };
}
// Customize: pre-fill with preset values
return this.configureManualBundle(preset.config);
}
/**
* Configure a bundle manually with optional pre-filled values
*/
private async configureManualBundle(
prefill?: Partial<interfaces.IBundleConfig>
): Promise<interfaces.IBundleConfig> {
const interact = new plugins.smartinteract.SmartInteract();
// Basic configuration questions
interact.addQuestions([
{
type: 'input',
name: 'from',
message: 'Entry point TypeScript file:',
default: prefill?.from || './ts_web/index.ts',
},
{
type: 'input',
name: 'to',
message: 'Output file path:',
default: prefill?.to || './dist_bundle/bundle.js',
},
{
type: 'list',
name: 'outputMode',
message: 'Output mode:',
choices: [
{ name: 'bundle - Standard JavaScript bundle file', value: 'bundle' },
{
name: 'base64ts - TypeScript file with base64-encoded content (for Deno compile)',
value: 'base64ts',
},
],
default: prefill?.outputMode || 'bundle',
},
{
type: 'list',
name: 'bundler',
message: 'Bundler to use:',
choices: [
{ name: 'esbuild (fastest, recommended)', value: 'esbuild' },
{ name: 'rolldown (Rust-based, Rollup compatible)', value: 'rolldown' },
{ name: 'rspack (Webpack compatible)', value: 'rspack' },
],
default: prefill?.bundler || 'esbuild',
},
{
type: 'confirm',
name: 'production',
message: 'Enable production mode (minification)?',
default: prefill?.production || false,
},
{
type: 'confirm',
name: 'hasIncludeFiles',
message: 'Include additional files (HTML, assets)?',
default: prefill?.includeFiles && prefill.includeFiles.length > 0 ? true : false,
},
]);
const answers = await interact.runQueue();
const bundle: interfaces.IBundleConfig = {
from: answers.getAnswerFor('from'),
to: answers.getAnswerFor('to'),
outputMode: answers.getAnswerFor('outputMode') as interfaces.TOutputMode,
bundler: answers.getAnswerFor('bundler') as interfaces.TBundler,
production: answers.getAnswerFor('production'),
};
// Update default output path based on mode
if (bundle.outputMode === 'base64ts' && bundle.to === './dist_bundle/bundle.js') {
const suggestInteract = new plugins.smartinteract.SmartInteract();
suggestInteract.addQuestions([
{
type: 'input',
name: 'to',
message: 'For base64ts mode, suggest a .ts output path:',
default: './ts/embedded-bundle.ts',
},
]);
const suggestAnswers = await suggestInteract.runQueue();
bundle.to = suggestAnswers.getAnswerFor('to');
}
// Handle include files
if (answers.getAnswerFor('hasIncludeFiles')) {
bundle.includeFiles = await this.configureIncludeFiles(prefill?.includeFiles);
}
return bundle;
}
/**
* Configure files to include
*/
private async configureIncludeFiles(prefill?: string[]): Promise<string[]> {
const includeFiles: string[] = [];
let addMore = true;
// If we have prefilled values, show them first
if (prefill && prefill.length > 0) {
console.log('\nPre-configured include patterns:');
prefill.forEach((p) => console.log(` - ${p}`));
const keepInteract = new plugins.smartinteract.SmartInteract();
keepInteract.addQuestions([
{
type: 'confirm',
name: 'keepPrefill',
message: 'Keep these patterns?',
default: true,
},
]);
const keepAnswers = await keepInteract.runQueue();
if (keepAnswers.getAnswerFor('keepPrefill')) {
includeFiles.push(...prefill);
}
}
console.log('\nAdd files or glob patterns to include (e.g., ./html/index.html, ./assets/**/*):\n');
// Ask if user wants to add more patterns
const addInteract = new plugins.smartinteract.SmartInteract();
addInteract.addQuestions([
{
type: 'confirm',
name: 'addPatterns',
message: includeFiles.length > 0 ? 'Add more patterns?' : 'Add include patterns?',
default: includeFiles.length === 0,
},
]);
const addAnswers = await addInteract.runQueue();
addMore = addAnswers.getAnswerFor('addPatterns');
while (addMore) {
const fileInteract = new plugins.smartinteract.SmartInteract();
fileInteract.addQuestions([
{
type: 'input',
name: 'pattern',
message: 'File or glob pattern:',
default: includeFiles.length === 0 ? './html/index.html' : '',
},
]);
const fileAnswers = await fileInteract.runQueue();
const pattern = fileAnswers.getAnswerFor('pattern');
if (pattern && pattern.trim()) {
includeFiles.push(pattern.trim());
console.log(` Added: ${pattern}`);
}
const continueInteract = new plugins.smartinteract.SmartInteract();
continueInteract.addQuestions([
{
type: 'confirm',
name: 'addMore',
message: 'Add another file/pattern?',
default: false,
},
]);
const continueAnswers = await continueInteract.runQueue();
addMore = continueAnswers.getAnswerFor('addMore');
}
return includeFiles;
}
}
/**
* Run the init command
*/
export async function runInit(): Promise<void> {
const handler = new InitHandler();
await handler.runWizard();
}

5
ts/mod_init/plugins.ts Normal file
View File

@@ -0,0 +1,5 @@
export * from '../plugins.js';
import * as smartinteract from '@push.rocks/smartinteract';
export { smartinteract };

136
ts/mod_output/index.ts Normal file
View File

@@ -0,0 +1,136 @@
import * as plugins from './plugins.js';
import * as paths from '../paths.js';
import * as interfaces from '../interfaces/index.js';
export class Base64TsOutput {
private files: interfaces.IBase64File[] = [];
private cwd: string;
constructor(cwd: string = paths.cwd) {
this.cwd = cwd;
}
/**
* Add a file with its content to the output
*/
public addFile(filePath: string, content: Buffer | string): void {
const contentBuffer = typeof content === 'string' ? Buffer.from(content, 'utf-8') : content;
const contentBase64 = contentBuffer.toString('base64');
this.files.push({
path: filePath,
contentBase64,
});
}
/**
* Add files matching a glob pattern
*/
public async addFilesFromGlob(pattern: string): Promise<void> {
const absolutePattern = plugins.smartpath.transform.toAbsolute(pattern, this.cwd) as string;
const patternDir = plugins.path.dirname(absolutePattern);
const patternBase = plugins.path.basename(absolutePattern);
// Check if it's a directory pattern or file pattern
const isGlobPattern = patternBase.includes('*');
if (isGlobPattern) {
// Handle glob patterns
const dirPath = patternDir.replace(/\/\*\*$/, '');
const dirExists = await plugins.fs.directory(dirPath).exists();
if (!dirExists) {
console.log(`Directory does not exist: ${dirPath}`);
return;
}
const isRecursive = pattern.includes('**');
let entries;
if (isRecursive) {
entries = await plugins.fs.directory(dirPath).recursive().list();
} else {
entries = await plugins.fs.directory(dirPath).list();
}
// Filter by pattern if needed
const filePattern = patternBase.replace('*', '.*');
const regex = new RegExp(filePattern);
for (const entry of entries) {
if (!entry.isDirectory && regex.test(entry.name)) {
const fullPath = plugins.path.join(dirPath, entry.path);
const relativePath = plugins.path.relative(this.cwd, fullPath);
const content = await plugins.fs.file(fullPath).read();
this.addFile(relativePath, content);
}
}
} else {
// Handle single file path
const fileExists = await plugins.fs.file(absolutePattern).exists();
if (!fileExists) {
console.log(`File does not exist: ${absolutePattern}`);
return;
}
const relativePath = plugins.path.relative(this.cwd, absolutePattern);
const content = await plugins.fs.file(absolutePattern).read();
this.addFile(relativePath, content);
}
}
/**
* Generate TypeScript file content
*/
public generateTypeScript(): string {
const MAX_LINE_LENGTH = 200;
const formatBase64 = (base64: string): string => {
if (base64.length <= MAX_LINE_LENGTH) {
return `"${base64}"`;
}
const chunks: string[] = [];
for (let i = 0; i < base64.length; i += MAX_LINE_LENGTH) {
chunks.push(base64.slice(i, i + MAX_LINE_LENGTH));
}
return `"" +\n "${chunks.join('" +\n "')}"`;
};
const filesFormatted = this.files.map(file => {
return ` {
"path": "${file.path}",
"contentBase64": ${formatBase64(file.contentBase64)}
}`;
}).join(',\n');
return `// Auto-generated by tsbundle - do not edit
export const files: { path: string; contentBase64: string }[] = [
${filesFormatted}
];
`;
}
/**
* Write the TypeScript file to disk
*/
public async writeToFile(outputPath: string): Promise<void> {
const absolutePath = plugins.smartpath.transform.toAbsolute(outputPath, this.cwd) as string;
const outputDir = plugins.path.dirname(absolutePath);
await plugins.fs.directory(outputDir).create();
const content = this.generateTypeScript();
await plugins.fs.file(absolutePath).encoding('utf8').write(content);
console.log(`Generated base64ts output: ${outputPath}`);
}
/**
* Get all collected files
*/
public getFiles(): interfaces.IBase64File[] {
return this.files;
}
/**
* Clear all collected files
*/
public clear(): void {
this.files = [];
}
}

1
ts/mod_output/plugins.ts Normal file
View File

@@ -0,0 +1 @@
export * from '../plugins.js';

View File

@@ -4,8 +4,10 @@ import * as path from 'path';
export { path };
// pushrocks scope
import * as npmextra from '@push.rocks/npmextra';
import * as smartcli from '@push.rocks/smartcli';
import * as smartfs from '@push.rocks/smartfs';
import * as smartinteract from '@push.rocks/smartinteract';
import * as smartlog from '@push.rocks/smartlog';
import * as smartlogDestinationLocal from '@push.rocks/smartlog-destination-local';
import * as smartpath from '@push.rocks/smartpath';
@@ -13,8 +15,10 @@ import * as smartpromise from '@push.rocks/smartpromise';
import * as smartspawn from '@push.rocks/smartspawn';
export {
npmextra,
smartcli,
smartfs,
smartinteract,
smartlog,
smartlogDestinationLocal,
smartpath,

View File

@@ -1,70 +1,23 @@
import * as plugins from './plugins.js';
import { TsBundle } from './tsbundle.class.tsbundle.js';
import { HtmlHandler } from './mod_html/index.js';
import { logger } from './tsbundle.logging.js';
import { AssetsHandler } from './mod_assets/index.js';
import { runCustomBundles } from './mod_custom/index.js';
import { runInit } from './mod_init/index.js';
export const runCli = async () => {
const tsBundleCli = new plugins.smartcli.Smartcli();
// Default command: run custom bundles from npmextra.json
tsBundleCli.standardCommand().subscribe(async (argvArg) => {
const tsbundle = new TsBundle();
await tsbundle.build(process.cwd(), argvArg.from, argvArg.to, argvArg);
return;
await runCustomBundles();
});
tsBundleCli.addCommand('element').subscribe(async (argvArg) => {
const tsbundle = new TsBundle();
await tsbundle.build(
process.cwd(),
'./ts_web/index.ts',
'./dist_bundle/bundle.js',
argvArg,
);
// Explicit custom command (same as default)
tsBundleCli.addCommand('custom').subscribe(async (argvArg) => {
await runCustomBundles();
});
tsBundleCli.addCommand('npm').subscribe(async (argvArg) => {
const tsbundle = new TsBundle();
const htmlHandler = new HtmlHandler();
await tsbundle.build(
process.cwd(),
'./ts/index.ts',
'./dist_bundle/bundle.js',
argvArg,
);
});
tsBundleCli.addCommand('website').subscribe(async (argvArg) => {
const tsbundle = new TsBundle();
// lets deal with the html
const htmlHandler = new HtmlHandler();
await tsbundle.build(
process.cwd(),
'./ts_web/index.ts',
'./dist_serve/bundle.js',
argvArg,
);
const htmlDirPath = plugins.path.join(process.cwd(), './html');
let htmlFiles: string[] = [];
const htmlDirExists = await plugins.fs.directory(htmlDirPath).exists();
if (htmlDirExists) {
const entries = await plugins.fs
.directory(htmlDirPath)
.filter(/\.html$/)
.list();
htmlFiles = entries.map((entry) => plugins.path.basename(entry.path));
}
for (const htmlFile of htmlFiles) {
await htmlHandler.processHtml({
from: `./html/${htmlFile}`,
to: `./dist_serve/${htmlFile}`,
minify: true,
});
}
// lets deal with the assets
const assetsHandler = new AssetsHandler();
await assetsHandler.processAssets();
// Interactive init wizard
tsBundleCli.addCommand('init').subscribe(async (argvArg) => {
await runInit();
});
tsBundleCli.startParse();