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"
|
"tsbundle": "cli.js"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@git.zone/tsbuild": "^2.1.70",
|
"@git.zone/tsbuild": "^2.1.85",
|
||||||
"@git.zone/tsrun": "^1.2.46",
|
"@git.zone/tsrun": "^1.2.49",
|
||||||
"@git.zone/tstest": "^1.0.84",
|
"@git.zone/tstest": "^1.0.90",
|
||||||
"@push.rocks/tapbundle": "^5.0.15",
|
"@push.rocks/tapbundle": "^5.3.0",
|
||||||
"@types/node": "^20.10.7"
|
"@types/node": "^22.8.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@push.rocks/early": "^4.0.4",
|
"@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/smartdelay": "^3.0.5",
|
||||||
"@push.rocks/smartfile": "^11.0.4",
|
"@push.rocks/smartfile": "^11.0.21",
|
||||||
"@push.rocks/smartlog": "^3.0.3",
|
"@push.rocks/smartlog": "^3.0.7",
|
||||||
"@push.rocks/smartlog-destination-local": "^9.0.0",
|
"@push.rocks/smartlog-destination-local": "^9.0.2",
|
||||||
"@push.rocks/smartpath": "^5.0.11",
|
"@push.rocks/smartpath": "^5.0.18",
|
||||||
"@push.rocks/smartpromise": "^4.0.2",
|
"@push.rocks/smartpromise": "^4.0.4",
|
||||||
"@push.rocks/smartspawn": "^3.0.2",
|
"@push.rocks/smartspawn": "^3.0.3",
|
||||||
"@types/html-minifier": "^4.0.5",
|
"@types/html-minifier": "^4.0.5",
|
||||||
"esbuild": "^0.19.11",
|
"esbuild": "^0.24.0",
|
||||||
"html-minifier": "^4.0.0",
|
"html-minifier": "^4.0.0",
|
||||||
"typescript": "5.3.3"
|
"typescript": "5.6.3"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"ts/**/*",
|
"ts/**/*",
|
||||||
|
4520
pnpm-lock.yaml
4520
pnpm-lock.yaml
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 = {
|
export const commitinfo = {
|
||||||
name: '@git.zone/tsbundle',
|
name: '@git.zone/tsbundle',
|
||||||
version: '2.0.15',
|
version: '2.1.0',
|
||||||
description: 'a bundler using rollup for painless bundling of web projects'
|
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';
|
import { logger } from '../tsbundle.logging.js';
|
||||||
|
|
||||||
export class TsBundleProcess {
|
export class TsBundleProcess {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
// Nothing here
|
// 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
|
* creates a bundle for the test enviroment
|
||||||
*/
|
*/
|
||||||
public async buildTest(
|
public async buildTest(fromArg: string, toArg: string, argvArg: any) {
|
||||||
fromArg: string,
|
|
||||||
toArg: string,
|
|
||||||
argvArg: any
|
|
||||||
) {
|
|
||||||
// create a bundle
|
// create a bundle
|
||||||
const esbuild = await plugins.esbuild.build({
|
const esbuild = await plugins.esbuild.build({
|
||||||
entryPoints: [fromArg],
|
entryPoints: [fromArg],
|
||||||
@ -27,22 +40,19 @@ export class TsBundleProcess {
|
|||||||
entryNames: plugins.path.parse(toArg).name,
|
entryNames: plugins.path.parse(toArg).name,
|
||||||
outdir: plugins.path.parse(toArg).dir,
|
outdir: plugins.path.parse(toArg).dir,
|
||||||
// splitting: true,
|
// splitting: true,
|
||||||
tsconfig: paths.tsconfigPath
|
tsconfig: paths.tsconfigPath,
|
||||||
|
alias: await this.getAliases(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* creates a bundle for the production environment
|
* creates a bundle for the production environment
|
||||||
*/
|
*/
|
||||||
public async buildProduction(
|
public async buildProduction(fromArg: string, toArg: string, argvArg: any) {
|
||||||
fromArg: string,
|
|
||||||
toArg: string,
|
|
||||||
argvArg: any
|
|
||||||
) {
|
|
||||||
// create a bundle
|
// create a bundle
|
||||||
console.log('esbuild specific:');
|
console.log('esbuild specific:');
|
||||||
console.log(`from: ${fromArg}`);
|
console.log(`from: ${fromArg}`);
|
||||||
console.log((`to: ${toArg}`));
|
console.log(`to: ${toArg}`);
|
||||||
const esbuild = await plugins.esbuild.build({
|
const esbuild = await plugins.esbuild.build({
|
||||||
entryPoints: [fromArg],
|
entryPoints: [fromArg],
|
||||||
bundle: true,
|
bundle: true,
|
||||||
@ -55,27 +65,30 @@ export class TsBundleProcess {
|
|||||||
tsconfig: paths.tsconfigPath,
|
tsconfig: paths.tsconfigPath,
|
||||||
// splitting: true,
|
// splitting: true,
|
||||||
chunkNames: 'chunks/[name]-[hash]',
|
chunkNames: 'chunks/[name]-[hash]',
|
||||||
|
alias: await this.getAliases(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const run = async () => {
|
const run = async () => {
|
||||||
console.log('running spawned compilation process');
|
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('=======> ESBUILD');
|
||||||
console.log(transportOptions);
|
console.log(transportOptions);
|
||||||
process.chdir(transportOptions.cwd);
|
process.chdir(transportOptions.cwd);
|
||||||
console.log(`switched to ${process.cwd()}`);
|
console.log(`switched to ${process.cwd()}`);
|
||||||
const tsbundleProcessInstance = new TsBundleProcess();
|
const tsbundleProcessInstance = new TsBundleProcess();
|
||||||
if (transportOptions.mode === 'test') {
|
if (transportOptions.mode === 'test') {
|
||||||
console.log('building for test:')
|
console.log('building for test:');
|
||||||
tsbundleProcessInstance.buildTest(
|
tsbundleProcessInstance.buildTest(
|
||||||
plugins.smartpath.transform.makeAbsolute(transportOptions.from, process.cwd()),
|
plugins.smartpath.transform.makeAbsolute(transportOptions.from, process.cwd()),
|
||||||
plugins.smartpath.transform.makeAbsolute(transportOptions.to, process.cwd()),
|
plugins.smartpath.transform.makeAbsolute(transportOptions.to, process.cwd()),
|
||||||
transportOptions.argv
|
transportOptions.argv
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
console.log('building for production:')
|
console.log('building for production:');
|
||||||
tsbundleProcessInstance.buildProduction(
|
tsbundleProcessInstance.buildProduction(
|
||||||
plugins.smartpath.transform.makeAbsolute(transportOptions.from, process.cwd()),
|
plugins.smartpath.transform.makeAbsolute(transportOptions.from, process.cwd()),
|
||||||
plugins.smartpath.transform.makeAbsolute(transportOptions.to, process.cwd()),
|
plugins.smartpath.transform.makeAbsolute(transportOptions.to, process.cwd()),
|
||||||
|
Loading…
Reference in New Issue
Block a user