{"id":19418968,"url":"https://github.com/playform/build","last_synced_at":"2026-02-12T02:29:32.178Z","repository":{"id":186867726,"uuid":"675904885","full_name":"PlayForm/Build","owner":"PlayForm","description":"🌀 Build —","archived":false,"fork":false,"pushed_at":"2024-11-07T02:06:39.000Z","size":14857,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"Current","last_synced_at":"2024-11-07T03:18:55.702Z","etag":null,"topics":["build","esbuild","javascript","playform","typescript"],"latest_commit_sha":null,"homepage":"https://NPMJS.Org/@playform/build","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PlayForm.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"open_collective":"playform-cloud-collective"}},"created_at":"2023-08-08T02:18:27.000Z","updated_at":"2024-11-07T02:06:43.000Z","dependencies_parsed_at":"2023-09-22T20:20:26.032Z","dependency_job_id":"58ef8998-0d87-4c64-871d-b3a3b1ec3406","html_url":"https://github.com/PlayForm/Build","commit_stats":{"total_commits":941,"total_committers":6,"mean_commits":"156.83333333333334","dds":0.4144527098831031,"last_synced_commit":"2a0176d458f2f3b455544ad99c3f2098e9c511ca"},"previous_names":["baxast/baxast","nikolarhristov/baxast","nikolarhristov/javascriptbuild","nikolarhristov/build","nikolarhristov/typescriptbuild","nikolarhristov/tsbundle","nikolarhristov/syclone","nikolarhristov/typescriptesbuild","playform/typescriptesbuild"],"tags_count":102,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PlayForm%2FBuild","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PlayForm%2FBuild/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PlayForm%2FBuild/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PlayForm%2FBuild/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PlayForm","download_url":"https://codeload.github.com/PlayForm/Build/tar.gz/refs/heads/Current","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223954709,"owners_count":17231189,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["build","esbuild","javascript","playform","typescript"],"created_at":"2024-11-10T13:15:44.836Z","updated_at":"2026-01-06T23:21:36.809Z","avatar_url":"https://github.com/PlayForm.png","language":"TypeScript","readme":"# [Build] 🌀\n\n`Build` is a powerful tool that compiles all your `TypeScript` files into\n`JavaScript`, leveraging the speed of `ESBuild` and the type-checking\ncapabilities of the `TypeScript` compiler.\n\n## Feature 📦\n\n- Fast compilation using `ESBuild`\n- `TypeScript` support with type-checking (`tsc` \u0026 `tsc-alias`)\n- Watch mode for development (`--Watch`)\n- Customizable `ESBuild` configuration via object or function (`--ESBuild`)\n- Supports both `CommonJS` and `ES` modules\n- Glob pattern support for input files\n- Exclusion patterns for input files\n\n## Installation 🚀\n\nInstall the package as a development dependency:\n\n```sh\n# Using npm\nnpm install -D -E @playform/build\n\n# Or using yarn\n# yarn add -D -E @playform/build\n\n# Or using pnpm\n# pnpm add -D -E @playform/build\n```\n\n## Usage 🛠️\n\n### Command Line\n\nRun the build tool from the command line, providing file patterns:\n\n```sh\nnpx @playform/build 'Source/**/*.ts' 'OtherSource/**/*.mts'\n```\n\n### CLI Options\n\n```\nUsage: Build [options] \u003cFile...\u003e\n\nArguments:\n  File                      One or more glob patterns matching files to build 📝\n\nOptions:\n  -V, --version             Output the version number\n  -E, --ESBuild \u003cFile\u003e      Path to a custom ESBuild configuration file (exports an object or a function) 📜\n  -T, --TypeScript \u003cFile\u003e   Path to a custom TypeScript configuration file (default: \"tsconfig.json\") 📜\n  -W, --Watch               Enable watch mode: rebuild on file changes 👁️\n  -h, --help                Display help information\n```\n\n### NPM Scripts\n\nAdd `Build` to your `package.json` scripts:\n\n```json\n{\n\t\"scripts\": {\n\t\t\"Build\": \"Build 'Source/**/*.ts'\",\n\t\t\"Run\": \"Build 'Source/**/*.ts' --Watch\",\n\t\t\"prepublishOnly\": \"Build 'Source/**/*.ts'\"\n\t}\n}\n```\n\n## Configuration ⚙️\n\n### ESBuild Configuration (`--ESBuild`) 📜\n\nYou can provide a custom configuration file to modify the default ESBuild\noptions used by `@playform/build`. This file (e.g., `ESBuild.js` or\n`esbuild.config.ts`) should use `export default` with **either** a configuration\nobject **or** a function.\n\n**1. Exporting an Object:**\n\nProvide an object with ESBuild options. These will be merged with the base\nconfiguration.\n\n```javascript\n// ESBuild.js\n/** @type {import('esbuild').BuildOptions} */\nconst config = {\n\tminify: true,\n\tsourcemap: \"external\",\n\tplatform: \"node\",\n\t// Add other esbuild options here\n};\n\nexport default config;\n```\n\n**2. Exporting a Function:**\n\nProvide a function that receives the _current_ ESBuild configuration object\n(`BuildOptions` from `esbuild`) as its argument. You can modify this object\ndirectly **or** return a new (partial) object containing options to be merged.\nThis allows for dynamic configuration, such as filtering entry points.\n\n```javascript\n// ESBuild.js\n/**\n * @param {import('esbuild').BuildOptions} Current The configuration object before this function runs.\n * @returns {import('esbuild').BuildOptions | void} Return changes to merge, or modify Current directly.\n */\nexport default (Current) =\u003e {\n\tconsole.log(\"Applying custom ESBuild function...\");\n\n\t// Example: Filter out test files from entry points\n\tif (Array.isArray(Current.entryPoints)) {\n\t\tCurrent.entryPoints = Current.entryPoints.filter(\n\t\t\t(entry) =\u003e !/\\.(test|spec)\\.[mc]?[jt]s$/.test(entry),\n\t\t);\n\n\t\tconsole.log(\"Filtered entry points:\", Current.entryPoints);\n\t}\n\n\t// Example: Modify the config directly\n\tCurrent.define = {\n\t\t...(Current.define ?? {}), // Preserve existing defines\n\t\t\"process.env.BUILD_TIME\": `\"${new Date().toISOString()}\"`,\n\t};\n\n\t// Example: Return additional options to merge\n\treturn {\n\t\tbanner: {\n\t\t\tjs: \"// Generated by @playform/build\",\n\t\t},\n\t\tlogLevel: \"info\",\n\t};\n\n\t// If you only modify 'Current' directly, you can simply have no return:\n\t// return;\n\n\t// or return undefined;\n};\n```\n\n**Usage:**\n\nSpecify the path to your configuration file using the `--ESBuild` option:\n\n```sh\nnpx @playform/build 'Source/**/*.ts' --ESBuild ESBuild.ts\n```\n\nSee the base configuration used internally in\n[`Source/Variable/ESBuild.ts`](Source/Variable/ESBuild.ts) (link might need\nadjustment based on your actual path).\n\n### TypeScript Configuration (`--TypeScript`) 📜\n\nBy default, `Build` looks for `tsconfig.json` in the current working directory.\nYou can specify a different path using the `--TypeScript` option. This\n`tsconfig.json` is used by `ESBuild` for path resolution and by the `tsc` and\n`tsc-alias` commands run after the build for type checking and path alias\nreplacement.\n\nA typical `tsconfig.json` might look like this:\n\n```json\n// tsconfig.json\n{\n\t\"compilerOptions\": {\n\t\t// --- Essential for tsc/tsc-alias ---\n\t\t\"outDir\": \"Target\", // Must match esbuild's outdir/outfile directory\n\t\t\"rootDir\": \"Source\", // Or your source root\n\t\t\"baseUrl\": \".\", // Often needed for path aliases\n\t\t\"paths\": {\n\t\t\t// Example alias - must match esbuild alias config if used\n\t\t\t\"@/*\": [\"Source/*\"]\n\t\t},\n\t\t// --- Type Checking Options ---\n\t\t\"strict\": true,\n\t\t\"skipLibCheck\": true,\n\t\t\"forceConsistentCasingInFileNames\": true,\n\t\t// --- Module Settings (match esbuild target/format) ---\n\t\t\"target\": \"ES2020\",\n\t\t\"module\": \"ESNext\", // or CommonJS\n\t\t\"moduleResolution\": \"node\", // or node16/nodenext\n\t\t// --- Interoperability ---\n\t\t\"esModuleInterop\": true,\n\t\t\"allowSyntheticDefaultImports\": true,\n\t\t// --- Other ---\n\t\t\"resolveJsonModule\": true,\n\t\t\"isolatedModules\": true, // Good practice with transpilers like esbuild\n\t\t\"noEmit\": true // Important: Set noEmit to true as esbuild handles file emission\n\t},\n\t// Use @playform/build's base config for sensible defaults (optional)\n\t// \"extends\": \"@playform/build/tsconfig\",\n\t\"include\": [\"Source/**/*\"], // Files to be type-checked\n\t\"exclude\": [\"node_modules\", \"Target\"] // Exclude output and dependencies\n}\n```\n\n**Important:** Ensure `compilerOptions.outDir` in your `tsconfig.json` aligns\nwith the output directory configured for `ESBuild` (either via the default\n`Source/Variable/ESBuild.ts` or your custom `--ESBuild` config). Also, set\n`\"noEmit\": true` as `esbuild` handles the file generation; `tsc` is only used\nfor type checking here.\n\n### JSConfig Configuration (Optional) 📜\n\nIf you are working with JavaScript and JSDoc for type checking, you can use a\n`jsconfig.json` file instead of `tsconfig.json`. The principles are similar.\n\n```json\n// jsconfig.json\n{\n\t\"compilerOptions\": {\n\t\t\"outDir\": \"Target\",\n\t\t\"rootDir\": \"Source\",\n\t\t\"checkJs\": true, // Enable type checking for JS files\n\t\t\"target\": \"ES2020\",\n\t\t\"module\": \"ESNext\", // or CommonJS\n\t\t\"moduleResolution\": \"node\", // or node16/nodenext\n\t\t\"baseUrl\": \".\",\n\t\t\"paths\": {\n\t\t\t\"@/*\": [\"Source/*\"]\n\t\t},\n\t\t\"noEmit\": true // Still important\n\t},\n\t\"extends\": \"@playform/build/jsconfig\", // If you provide a base jsconfig\n\t\"include\": [\"Source/**/*\"],\n\t\"exclude\": [\"node_modules\", \"Target\"]\n}\n```\n\nRemember to pass the path to this file if it's not named `tsconfig.json` (even\nif it's a JS project, the default flag might still look for `tsconfig.json`\nunless you explicitly pass `--TypeScript jsconfig.json`).\n\n## Contributing 🤝\n\nContributions are welcome! Please see [`CONTRIBUTING.md`](CONTRIBUTING.md) for\nguidelines and feel free to submit a Pull Request.\n\n## Changelog\n\nSee [`CHANGELOG.md`](CHANGELOG.md) for a history of changes to this component.\n\n[ESBuild]: HTTPS://esbuild.github.io/\n[TypeScript]: HTTPS://www.typescriptlang.org/\n[Build]: HTTPS://www.npmjs.com/package/@playform/build\n","funding_links":["https://opencollective.com/playform-cloud-collective"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplayform%2Fbuild","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fplayform%2Fbuild","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplayform%2Fbuild/lists"}