feat(mod_esbuild): Add alias support to esbuild bundling process
This commit is contained in:
parent
32b0781d72
commit
84854b0b40
24
changelog.md
Normal file
24
changelog.md
Normal file
@ -0,0 +1,24 @@
|
||||
# Changelog
|
||||
|
||||
## 2024-10-27 - 2.1.0 - feat(mod_esbuild)
|
||||
Add alias support to esbuild bundling process
|
||||
|
||||
- Updated dependencies in package.json to latest versions.
|
||||
- Improved build process by adding alias resolution based on tsconfig.json settings in esbuild.
|
||||
|
||||
## 2022-05-04 - 2.0.0-2.0.1 - Breaking and Fix Changes
|
||||
Released version 2.0.0 with breaking changes and subsequent fixes.
|
||||
|
||||
- BREAKING CHANGE(core): Removed parcel and rollup
|
||||
- fix(core): Addressed initial issues in new major version
|
||||
|
||||
## 2023-10-03 - 2.0.10 - Fix Updates
|
||||
Ongoing updates and improvements.
|
||||
|
||||
- fix(core): General updates and enhancements
|
||||
|
||||
## 2024-01-10 - 2.0.11-2.0.15 - Minor Fixes
|
||||
Cumulative fixes and updates from recent releases.
|
||||
|
||||
- fix(core): Continuous improvement cycle across versions
|
||||
|
28
package.json
28
package.json
@ -16,26 +16,26 @@
|
||||
"tsbundle": "cli.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@git.zone/tsbuild": "^2.1.70",
|
||||
"@git.zone/tsrun": "^1.2.46",
|
||||
"@git.zone/tstest": "^1.0.84",
|
||||
"@push.rocks/tapbundle": "^5.0.15",
|
||||
"@types/node": "^20.10.7"
|
||||
"@git.zone/tsbuild": "^2.1.85",
|
||||
"@git.zone/tsrun": "^1.2.49",
|
||||
"@git.zone/tstest": "^1.0.90",
|
||||
"@push.rocks/tapbundle": "^5.3.0",
|
||||
"@types/node": "^22.8.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@push.rocks/early": "^4.0.4",
|
||||
"@push.rocks/smartcli": "^4.0.8",
|
||||
"@push.rocks/smartcli": "^4.0.11",
|
||||
"@push.rocks/smartdelay": "^3.0.5",
|
||||
"@push.rocks/smartfile": "^11.0.4",
|
||||
"@push.rocks/smartlog": "^3.0.3",
|
||||
"@push.rocks/smartlog-destination-local": "^9.0.0",
|
||||
"@push.rocks/smartpath": "^5.0.11",
|
||||
"@push.rocks/smartpromise": "^4.0.2",
|
||||
"@push.rocks/smartspawn": "^3.0.2",
|
||||
"@push.rocks/smartfile": "^11.0.21",
|
||||
"@push.rocks/smartlog": "^3.0.7",
|
||||
"@push.rocks/smartlog-destination-local": "^9.0.2",
|
||||
"@push.rocks/smartpath": "^5.0.18",
|
||||
"@push.rocks/smartpromise": "^4.0.4",
|
||||
"@push.rocks/smartspawn": "^3.0.3",
|
||||
"@types/html-minifier": "^4.0.5",
|
||||
"esbuild": "^0.19.11",
|
||||
"esbuild": "^0.24.0",
|
||||
"html-minifier": "^4.0.0",
|
||||
"typescript": "5.3.3"
|
||||
"typescript": "5.6.3"
|
||||
},
|
||||
"files": [
|
||||
"ts/**/*",
|
||||
|
4520
pnpm-lock.yaml
generated
4520
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
0
readme.hints.md
Normal file
0
readme.hints.md
Normal file
@ -1,8 +1,8 @@
|
||||
/**
|
||||
* autocreated commitinfo by @pushrocks/commitinfo
|
||||
* autocreated commitinfo by @push.rocks/commitinfo
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@git.zone/tsbundle',
|
||||
version: '2.0.15',
|
||||
version: '2.1.0',
|
||||
description: 'a bundler using rollup for painless bundling of web projects'
|
||||
}
|
||||
|
@ -4,19 +4,32 @@ import * as interfaces from '../interfaces/index.js';
|
||||
import { logger } from '../tsbundle.logging.js';
|
||||
|
||||
export class TsBundleProcess {
|
||||
|
||||
constructor() {
|
||||
// Nothing here
|
||||
}
|
||||
|
||||
public async getAliases() {
|
||||
try {
|
||||
const aliasObject: Record<string, string> = {};
|
||||
const localTsConfig = plugins.smartfile.fs.toObjectSync(
|
||||
plugins.path.join(paths.cwd, 'tsconfig.json')
|
||||
);
|
||||
if (localTsConfig.compilerOptions && localTsConfig.compilerOptions.paths) {
|
||||
for (const alias of Object.keys(localTsConfig.compilerOptions.paths)) {
|
||||
const aliasPath = localTsConfig.compilerOptions.paths[alias][0];
|
||||
aliasObject[alias] = aliasPath;
|
||||
}
|
||||
}
|
||||
return aliasObject;
|
||||
} catch (error) {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* creates a bundle for the test enviroment
|
||||
*/
|
||||
public async buildTest(
|
||||
fromArg: string,
|
||||
toArg: string,
|
||||
argvArg: any
|
||||
) {
|
||||
public async buildTest(fromArg: string, toArg: string, argvArg: any) {
|
||||
// create a bundle
|
||||
const esbuild = await plugins.esbuild.build({
|
||||
entryPoints: [fromArg],
|
||||
@ -27,22 +40,19 @@ export class TsBundleProcess {
|
||||
entryNames: plugins.path.parse(toArg).name,
|
||||
outdir: plugins.path.parse(toArg).dir,
|
||||
// splitting: true,
|
||||
tsconfig: paths.tsconfigPath
|
||||
tsconfig: paths.tsconfigPath,
|
||||
alias: await this.getAliases(),
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* creates a bundle for the production environment
|
||||
*/
|
||||
public async buildProduction(
|
||||
fromArg: string,
|
||||
toArg: string,
|
||||
argvArg: any
|
||||
) {
|
||||
public async buildProduction(fromArg: string, toArg: string, argvArg: any) {
|
||||
// create a bundle
|
||||
console.log('esbuild specific:');
|
||||
console.log(`from: ${fromArg}`);
|
||||
console.log((`to: ${toArg}`));
|
||||
console.log(`to: ${toArg}`);
|
||||
const esbuild = await plugins.esbuild.build({
|
||||
entryPoints: [fromArg],
|
||||
bundle: true,
|
||||
@ -55,27 +65,30 @@ export class TsBundleProcess {
|
||||
tsconfig: paths.tsconfigPath,
|
||||
// splitting: true,
|
||||
chunkNames: 'chunks/[name]-[hash]',
|
||||
alias: await this.getAliases(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const run = async () => {
|
||||
console.log('running spawned compilation process');
|
||||
const transportOptions: interfaces.IEnvTransportOptions = JSON.parse(process.env.transportOptions);
|
||||
const transportOptions: interfaces.IEnvTransportOptions = JSON.parse(
|
||||
process.env.transportOptions
|
||||
);
|
||||
console.log('=======> 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:')
|
||||
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:')
|
||||
console.log('building for production:');
|
||||
tsbundleProcessInstance.buildProduction(
|
||||
plugins.smartpath.transform.makeAbsolute(transportOptions.from, process.cwd()),
|
||||
plugins.smartpath.transform.makeAbsolute(transportOptions.to, process.cwd()),
|
||||
|
Loading…
Reference in New Issue
Block a user