Skip to content

Commit

Permalink
feat: add Makefile to streamline build process
Browse files Browse the repository at this point in the history
This commit introduces a new Makefile to the project, facilitating a more streamlined build process for developers. The Makefile defines paths for library outputs (lib, types, esm, cjs) and automates the build workflow with tasks for cleaning and building types, ESM, and CJS modules. This enhancement simplifies the build steps, making it easier for developers to generate the necessary files for distribution. By segregating the build process into distinct tasks (`build@types`, `build@esm`, `build@cjs`), it allows for finer control over the compilation process and supports a modular project structure. The addition of `clean_lib` ensures that old builds are removed before a new build starts, preventing potential conflicts or outdated artifacts from persisting. The explicit setting of module types in the generated package.json for ESM and CJS outputs clarifies the module format, aiding in correct module resolution by Node.js and other tools. This Makefile is expected to significantly improve the build efficiency and clarity for developers working on the project.
  • Loading branch information
JonDotsoy committed Mar 21, 2024
1 parent b3ee057 commit 187b7c1
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions Makefile
@@ -0,0 +1,26 @@
lib_path = ./lib
types_path = $(lib_path)/types
esm_path = $(lib_path)/esm
cjs_path = $(lib_path)/cjs

all:
@exit 0

build: clean_lib build@esm build@cjs build@types

clean_lib:
rm -rf "$(lib_path)/"

build@types:
rm -rf "$(types_path)/"
npx tsc --project tsconfig.types.json --outDir "$(types_path)/"

build@esm:
rm -rf "$(esm_path)/"
npx tsc --project tsconfig.esm.json --outDir "$(esm_path)/"
echo '{"type": "module"}' > "$(esm_path)/package.json"

build@cjs:
rm -rf "$(cjs_path)/"
npx tsc --project tsconfig.cjs.json --outDir "$(cjs_path)/"
echo '{"type": "commonjs"}' > "$(cjs_path)/package.json"

0 comments on commit 187b7c1

Please sign in to comment.