{"id":13880818,"url":"https://github.com/egoist/haya","last_synced_at":"2025-10-04T04:32:44.968Z","repository":{"id":40407448,"uuid":"440887489","full_name":"egoist/haya","owner":"egoist","description":"⚡️ esbuild based dev server and production bundler, it's really fast","archived":false,"fork":false,"pushed_at":"2022-06-23T22:40:09.000Z","size":116,"stargazers_count":233,"open_issues_count":13,"forks_count":2,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-02T02:39:35.876Z","etag":null,"topics":[],"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/egoist.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}},"created_at":"2021-12-22T14:37:33.000Z","updated_at":"2025-03-31T13:24:12.000Z","dependencies_parsed_at":"2022-08-25T07:40:19.002Z","dependency_job_id":null,"html_url":"https://github.com/egoist/haya","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":"egoist/ts-lib-starter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egoist%2Fhaya","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egoist%2Fhaya/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egoist%2Fhaya/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egoist%2Fhaya/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/egoist","download_url":"https://codeload.github.com/egoist/haya/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248045230,"owners_count":21038553,"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":[],"created_at":"2024-08-06T08:03:30.844Z","updated_at":"2025-10-04T04:32:44.873Z","avatar_url":"https://github.com/egoist.png","language":"TypeScript","funding_links":["https://github.com/sponsors/egoist).","https://github.com/sponsors/egoist"],"categories":["TypeScript"],"sub_categories":[],"readme":"**💛 You can help the author become a full-time open-source maintainer by [sponsoring him on GitHub](https://github.com/sponsors/egoist).**\n\n---\n\n# haya\n\n[![npm version](https://badgen.net/npm/v/haya)](https://npm.im/haya) [![npm downloads](https://badgen.net/npm/dm/haya)](https://npm.im/haya)\n\n## Introduction\n\nThis is a dev server and a bundler based on [esbuild](https://esbuild.github.io). Very early stage, don't use it for serious projects.\n\nThis guide is heavily copied from [Vite](https://vitejs.dev), since their usages are very similar.\n\n## Main Differences from Vite\n\n- Haya always bundles your app, while Vite does not during development.\n- Haya use esbuild for bundling, Vite uses Rollup.\n- Haya only supports full page reloading, while Vite has fine-grained HMR support.\n\n## Why Haya When There's Already Vite?\n\nVite shines at local development, it features a no-bundle dev server which is very fast and has a very good support for HMR. Thanks to [dependency prebundling with esbuild](https://vitejs.dev/guide/dep-pre-bundling.html), Vite can also create a production build fast using Rollup.\n\nThe idea of Haya is not to replace Vite at development, Haya's dev server works, as long as full page reloading works for your app, but the main goal is to make the production build even faster by fully leveraging esbuild. Currently Haya can already build Vite's default starter projects, and it's trying to keep improving on that.\n\nI plan to at least add HMR for CSS files, but HMR for JS files needs better support from esbuild itself, and it won't be there anytime soon.\n\n## Install\n\n```bash\nnpm i haya -D\n```\n\n## Quick Start\n\nUse [aho](https://github.com/egoist/aho) to download the starter project:\n\n```bash\nnpx aho@latest egoist/haya/template my-app\ncd my-app\nnpm i\n\n# start dev server\nnpm run dev\n# build for production\nnpm run build\n# preview production build\nnpm run preview\n```\n\n## Basics\n\n### Commands\n\n- `haya [dir]`: Start dev server, treat `dir` as root directory, defaults to `.`\n- `haya build [dir]`: Build for production, output files go to `[dir]/dist`\n- `haya preview [dir]`: Preview the production build in `[dir]/dist`.\n\n### Root HTML\n\nhaya expects a `index.html` file in the root directory. You can use `\u003clink\u003e` and `\u003cscript\u003e` tags to reference and bundle external CSS and JavaScript/TypeScript.\n\n- `\u003clink\u003e` should have property `rel=\"stylesheet\"` and `href=\"/some/style.css\"`\n- `\u003cscript\u003e` should have property `type=\"module\"` and `src=\"/some/script.ts\"`\n\n## Loader\n\n### TypeScript / JavaScript\n\nhaya uses [esbuild](https://esbuild.github.io) to bundle your TypeScript and JavaScript files in ES Module format, with code splitting enabled (via dynamic import).\n\nJSX/TSX works out of the box.\n\n### CSS\n\nThe recommended way to use CSS is to use `\u003clink\u003e` in `index.html`:\n\n```html\n\u003clink rel=\"stylesheet\" href=\"/src/style.css\" /\u003e\n```\n\nThe generated `index.html` will look like:\n\n```html\n\u003clink rel=\"stylesheet\" href=\"/0-style-[hash].css\" /\u003e\n```\n\nHowever you can also directly `import` CSS files in TypeScript/JavaScript files:\n\n```js\nimport \"./style.css\"\n```\n\nIt will also be included in generated `index.html`.\n\nNote that the exported value of CSS files will be the its URL:\n\n```js\nimport style from \"./style.css\"\n\nconsole.log(style)\n//=\u003e /style-[hash].css\n```\n\nIf you want to get the URL without adding the CSS file to generated `index.html`, append `?import-only` query to the module name:\n\n```js\nimport style from \"./style.css?import-only\"\n```\n\n### PostCSS\n\nAdding a `postcss.config.js` or `postcss.config.cjs` in your root directory to enable postcss.\n\n### Vue / Svelte\n\nLESS SOON.\n\n## Guide\n\n### Hot Module Replacement\n\nThere is **NO** hot module replacement, instead it does a full reloading of the page when a rebuild occurs.\n\n### Path Alias\n\nYou can directly configure aliases via `tsconfig.json` like this:\n\n```json\n{\n  \"compilerOptions\": {\n    \"baseUrl\": \".\",\n    \"paths\": {\n      \"~/*\": [\"./src/*\"]\n    }\n  }\n}\n```\n\nNow `~/main` will be resolved to `./src/main`.\n\n### Env Variables\n\nhaya exposes env variables on the `process.env` object. Some built-in variables are available in all cases:\n\n- `process.env.NODE_ENV`: `development` in dev or `production` in production. We also have a special global variable `__DEV__` which evaluates to `true` in dev and `false` in production.\n\n#### `.env` Files\n\nhaya uses [dotenv](https://github.com/motdotla/dotenv) to load additional environment variables from the following files in root directory:\n\n```\n.env                # loaded in all cases\n.env.local          # loaded in all cases, ignored by git\n.env.[mode]         # only loaded in specified mode\n.env.[mode].local   # only loaded in specified mode, ignored by git\n```\n\nLoaded env variables are also exposed to your client source code via `process.env`.\n\nTo prevent accidentally leaking env variables to the client, only variables prefixed with `HAYA_` are exposed to your haya-processed code. e.g. the following file:\n\n```\nDB_PASSWORD=foobar\nHAYA_SOME_KEY=123\n```\n\nOnly `HAYA_SOME_KEY` will be exposed as `process.env.HAYA_SOME_KEY` to your client source code, but `DB_PASSWORD` will not.\n\n### The `public` directory\n\nIf you have assets that are:\n\n- Never referenced in source code (e.g. `robots.txt`)\n- Must retain the exact same file name (without hashing)\n- ...or you simply don't want to have to import an asset first just to get its URL\n  Then you can place the asset in a special public directory under your project root. Assets in this directory will be served at root path `/` during dev, and copied to the root of the dist directory as-is.\n\nThe directory defaults to `\u003croot\u003e/public`, ~~but can be configured via the `publicDir` option (not yet)~~.\n\nNote that:\n\n- You should always reference public assets using root absolute path - for example, `public/icon.png` should be referenced in source code as /icon.png.\n- Assets in `public` cannot be imported from JavaScript.\n\n### Deploying a Static Site\n\nThe output directory `dist` can be served as a static website, you can preview it locally using the `haya preview` command.\n\n## Roadmap\n\n- [x] PostCSS / Tailwind support.\n- [ ] Vue / Svelte support.\n- [ ] SSR support, like the `ssrLoadModule` API from Vite.\n- [ ] Testing framework, like [Vitest](https://vitest.dev/) but for haya.\n\n## Sponsors\n\n[![sponsors](https://sponsors-images.egoist.sh/sponsors.svg)](https://github.com/sponsors/egoist)\n\n## License\n\nMIT \u0026copy; [EGOIST](https://github.com/sponsors/egoist)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fegoist%2Fhaya","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fegoist%2Fhaya","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fegoist%2Fhaya/lists"}