{"id":19451278,"url":"https://github.com/thekashey/react-imported-library","last_synced_at":"2025-06-10T08:03:28.464Z","repository":{"id":66140832,"uuid":"138818120","full_name":"theKashey/react-imported-library","owner":"theKashey","description":"✂Code-split any library using renderProps!","archived":false,"fork":false,"pushed_at":"2018-10-27T07:31:15.000Z","size":247,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-10T08:02:00.347Z","etag":null,"topics":["code-splitting","codesplit","reactjs"],"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/theKashey.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-06-27T02:17:08.000Z","updated_at":"2024-05-08T06:58:56.000Z","dependencies_parsed_at":null,"dependency_job_id":"e1cdd785-05f5-4a2b-9c15-35b5267206d4","html_url":"https://github.com/theKashey/react-imported-library","commit_stats":{"total_commits":7,"total_committers":1,"mean_commits":7.0,"dds":0.0,"last_synced_commit":"f3950fd26169cd087a4f08d2055a9e55c9b215a8"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theKashey%2Freact-imported-library","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theKashey%2Freact-imported-library/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theKashey%2Freact-imported-library/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theKashey%2Freact-imported-library/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/theKashey","download_url":"https://codeload.github.com/theKashey/react-imported-library/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/theKashey%2Freact-imported-library/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259033746,"owners_count":22795766,"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":["code-splitting","codesplit","reactjs"],"created_at":"2024-11-10T16:41:04.366Z","updated_at":"2025-06-10T08:03:28.410Z","avatar_url":"https://github.com/theKashey.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003ch1\u003eIMPORTED LIBRARY ✂\u003c/h1\u003e\n  \u003cbr/\u003e\n  \u003cimg src=\"./assets/imported-logo.png\" alt=\"imported library\" width=\"409\" align=\"center\"\u003e\n  \u003cbr/\u003e\n  \u003cbr/\u003e\n  Dont code-split components - code split libraries \n  \u003cbr/\u003e\n  \u003cbr/\u003e\n  \n  \u003ca href=\"https://www.npmjs.com/package/react-imported-library\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/v/react-imported-library.svg?style=flat-square\" /\u003e\n  \u003c/a\u003e\n        \n  \u003ca href=\"https://travis-ci.org/theKashey/react-imported-library\"\u003e\n   \u003cimg src=\"https://travis-ci.org/theKashey/react-imported-library.svg?branch=master\" alt=\"Build status\"\u003e\n  \u003c/a\u003e \n    \n  \u003cimg src=\"https://badges.greenkeeper.io/theKashey/react-imported-library.svg\" /\u003e\n    \n  \u003cbr/\u003e\n\u003c/div\u003e\n\nUse the power of renderprop to delived a Library as a React component. Based on \n[React-imported-component](https://github.com/theKashey/react-imported-component). Support SSR and React Suspense.\n\n- ⛅️ You can codesplit momentjs, you may async load any library and use it.\n- 🏎 Sync on server, and for already loaded stuff, async on client.\n- 🚀 Bundler-independent SSR (when used with react-imported-component).\n- 🔒 Written in TypeScript.\n- 😴 Suspense friendly\n \n## Usage\n\nHave you heard, than moment.js is super hudge? Code split it!\n```javascript\nimport {importedLibraryDefault, setConfig} from 'react-imported-library';\n\n// do you need SSR support? Probably not (affects react-imported-component settings)\nsetConfig({SSR: false});\n\n// this will import `default` export\nconst Moment = importedLibraryDefault( () =\u003e import('momentjs'));\n\n\u003cMoment\u003e\n { (momentjs) =\u003e \u003cspan\u003e {momentjs(date).format(FORMAT)}\u003c/span\u003e }\n\u003c/Moment\u003e\n\n// You can use suspense\nconst Moment = importedLibraryDefault( () =\u003e import('momentjs'), { async: true });\n\n\u003cSuspense\u003e\n    \u003cMoment\u003e\n     { (momentjs) =\u003e \u003cspan\u003e {momentjs(date).format(FORMAT)}\u003c/span\u003e }\n    \u003c/Moment\u003e\n\u003c/Suspense\u003e\n```\n\nMay be you have a small library, you may use somewhere inside your components?\n\nCodesplit it! \n```js\nimport {importedLibrary} from 'react-imported-library';\nconst Utils = importedLibrary( () =\u003e import('./utils.js'));\n\n\u003cUtils\u003e\n { ({a,b,c }) =\u003e \u003cspan\u003e {a(b+c())} \u003c/span\u003e }\n\u003c/Utils\u003e\n```\n\nMay be you also have to calculate something heavy, not to do it on every `render`?\n```js\n// you may use \"initialization hook\" to offload some computations\n\n\u003cUtils\n  initial={ ({a,b,c}) =\u003e ({ result: a(b+c()) })}\n\u003e\n {(_,state) =\u003e \u003cspan\u003e{state.result}\u003c/span\u003e} \n\u003c/Utils\u003e\n\n\n```\n\n## API\n#### importedLibrary\n- `importedLibrary(importer, options?): Component`\n  - `importer` is an `import` statement, or any Promise resolver\n  - options \n    - options.async:boolean - enables React.suspense, ie throws a Promise on loading\n    - options.exportPicker - allows you to \"pick\" export from the original file\n    \n#### importedLibraryDefault    \n- `importedLibraryDefault(importer, options?): Component` - is just importedLibrary with `exportPicker` configured to pick `.default`\n\n#### lazyLibrary    \n- `lazyLibrary(importer): Component` - is just importedLibrary with `async` configured be __true__\n\n\n#### all helpers returns \"Component\"\n- Component\n  - `initial: (library: T) =\u003e K;` - state initializator, state will be passed as second argument to a children.\n  - `children: (library: T, state: K) =\u003e React.ReactNode` - function-as-children\n  - -- does not work in async mode --\n  - `error: ReactComponent` - error indicator\n  - `loading: ReactComponent` - __unthrottled__ loading indicator.         \n\n\n## Licence\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthekashey%2Freact-imported-library","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthekashey%2Freact-imported-library","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthekashey%2Freact-imported-library/lists"}