@darkobits/ts
Version:
Vite-based toolchain for Node projects.
49 lines (48 loc) • 1.17 kB
JavaScript
import chalk from "chalk";
import merge from "deepmerge";
import ms from "ms";
import { replaceTscAliasPaths } from "tsc-alias";
import log from "./log.js";
const prefix = chalk.dim.cyan("tsc-alias");
const defaultOptions = {
debug: log.level >= 4,
output: {
verbose: true,
clear: () => {
},
debug: (message) => {
log.debug(prefix, message);
},
info: (message) => {
log.debug(prefix, message);
},
error(message) {
log.error(prefix, message);
this.error(message, true);
},
assert(claim, message) {
void (claim || this.error(message, true));
}
}
};
function tscAliasPlugin(userOptions = {}) {
const options = merge(defaultOptions, userOptions);
return {
name: "ts:tsc-alias-plugin",
enforce: "post",
async closeBundle() {
const startTime = Date.now();
try {
await replaceTscAliasPaths(options);
const time = Date.now() - startTime;
log.debug(prefix, chalk.gray(`Done in ${ms(time)}.`));
} catch (error) {
this.error(error);
}
}
};
}
export {
tscAliasPlugin as default
};
//# sourceMappingURL=tsc-alias-plugin.js.map