{"id":13826020,"url":"https://github.com/lukeed/route-manifest","last_synced_at":"2025-10-09T18:24:27.388Z","repository":{"id":57157433,"uuid":"203074821","full_name":"lukeed/route-manifest","owner":"lukeed","description":"A tiny (412B) runtime to retrieve the correct entry from a Route Manifest file.","archived":false,"fork":false,"pushed_at":"2020-01-26T08:11:14.000Z","size":16,"stargazers_count":46,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-11T01:42:58.608Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/lukeed.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":"2019-08-19T01:10:56.000Z","updated_at":"2024-04-15T04:30:44.000Z","dependencies_parsed_at":"2022-09-07T21:00:39.437Z","dependency_job_id":null,"html_url":"https://github.com/lukeed/route-manifest","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Froute-manifest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Froute-manifest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Froute-manifest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukeed%2Froute-manifest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lukeed","download_url":"https://codeload.github.com/lukeed/route-manifest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225470631,"owners_count":17479366,"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-08-04T09:01:30.891Z","updated_at":"2025-10-09T18:24:22.355Z","avatar_url":"https://github.com/lukeed.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# route-manifest [![codecov](https://badgen.now.sh/codecov/c/github/lukeed/route-manifest)](https://codecov.io/gh/lukeed/route-manifest)\n\n\u003e A tiny (412B) runtime to retrieve the correct entry from a Route Manifest file.\n\nThis is the runtime/client-side component for [`webpack-route-manifest`](https://github.com/lukeed/webpack-route-manifest).\u003cbr\u003e\nIt is **required** that your manifest's routes be [sorted by specificity](https://github.com/lukeed/route-sort#specificity), which _is_ the webpack plugin's default setting.\n\n\u003e **Important:** This `route-manifest` _does not_ fetch files or apply headers on your behalf!\n\nThe module is available in three formats:\n\n* **ES Module**: `dist/rmanifest.mjs`\n* **CommonJS**: `dist/rmanifest.js`\n* **UMD**: `dist/rmanifest.min.js`\n\n\n## Install\n\n```\n$ npm install --save route-manifest\n```\n\n\n## Usage\n\n```js\nimport { prefetch } from 'quicklink';\nimport rmanifest from 'route-manifest';\n\n// Manually fetch Manifest file contents\nfetch('/manifest.json').then(r =\u003e r.json()).then(data =\u003e {\n  /*\n    Assume Manifest (`data`) is:\n    {\n      [pattern]: {\n        files: { href: string, type: string }\n        headers: [...skip...]\n      }\n    }\n  */\n\n  const files = new Set();\n\n  // We want to prefetch these pages' assets\n  ['/blog', '/about', '/features'].forEach(str =\u003e {\n    let entry = rmanifest(data, str);\n    entry.files.forEach(x =\u003e files.add(x.href));\n  });\n\n  // Note:\n  //   The `quicklink` module will do the actual prefetching!\n  //   We just have have to give it a file path, or an array\n  //   of file paths in this case~!\n  return prefetch([...files]);\n});\n```\n\n\n## API\n\n### rmanifest(contents, uri, withCommons)\nReturns: `{ files: Array, headers: Array }`\n\nReturns an object containing `files` and `headers` keys, both of which will be arrays. The arrays' items are copied from your Manifest file directly, so you will (presumably) already know the shape of your data.\n\n\n#### contents\nType: `Object`\n\nThe Manifest file's contents.\u003cbr\u003e\nAny format returned by [`webpack-route-manifest`](https://github.com/lukeed/webpack-route-manifest) is valid.\n\n\u003e **Important:** The route pattern keys [must be sorted](https://github.com/lukeed/webpack-route-manifest#optionssort) for matching correctness.\n\n#### uri\nType: `String`\n\nThe URL for which you want to find files or headers.\n\n\u003e **Note:** _Only_ include the `pathname` segment of a URL, unless a pattern is explicitly looking for other segments.\n\n#### withCommons\nType: `Boolean`\u003cbr\u003e\nDefault: `false`\n\nWhether or not the base/root-wildcard entry should be included.\n\nWhen `true` and when a `\"*\"` pattern is defined, this will include the wildcard's entry _in addition to_ the route's own specific entry too, if any. The result is still a single object of `{ files, headers }` shape – the difference is just that the two entries have their keys' items concatenated into a single array.\n\nWhen `false`, this module will _only_ return the entry _specific to_ the requested `uri` pathname.\n\n\n## Related\n\n* [webpack-route-manifest](https://github.com/lukeed/webpack-route-manifest) – generate a Route Manifest file for your webpack build\n* [quicklink](https://github.com/GoogleChromeLabs/quicklink) – preloading utility that reacts to connection speed and browser support\n* [route-sort](https://github.com/lukeed/route-sort) – the route pattern sorter required for safe sequential matching\n\n\n## License\n\nMIT © [Luke Edwards](https://lukeed.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukeed%2Froute-manifest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flukeed%2Froute-manifest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukeed%2Froute-manifest/lists"}