{"id":20160586,"url":"https://github.com/reactnativecn/rn-haul-split","last_synced_at":"2025-04-10T00:10:43.639Z","repository":{"id":56824239,"uuid":"151795071","full_name":"reactnativecn/rn-haul-split","owner":"reactnativecn","description":"support code splitting for react-native with haul \u0026 webpack","archived":false,"fork":false,"pushed_at":"2018-10-06T03:42:06.000Z","size":51,"stargazers_count":12,"open_issues_count":0,"forks_count":1,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-04-26T10:45:40.247Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/reactnativecn.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}},"created_at":"2018-10-06T01:41:38.000Z","updated_at":"2020-01-18T22:38:58.000Z","dependencies_parsed_at":"2022-09-01T13:02:30.730Z","dependency_job_id":null,"html_url":"https://github.com/reactnativecn/rn-haul-split","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/reactnativecn%2Frn-haul-split","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reactnativecn%2Frn-haul-split/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reactnativecn%2Frn-haul-split/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reactnativecn%2Frn-haul-split/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/reactnativecn","download_url":"https://codeload.github.com/reactnativecn/rn-haul-split/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":[],"created_at":"2024-11-14T00:14:49.675Z","updated_at":"2025-04-10T00:10:43.620Z","avatar_url":"https://github.com/reactnativecn.png","language":"JavaScript","readme":"# react-native-chunk-split\n\n## Getting started\n\nThis module works with react native and [haul](https://callstack.github.io/haul/), which use webpack as bundle tools.\n\nStep 1: Init project\n\n```bash\n# Create a project. skip if you already have a project\nreact-native init MyProject --version 0.55.4\ncd MyProject\n\n# install and init haul\nyarn add -D haul\nyarn haul init\n```\n\nThis will generate `haul.config.js` in your project root.\n\nStep 2: Config babel\n\nConfig babel to support \"async import\" syntax. You can skip this step if you use require.ensure instead.\n\n```bash\n# babel 6(rn 0.55-)\nyarn add -D babel-plugin-syntax-dynamic-import\n# babel 7(rn 0.56+, currently not supported by haul:)\nyarn add -D @babel/plugin-syntax-dynamic-import\n```\n\nEdit your `.babelrc`:\n\n```javascript\n{\n  \"presets\": [\"react-native\"],\n  // Add this line for RN 0.55-:\n  \"plugins\": [\"babel-plugin-syntax-dynamic-import\"]\n  // Add this line for RN 0.56+:\n  \"plugins\": [\"@babel/plugin-syntax-dynamic-import\"]\n}\n```\n\nStep 3: Install and add ChunkSplit:\n\n```bash\nyarn add react-native-chunk-split\nreact-native link react-native-chunk-split\n```\n\nEdit your `haul.config.js`:\n\n```javascript\n// Change this line from require(\"haul\"):\nconst { createWebpackConfig } = require('react-native-chunk-split');\n\nexport default {\n  webpack: createWebpackConfig(({ platform }) =\u003e ({\n    entry: `./index.js`,\n  })),\n};\n```\n\nStep 4: Run project\n\nStart haul packager:\n\n```bash\nyarn haul\n```\n\nRun your app:\n\n```bash\nreact-native run-ios\n# or\nreact-native run-android\n```\n\nNow you can use\n\n## Usage\n\nRead [Webpack guides for code splitting](https://webpack.js.org/guides/code-splitting/#dynamic-imports)\n\n## FAQ:\n\n#### Why `yarn haul init` doesn't create `haul.config.js` ?\n\nCurrently, haul doesn't support babel@7, which means it's not compatible with react native 0.56+. Use 0.55.4 instead.\n\n#### Can I split react-native into a vendor chunk?\n\nNope. Because react-native init bridge with a root view, while only one script can be loaded at this time, you must include BOTH react-native code AND your root component in your entry chunk.\n\nBut you can split other libraries that's not used by root component into vendor chunk.\n\nIt's good to include only a entry(splash) component in entry chunk, then load any other component with 'await import' syntax.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freactnativecn%2Frn-haul-split","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freactnativecn%2Frn-haul-split","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freactnativecn%2Frn-haul-split/lists"}