{"id":22076,"library":"rollup-plugin-import-folder","title":"rollup-plugin-import-folder","description":"A Rollup plugin that resolves imports using folder names instead of explicit file paths. It transforms import statements like `import './hello-world'` into `import './hello-world/hello-world.js'`, making modular component-based projects easier to manage by eliminating the need for index.js files. Version 1.0.6 is stable and maintained, supporting Rollup versions 1.x through 4.x. It is published on npm and aimed at developers using bundlers for JavaScript or TypeScript projects. The plugin ships with TypeScript definitions and is configured with include/exclude options. It is a lightweight utility solution for teams organizing components in folders.","status":"active","version":"1.0.6","language":"javascript","source_language":"en","source_url":"https://github.com/jleeson/rollup-plugin-import-folder","tags":["javascript","rollup","rollup-plugin","folder","import","typescript"],"install":[{"cmd":"npm install rollup-plugin-import-folder","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-import-folder","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-import-folder","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency required for Rollup plugin integration","package":"rollup","optional":false}],"imports":[{"note":"Default export; CommonJS require works but ESM is recommended since Node >=16. Package ships types.","wrong":"const folder = require('rollup-plugin-import-folder')","symbol":"default","correct":"import folder from 'rollup-plugin-import-folder'"},{"note":"Named import 'folder' is incorrect; only default export exists.","wrong":"import { folder } from 'rollup-plugin-import-folder'","symbol":"folder","correct":"import folder from 'rollup-plugin-import-folder'"},{"note":"Plugin type is imported from Rollup, not this package. This package types are inferred.","wrong":"import { Plugin } from 'rollup-plugin-import-folder'","symbol":"Plugin","correct":"import type { Plugin } from 'rollup'"}],"quickstart":{"code":"// rollup.config.js\nimport folder from 'rollup-plugin-import-folder';\n\nexport default {\n  input: 'src/index.js',\n  output: {\n    file: 'dist/bundle.js',\n    format: 'esm'\n  },\n  plugins: [folder()]\n};\n\n// src/index.js\nimport './hello-world'; // resolves to ./hello-world/hello-world.js\n\n// src/hello-world/hello-world.js\nexport const message = 'Hello World!';","lang":"javascript","description":"Basic usage showing how to import and configure the plugin in a Rollup config, along with an example of how folder imports are resolved."},"warnings":[{"fix":"Remove include/exclude options; they are no longer needed as the plugin always resolves folder imports.","message":"Plugin options `include` and `exclude` are deprecated since v1.0.5","severity":"deprecated","affected_versions":">=1.0.5"},{"fix":"Verify folder name and import path casing, especially on Linux/macOS.","message":"Import path must match folder name exactly; case-sensitive on some file systems","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use static imports for folder resolution; dynamic imports will remain unchanged.","message":"Plugin does not support dynamic imports (import())","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure that files inside folders have .js or .mjs extensions, or use @rollup/plugin-typescript or @rollup/plugin-babel for other extensions.","message":"Resolves only .js and .mjs files; other extensions like .ts or .jsx are ignored unless configured via Rollup's resolve plugin","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Absolute imports or bare specifiers are not processed; use relative paths for folder resolution.","message":"Plugin works only with relative imports starting with './' or '../'","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":"Create src/hello-world/hello-world.js with a default or named export, or check the folder name spelling.","cause":"Folder does not contain a file named hello-world.js or the import path is incorrect.","error":"Error: Could not resolve './hello-world' from src/index.js"},{"fix":"Use `import folder from 'rollup-plugin-import-folder'` (default import).","cause":"The plugin is imported incorrectly (e.g., using named import instead of default).","error":"TypeError: folder is not a function"},{"fix":"Update rollup-plugin-import-folder to latest version (>=1.0.6) or use older Rollup (<4).","cause":"Plugin version incompatible with Rollup v4; plugin uses dynamic require which is not allowed.","error":"[!] (plugin rpt2) RollupError: Could not resolve entry module"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}