A Rollup plugin that rewrites dynamic (and optionally static) import paths to use an absolute base URL, such as '/' or '/forum'. This prevents chunk loading failures on sub-routes (e.g., /login loads chunks from the wrong path). Version 0.0.2 is the current release. It avoids AST parsing for performance, doing a naive string replacement of chunk paths. No known release cadence. Differentiators: lightweight, simple, no AST overhead, compatible with plugins like rollup-plugin-hoist-import-deps. Alternatives (e.g., @rollup/plugin-url) target assets, not imports.
npm install rollup-plugin-base-urlVerified import paths — ran on the pinned version, not inferred.
Basic Rollup config using baseUrl plugin to serve dynamic imports from '/' root, preventing route-specific loading errors.
Avoid using file names or imports that contain patterns like './some-chunk-hash.js' in string literals or comments.
Ensure output.chunkFileNames uses the default '[name]-[hash].js' pattern, or adapt plugin logic.
None needed.
Consider migrating to a more maintained alternative if needed.
Change to import { baseUrl } from 'rollup-plugin-base-url' and ensure your project is ESM (e.g., use 'type': 'module' in package.json or .mjs extension).Invoke baseUrl with a single options object: baseUrl({ url: '/forum', staticImports: true }).Check that output.chunkFileNames uses '[name]-[hash].js' pattern. If using static imports, set staticImports: true.
No dependency data recorded yet.