{"id":21925,"library":"rollup-plugin-base-url","title":"rollup-plugin-base-url","description":"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.","status":"active","version":"0.0.2","language":"javascript","source_language":"en","source_url":"https://github.com/kim366/rollup-plugin-base-url","tags":["javascript","rollup-plugin","base-url","prerender"],"install":[{"cmd":"npm install rollup-plugin-base-url","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-base-url","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-base-url","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package is ESM-only; require() will fail because package.json has no 'main' or 'exports' for CJS.","wrong":"const baseUrl = require('rollup-plugin-base-url')","symbol":"baseUrl","correct":"import { baseUrl } from 'rollup-plugin-base-url'"},{"note":"There is no default export. Only the named export 'baseUrl' exists.","wrong":"import baseUrl from 'rollup-plugin-base-url'","symbol":"default export","correct":"import { baseUrl } from 'rollup-plugin-base-url'"},{"note":"The plugin takes a single options object; positional arguments are not supported.","wrong":"baseUrl('/forum', true)","symbol":"baseUrl (options)","correct":"baseUrl({ url: '/forum', staticImports: true })"}],"quickstart":{"code":"// rollup.config.js\nimport { baseUrl } from 'rollup-plugin-base-url';\n\nexport default {\n  input: 'src/index.js',\n  output: {\n    dir: 'dist',\n    format: 'es',\n    entryFileNames: '[name]-[hash].js',\n    chunkFileNames: '[name]-[hash].js',\n  },\n  plugins: [\n    baseUrl({\n      url: '/',\n      staticImports: false,\n    }),\n  ],\n};","lang":"javascript","description":"Basic Rollup config using baseUrl plugin to serve dynamic imports from '/' root, preventing route-specific loading errors."},"warnings":[{"fix":"Avoid using file names or imports that contain patterns like './some-chunk-hash.js' in string literals or comments.","message":"Does not parse AST; uses naive string replacement of import paths. May incorrectly replace strings in comments, strings, or variable names that match the chunk pattern.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Ensure output.chunkFileNames uses the default '[name]-[hash].js' pattern, or adapt plugin logic.","message":"Only rewrites imports that match the exact output chunk pattern; non-standard chunk file names or custom hash functions may not be recognized.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"None needed.","message":"Version 0.0.2 is the only release; no breaking changes yet, but be aware of possible future changes.","severity":"breaking","affected_versions":"<0.0.2"},{"fix":"Consider migrating to a more maintained alternative if needed.","message":"Package is experimental and may be abandoned; no recent updates.","severity":"deprecated","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"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).","cause":"Using require('rollup-plugin-base-url') in a CommonJS context.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module"},{"fix":"Invoke baseUrl with a single options object: baseUrl({ url: '/forum', staticImports: true }).","cause":"Attempting to call baseUrl() with incorrect arguments, e.g., baseUrl('/forum', true) instead of baseUrl({url: '/forum', staticImports: true}).","error":"TypeError: (0 , _baseUrl.baseUrl) is not a function"},{"fix":"Check that output.chunkFileNames uses '[name]-[hash].js' pattern. If using static imports, set staticImports: true.","cause":"Plugin didn't rewrite the import path correctly, possibly because the chunk name doesn't match the expected pattern or staticImports is false but a static import is present.","error":"Error: Could not resolve import ... in file ..."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}