{"id":13432968,"url":"https://github.com/unjs/unbuild","last_synced_at":"2025-05-12T11:18:01.486Z","repository":{"id":37501293,"uuid":"355627781","full_name":"unjs/unbuild","owner":"unjs","description":"📦 A unified JavaScript build system","archived":false,"fork":false,"pushed_at":"2025-04-29T14:07:04.000Z","size":1884,"stargazers_count":2579,"open_issues_count":57,"forks_count":99,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-05-12T11:17:52.794Z","etag":null,"topics":["universal-javascript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/unjs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"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,"zenodo":null}},"created_at":"2021-04-07T17:23:00.000Z","updated_at":"2025-05-12T04:31:24.000Z","dependencies_parsed_at":"2023-11-14T08:26:06.861Z","dependency_job_id":"fb6f6ce9-6163-410b-aefa-c9354fb8bd90","html_url":"https://github.com/unjs/unbuild","commit_stats":{"total_commits":489,"total_committers":43,"mean_commits":"11.372093023255815","dds":0.6809815950920246,"last_synced_commit":"c00af347af11825af031f4aa8356c44040c3bc07"},"previous_names":[],"tags_count":103,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unjs%2Funbuild","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unjs%2Funbuild/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unjs%2Funbuild/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unjs%2Funbuild/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/unjs","download_url":"https://codeload.github.com/unjs/unbuild/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253726906,"owners_count":21954096,"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":["universal-javascript"],"created_at":"2024-07-31T02:01:19.146Z","updated_at":"2025-05-12T11:18:01.461Z","avatar_url":"https://github.com/unjs.png","language":"TypeScript","readme":"# unbuild\n\n\u003c!-- automd:badges --\u003e\n\n[![npm version](https://img.shields.io/npm/v/unbuild)](https://npmjs.com/package/unbuild)\n[![npm downloads](https://img.shields.io/npm/dm/unbuild)](https://npm.chart.dev/unbuild)\n\n\u003c!-- /automd --\u003e\n\n\u003e A unified JavaScript build system\n\n### 📦 Optimized bundler\n\nRobust [rollup](https://rollupjs.org) based bundler that supports TypeScript and generates commonjs and module formats + type declarations.\n\n### 🪄 Automated config\n\nAutomagically infer build config and entries from `package.json`.\n\n### 📁 Bundleless build\n\nIntegration with [mkdist](https://github.com/unjs/mkdist) for generating bundleless dists with file-to-file transpilation.\n\n### ✨ Passive watcher\n\nStub `dist` once using `unbuild --stub` (powered by [jiti](https://github.com/unjs/jiti)) and you can try and link your project without needing to watch and rebuild during development.\n\n### ✍ Untype Generator\n\nIntegration with [untyped](https://github.com/unjs/untyped).\n\n### ✔️ Secure builds\n\nAutomatically check for various build issues such as potential **missing** and **unused** [dependencies](https://docs.npmjs.com/cli/v7/configuring-npm/package-json#dependencies) and fail CI.\n\nCLI output also includes output size and exports for quick inspection.\n\n## Usage\n\nCreate `src/index.ts`:\n\n```js\nexport const log = (...args) =\u003e {\n  console.log(...args);\n};\n```\n\nUpdate `package.json`:\n\n```json\n{\n  \"type\": \"module\",\n  \"scripts\": {\n    \"build\": \"unbuild\",\n    \"prepack\": \"unbuild\"\n  },\n  \"exports\": {\n    \".\": {\n      \"import\": \"./dist/index.mjs\",\n      \"require\": \"./dist/index.cjs\"\n    }\n  },\n  \"main\": \"./dist/index.cjs\",\n  \"types\": \"./dist/index.d.ts\",\n  \"files\": [\"dist\"]\n}\n```\n\n\u003e **Note**\n\u003e You can find a more complete example in [unjs/template](https://github.com/unjs/template) for project setup.\n\nBuild with `unbuild`:\n\n```sh\nnpx unbuild\n```\n\nConfiguration is automatically inferred from fields in `package.json` mapped to `src/` directory. For more control, continue with next section.\n\n## Configuration\n\nCreate `build.config.ts`:\n\n```js\nexport default {\n  entries: [\"./src/index\"],\n};\n```\n\nYou can either use `unbuild` key in `package.json` or `build.config.{js,cjs,mjs,ts,mts,cts,json}` to specify configuration.\n\nSee options [here](./src/types.ts).\n\nExample:\n\n```js\nimport { defineBuildConfig } from \"unbuild\";\n\nexport default defineBuildConfig({\n  // If entries is not provided, will be automatically inferred from package.json\n  entries: [\n    // default\n    \"./src/index\",\n    // mkdist builder transpiles file-to-file keeping original sources structure\n    {\n      builder: \"mkdist\",\n      input: \"./src/package/components/\",\n      outDir: \"./build/components\",\n    },\n  ],\n\n  // Change outDir, default is 'dist'\n  outDir: \"build\",\n\n  // Generates .d.ts declaration file\n  declaration: true,\n});\n```\n\nOr with multiple builds you can declare an array of configs:\n\n```js\nimport { defineBuildConfig } from \"unbuild\";\n\nexport default defineBuildConfig([\n  {\n    // If entries is not provided, will be automatically inferred from package.json\n    entries: [\n      // default\n      \"./src/index\",\n      // mkdist builder transpiles file-to-file keeping original sources structure\n      {\n        builder: \"mkdist\",\n        input: \"./src/package/components/\",\n        outDir: \"./build/components\",\n      },\n    ],\n\n    // Change outDir, default is 'dist'\n    outDir: \"build\",\n\n    /**\n     * * `compatible` means \"src/index.ts\" will generate \"dist/index.d.mts\", \"dist/index.d.cts\" and \"dist/index.d.ts\".\n     * * `node16` means \"src/index.ts\" will generate \"dist/index.d.mts\" and \"dist/index.d.cts\".\n     * * `true` is equivalent to `compatible`.\n     * * `false` will disable declaration generation.\n     * * `undefined` will auto detect based on \"package.json\". If \"package.json\" has \"types\" field, it will be `\"compatible\"`, otherwise `false`.\n     */\n    declaration: \"compatible\",\n  },\n  {\n    name: \"minified\",\n    entries: [\"./src/index\"],\n    outDir: \"build/min\",\n    rollup: {\n      esbuild: {\n        minify: true,\n      },\n    },\n  },\n]);\n```\n\n## Recipes\n\n### Decorators support\n\nIn `build.config.ts`\n\n```ts\nimport { defineBuildConfig } from \"unbuild\";\n\nexport default defineBuildConfig({\n  rollup: {\n    esbuild: {\n      tsconfigRaw: {\n        compilerOptions: {\n          experimentalDecorators: true,\n        },\n      },\n    },\n  },\n});\n```\n\n### Generate sourcemaps\n\n```ts\nimport { defineBuildConfig } from \"unbuild\";\n\nexport default defineBuildConfig({\n  sourcemap: true,\n});\n```\n\n## 💻 Development\n\n- Clone this repository\n- Enable [Corepack](https://github.com/nodejs/corepack) using `corepack enable` (use `npm i -g corepack` for Node.js \u003c 16.10)\n- Install dependencies using `pnpm install`\n- Run interactive tests using `pnpm dev`\n\n## License\n\n[MIT](./LICENSE)\n\n\u003c!-- Badges --\u003e\n\n[npm-version-src]: https://img.shields.io/npm/v/unbuild?style=flat-square\n[npm-version-href]: https://npmjs.com/package/unbuild\n[npm-downloads-src]: https://img.shields.io/npm/dm/unbuild?style=flat-square\n[npm-downloads-href]: https://npmjs.com/package/unbuild\n[github-actions-src]: https://img.shields.io/github/actions/workflow/status/unjs/unbuild/ci.yml?style=flat-square\n[github-actions-href]: https://github.com/unjs/unbuild/actions?query=workflow%3Aci\n[codecov-src]: https://img.shields.io/codecov/c/gh/unjs/unbuild/main?style=flat-square\n[codecov-href]: https://codecov.io/gh/unjs/unbuild\n","funding_links":[],"categories":["TypeScript","others","Packages","Uncategorized"],"sub_categories":["Uncategorized"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funjs%2Funbuild","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funjs%2Funbuild","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funjs%2Funbuild/lists"}