{"id":20766190,"url":"https://github.com/navono/import-external-lib-to-react","last_synced_at":"2026-04-06T08:31:28.984Z","repository":{"id":74496772,"uuid":"146527976","full_name":"navono/import-external-lib-to-react","owner":"navono","description":"Dynamic load lib to React","archived":false,"fork":false,"pushed_at":"2018-12-04T08:03:25.000Z","size":3306,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-11T18:54:57.337Z","etag":null,"topics":["reactjs"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/navono.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-08-29T01:29:35.000Z","updated_at":"2018-12-04T08:16:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"2be0e8de-e356-4204-b46d-4cdd9e0f9ea6","html_url":"https://github.com/navono/import-external-lib-to-react","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/navono/import-external-lib-to-react","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/navono%2Fimport-external-lib-to-react","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/navono%2Fimport-external-lib-to-react/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/navono%2Fimport-external-lib-to-react/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/navono%2Fimport-external-lib-to-react/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/navono","download_url":"https://codeload.github.com/navono/import-external-lib-to-react/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/navono%2Fimport-external-lib-to-react/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31464604,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-05T21:22:52.476Z","status":"online","status_checked_at":"2026-04-06T02:00:07.287Z","response_time":112,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["reactjs"],"created_at":"2024-11-17T11:21:53.115Z","updated_at":"2026-04-06T08:31:28.966Z","avatar_url":"https://github.com/navono.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# import-external-lib-to-react\n在`React`工程中，导入其他工程的`UMD`风格的`bundle`文件。\n\n# dev\n`react-host`和`react-ts-host`均由`create-react-app`产生。因此如果要从外部导入文件，需要修改其`webpack`配置。首先`host`工程中：\n\u003e yarn eject\n\n然后修改`webpack.config.dev.js`和`webpack.config.prod.js`，将其中的\n\u003e new ModuleScopePlugin(paths.appSrc, [paths.appPackageJson]),\n\n注释掉。\n\n然后使用`import()`即可动态加载，详细参考`App.js`或者`App.tsx`。\n\n## react-ts-host\n`yarn build` 先编译产生结果文件。然后将 `lib` 拷贝到 `build` 文件夹。执行以下命令：\n```js\nnpx http-server ./build/\n```\n\n访问 `http://localhost:8080`。\n\n## 注意\n对于`typescript`的工程，需要额外添加`*.d.ts`声明文件。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnavono%2Fimport-external-lib-to-react","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnavono%2Fimport-external-lib-to-react","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnavono%2Fimport-external-lib-to-react/lists"}