{"id":20160844,"url":"https://github.com/lukasbombach/tree-shakable-component-library","last_synced_at":"2025-04-10T00:10:55.530Z","repository":{"id":65251223,"uuid":"238669762","full_name":"LukasBombach/tree-shakable-component-library","owner":"LukasBombach","description":"A blueprint for a component library with tree-shaking, TypeScript and a MonoRepo","archived":false,"fork":false,"pushed_at":"2020-09-04T03:36:28.000Z","size":2017,"stargazers_count":88,"open_issues_count":7,"forks_count":10,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-10T00:10:53.077Z","etag":null,"topics":["component-library","design-system","tree-shaking","typescript"],"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/LukasBombach.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2020-02-06T11:08:25.000Z","updated_at":"2025-02-25T06:09:24.000Z","dependencies_parsed_at":"2023-01-16T15:01:04.562Z","dependency_job_id":null,"html_url":"https://github.com/LukasBombach/tree-shakable-component-library","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LukasBombach%2Ftree-shakable-component-library","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LukasBombach%2Ftree-shakable-component-library/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LukasBombach%2Ftree-shakable-component-library/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LukasBombach%2Ftree-shakable-component-library/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LukasBombach","download_url":"https://codeload.github.com/LukasBombach/tree-shakable-component-library/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248131317,"owners_count":21052819,"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":["component-library","design-system","tree-shaking","typescript"],"created_at":"2024-11-14T00:16:08.033Z","updated_at":"2025-04-10T00:10:55.495Z","avatar_url":"https://github.com/LukasBombach.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tree-shakable component library with TypeScript, StoryBook \u0026 Next.js\n\nThis repository is the demonstration of my dev.to article\n\n👉 https://dev.to/lukasbombach/how-to-write-a-tree-shakable-component-library-4ied\n\ndemonstrating how to implement a tree-shakable component library (with TypeScript, StoryBook \u0026 Next.js\nall in a Monorepo).\n\nFor questions you can find me on twitter as [@luke_schmuke](https://twitter.com/luke_schmuke/)\n\n## Install\n\n```bash\ngit clone https://github.com/LukasBombach/tree-shakable-component-library\ncd tree-shakable-component-library\nyarn\n```\n\n## Run\n\nThis MonoRepo has 2 packages\n\n- [`app`](./packages/app) and\n- [`ui-library`](./packages/ui-library)\n\nThe `app` is a Next.js app that _consumes_ the `ui-library` in the [`index.tsx` page](./packages/app/pages/index.tsx) while the `ui-library` provides bundled [components](./packages/ui-library/components).\n\nYou can run the app by switching to the app folder and run `yarn dev` or `yarn start`\u003csup\u003e\\*\u003c/sup\u003e\u003cbr /\u003e\n\u003csub\u003e\\* both packages have `postinstall` script that runs `yarn build` in each project\u003c/sub\u003e\n\n### Run the app\n\n```bash\ncd packages/app\nyarn dev\n```\n\nYou can also run StoryBook from within the `ui-library`\n\n### Run StoryBook\n\n```bash\ncd packages/ui-library\nyarn storybook\n```\n\nYou can change or add new components by running\n\n### Develop new components\n\n```bash\ncd packages/ui-library\nyarn build -w\n```\n\nin another terminal you can run the app in parallel and it will auto-update with hot-module-reloading\n\n```bash\ncd packages/app\nyarn dev\n```\n\n## See the tree-shaking\n\nYou can very simple see that the app actually does tree-shake your code by opening this project in a code\neditor and searching all files in `packages/app/.next` and\n\n1. searching for the string `I SHOULD BE HERE`, which should be found.\n   This string is part of the [`Button`](./packages/ui-library/components/Button/Button.tsx) component\n   which has been loaded into the app\n2. then search for the string `I MUST NOT BE HERE`\n   This string is part of the [`Link`](./packages/ui-library/components/Link/Link.tsx) component which has\n   **not** been loaded into the app even though it has been bundled in the ui library and should not be\n   bundled in the app.\n3. check out the file `packages/ui-library/lib/index.esm.js` which is the bundled file of the ui-library which\n   includes all components\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukasbombach%2Ftree-shakable-component-library","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flukasbombach%2Ftree-shakable-component-library","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukasbombach%2Ftree-shakable-component-library/lists"}