{"id":22307,"library":"rollup-route-manifest","title":"rollup-route-manifest","description":"Rollup plugin (v1.0.0, stable, low release cadence) that generates an asset manifest keyed by route patterns, enabling proactive prefetching/preloading of code-split chunks. Unlike generic manifest plugins, this maps output filenames to URL route patterns via a user-defined function or dictionary, giving control over commons grouping and route-specific asset lists. Ships TypeScript types, requires Rollup >=2.0.0.","status":"active","version":"1.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/lukeed/rollup-route-manifest","tags":["javascript","route","manifest","code-split","route-manifest","rollup-plugin","rollup","typescript"],"install":[{"cmd":"npm install rollup-route-manifest","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-route-manifest","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-route-manifest","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency; plugin requires Rollup >=2.0.0 API","package":"rollup","optional":false}],"imports":[{"note":"ESM default export. CommonJS require works but TypeScript users may need esModuleInterop.","wrong":"const Manifest = require('rollup-route-manifest')","symbol":"Manifest","correct":"import Manifest from 'rollup-route-manifest'"},{"note":"Type exports are behind the default export; no named type exported directly.","wrong":"import { ManifestOptions } from 'rollup-route-manifest'","symbol":"Manifest (as type)","correct":"import type { RollupRouteManifestOptions } from 'rollup-route-manifest'"},{"note":"The `routes` option can be a function or an object. If object, keys must be absolute file paths.","wrong":"Manifest({ routes: {} }) without proper absolute paths","symbol":"routes function","correct":"Manifest({ routes: (file) => { /* ... */ } })"}],"quickstart":{"code":"// rollup.config.js\nimport Manifest from 'rollup-route-manifest';\n\nexport default {\n  input: 'src/index.js',\n  output: { dir: 'dist', format: 'esm', entryFileNames: '[name]-[hash].js', chunkFileNames: '[name]-[hash].js' },\n  plugins: [\n    Manifest({\n      // Map absolute file paths to route patterns\n      routes(file) {\n        // Example: group all non-page chunks as commons\n        if (!file.includes('/pages/')) return '*'; // commons\n        // Derive route from path\n        let name = file.replace('/Users/me/myapp/src', '').replace(/\\.js$/, '');\n        if (name === '/pages/home') return '/';\n        if (name === '/pages/about') return '/about';\n        if (name === '/pages/blog/[slug]') return '/blog/:slug';\n        // Ignore error page\n        if (name === '/pages/error') return false;\n        // Default: use file path as route\n        return name;\n      },\n      merge: true,\n      minify: true\n    })\n  ]\n};","lang":"typescript","description":"Shows how to configure the plugin in a Rollup config, mapping absolute file paths to route patterns with the required 'routes' function."},"warnings":[{"fix":"Always provide a `routes` option as described in the docs.","message":"The `routes` option is required and must be a function or an object with absolute paths as keys. If missing, the plugin throws an error.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Use `path.resolve` to generate the keys or extract absolute paths from Rollup's module resolution.","message":"When using the object form of `routes`, keys must be absolute file paths exactly as resolved by Rollup (including platform-specific separators).","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"If you want to exclude a chunk entirely, use Rollup's `inlineDynamicImports` or other mechanisms.","message":"Returning `false` from the `routes` function does NOT prevent the chunk from being emitted; it only omits it from the manifest. The chunk will still appear in the bundle output.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use the `name` option to customize the manifest filename if needed.","message":"The manifest output file is written to the Rollup output directory as `route-manifest.json` by default. Ensure the output directory is writable and not already containing that file unless you want it overwritten.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use `const Manifest = require('rollup-route-manifest').default;` or enable `esModuleInterop` in tsconfig.","cause":"Default import used with CommonJS requiring esModuleInterop.","error":"TypeError: Manifest is not a function"},{"fix":"Add a `routes` function or object to the plugin options.","cause":"Missing `routes` option in plugin config.","error":"Error: [rollup-route-manifest] The `routes` option is required."},{"fix":"Ensure Rollup's preserveModules or similar options are not interfering; provide absolute paths correctly.","cause":"Inside the `routes` function, the file argument is undefined because the plugin cannot retrieve the module's absolute path.","error":"TypeError: Cannot read property 'includes' of undefined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}