Rollup plugin (v1.1.0) that resolves dynamic imports containing variables at build time by converting concatenated strings into glob patterns and bundling matching files. Maintained by LarsDenBakker with infrequent releases. Key differentiator: enables dynamic imports with variable parts in Rollup, similar to webpack's dynamic import handling, without requiring complex configuration. Supports ESM and CJS. Alternatives include @rollup/plugin-dynamic-import-vars (official fork) which is more actively maintained.
npm install rollup-plugin-dynamic-import-variablesVerified import paths — ran on the pinned version, not inferred.
Configures Rollup to resolve dynamic imports with variables (e.g., `import('./locales/' + locale + '.js')`) by bundling matching files.
Prefix the dynamic import with a relative path, e.g., `import('./' + name + '.js')` instead of `import(name)`.Ensure the import string ends with a file extension (e.g., `.js`, `.mjs`). For example: `import('./' + name + '.js')`.Avoid multiple variables in the same directory segment; reorganize directory structure if deeper recursion is needed.
Use a more specific filename pattern, e.g., `import('./module-' + name + '.js')`.Replace 'rollup-plugin-dynamic-import-variables' with '@rollup/plugin-dynamic-import-vars' in your dependencies and import.
Check that the variable parts produce at least one valid file path. Adjust the import pattern or ensure the referenced files exist.
Prefix the import with a relative path starting with './' or '../'.
Add a file extension to the static part of the import string, e.g., `import('./' + name + '.js')`.Add a static prefix or suffix to the filename part, e.g., `import('./module-' + name + '.js')`.