Skip to content

Commit

Permalink
Merge pull request #85 from ublib/declaration-map
Browse files Browse the repository at this point in the history
Declaration map
  • Loading branch information
ubugeeei authored Mar 25, 2024
2 parents 5491086 + 9595b6d commit ed49cb5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 30 deletions.
55 changes: 25 additions & 30 deletions build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,33 +42,30 @@ export const clearCliSync = () => {

const PACKAGES = ["tecack", "frontend", "backend", "dataset", "shared"];

export const buildTecack = () =>
PACKAGES.map(pkg => {
const res = esbuild.build({
entryPoints: [path.resolve(`packages/${pkg}/src/index`)],
bundle: true,
minify: true,
target: "es2018",
outdir: `packages/${pkg}/dist`,
format: "esm",
plugins: [
{
name: "TypeScriptDeclarationsPlugin",
setup(build) {
build.onEnd(() => {
bundle({
name: pkg,
main: `temp/packages/${pkg}/src/index.d.ts`,
out: path.resolve(`packages/${pkg}/dist/index.d.ts`),
});
});
},
},
],
});
res.then(() => finishedBuild(`packages/${pkg}/dist`));
return res;
});
export const buildTecack = async () => {
execSync("tsc -p tsconfig.build.json");
const ps = await Promise.all(
PACKAGES.map(pkg =>
esbuild
.build({
entryPoints: [path.resolve(`packages/${pkg}/src/index`)],
bundle: true,
target: "es2018",
outdir: `packages/${pkg}/dist`,
format: "esm",
sourcemap: true,
})
.then(ps => {
execSync(`cp -r temp/packages/${pkg}/src/* packages/${pkg}/dist/`);
execSync(`cp -r packages/${pkg}/src/* packages/${pkg}/dist/`);
finishedBuild(`packages/${pkg}/dist`);
return ps;
}),
),
);
execSync(`rm -rf temp`);
return ps;
};

export const clearTecackSync = () => {
PACKAGES.map(pkg => `packages/${pkg}/dist`).forEach(dir => rimraf.sync(dir));
Expand All @@ -79,9 +76,7 @@ await (async function main() {
await Promise.allSettled([clearCliSync(), clearTecackSync()]);
console.log(`${green("✔︎")} finished clearing dist`);
console.log("building tecack...");
execSync("tsc -p tsconfig.build.json");
const buildingTecack = buildTecack();
const buildingCli = buildCli();
await Promise.all([...buildingTecack, buildingCli]);
execSync("rm -rf temp");
await Promise.all([...(await buildingTecack), buildingCli]);
})();
3 changes: 3 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "node",
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"outDir": "temp",
"strict": true,
"esModuleInterop": true,
Expand Down

0 comments on commit ed49cb5

Please sign in to comment.