{"id":4474,"url":"https://github.com/changfuguo/react-native-webpackager-server","last_synced_at":"2025-08-04T01:32:29.621Z","repository":{"id":57341440,"uuid":"50645903","full_name":"changfuguo/react-native-webpackager-server","owner":"changfuguo","description":null,"archived":false,"fork":false,"pushed_at":"2016-02-01T05:49:36.000Z","size":381,"stargazers_count":6,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-25T17:47:28.740Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/changfuguo.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":"2016-01-29T07:24:20.000Z","updated_at":"2018-09-25T02:30:45.000Z","dependencies_parsed_at":"2022-09-15T16:22:51.898Z","dependency_job_id":null,"html_url":"https://github.com/changfuguo/react-native-webpackager-server","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/changfuguo/react-native-webpackager-server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/changfuguo%2Freact-native-webpackager-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/changfuguo%2Freact-native-webpackager-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/changfuguo%2Freact-native-webpackager-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/changfuguo%2Freact-native-webpackager-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/changfuguo","download_url":"https://codeload.github.com/changfuguo/react-native-webpackager-server/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/changfuguo%2Freact-native-webpackager-server/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268636389,"owners_count":24282082,"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","status":"online","status_checked_at":"2025-08-03T02:00:12.545Z","response_time":2577,"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":[],"created_at":"2024-01-05T20:17:13.679Z","updated_at":"2025-08-04T01:32:29.299Z","avatar_url":"https://github.com/changfuguo.png","language":"JavaScript","funding_links":[],"categories":["Components"],"sub_categories":["Utils \u0026 Infra"],"readme":"# react-native-webpackager-server\n\n\u003e 该插件主要意图在做lib和app业务代码的分离；[react-native-webpack-server](https://github.com/mjohnston/react-native-webpack-server)里基本上已经实现了一套代码分离服务；在该插件基础上优化了一些东西，感谢该作者哈~\n\n## react-native-webpack-server分离\n\nreact-native-webpack-server分离启动了三个服务\n\n* 8081是原来RN服务，用来打包RN的lib代码\n* 8082是webpack-dev-server，用来打包app的业务代码\n* 8080 是新建的server服务，生成webpack的external输出8081和8082的合并结果\n\n但是发现作者打包的过程和RN的过程一样，启动非常慢，做了几点改进，\n\n# 安装\n  `npm install --save-dev react-native-webpackager-server`\n\n# 使用\n  \n  具体用法，可参考demo里用法，\n  也可以用[react-native-webpack-server](https://github.com/mjohnston/react-native-webpack-server)原来的用法，\n  demo的用法我自己写个8080的router，在执行 `npm run start` 时传入了 自定义ruoter的方法\n  \n  demo里的示例放在./router文件夹里，供8080的server调用，传入的参数可自己查看代码进行定制\n\n  获取所有代码的 地址为`http://localhost:8080/all.code?platform=ios\u0026dev=false\u0026minify=true`\n\n  获取RN的lib的 地址为`http://localhost:8080/lib.code?platform=ios\u0026dev=false\u0026minify=true`\n\n  获取业务代码的 地址为`http://localhost:8080/app.code?platform=ios\u0026dev=false\u0026minify=true`\n\n## 优化体现在以下两方面\n\n1 start服务时，不是动态生成externals，而是只生成一次\n\n优化webpack打包生成externals的方法，只在第一次生成时按照RN版本+是否是dev生成对应的externals文件，下次\n根据请求的RN版本+dev参数的文件，因为只有这两个参数会影响externals\n\n2 将用于生成lib的写法固定到具体文件里，分为ios和android\n\n3 缓存lib库\n\n在调试的时候，任何变动都会引起RN打包（这里没有仔细看是否制定projectRoot参数是否会起作用），\n但是实际上RN的lib文件变动只和platform、dev和minify三个参数有关，按照这三个参数进行缓存，加快输出速度\n\n4 webpack的minify通过引入uglify-js根据参数来输出\n\n5 引入手动制定server的routes\n\n  具体用法和 react-native-webpackager-server 一样 启动的时候加入routerServer的地址，\n  具体可见router文件，里面有三个路由可以生成lib、app以及所有代码的输出 \n\n6 webpack的demo 见webpack.config.js.demo\n\n  其中 1 2 3都可以大大提高启动和调试时获取bundle的速度，尤其是缓存了当前rn版本对应的lib库后；\n\n  5引入自定义的router之后 ，可以很灵活的结合自己业务进行lib库和app本身的逻辑代码，发布app时，把bundle拆分为lib和app代码，\n  可以减少bundle下行下载的速度，不用下载rn的lib库\n\n## 后续优化\n\n1  对分离的lib代码和app代码，提供一个服务进行单独的版本管理，目前可想到的根据端类型（ios或android）+端版本+RN版本+业务代码进行更新\n\n2  热更新机制，这个还没仔细研究RN是怎么实现的，看能不能webpack也实现下，原来的 react-native-webpack-server是没有实现\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchangfuguo%2Freact-native-webpackager-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchangfuguo%2Freact-native-webpackager-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchangfuguo%2Freact-native-webpackager-server/lists"}