{"id":22083,"library":"rollup-plugin-inline-code","title":"rollup-plugin-inline-code","description":"A Rollup plugin that loads files as plain text strings, akin to Webpack's raw-loader, using a configurable import prefix (default 'inline!'). Version 1.2.7 is the current stable release, published via semantic-release with automated versioning. It supports Node.js 12–16 and works with JavaScript, TypeScript, SVG, and any text-based assets. The plugin integrates seamlessly into Rollup builds, enabling inline injection of file contents into generated bundles—a common pattern in server-side rendering or HTML template generation. Unlike similar plugins, it uses a distinctive import prefix syntax to differentiate inline imports from standard module imports.","status":"active","version":"1.2.7","language":"javascript","source_language":"en","source_url":"https://github.com/denisstasyev/rollup-plugin-inline-code","tags":["javascript","rollup","plugin","rollup-plugin","inline","insert","inline-code","insert-code","inline-javascript"],"install":[{"cmd":"npm install rollup-plugin-inline-code","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-inline-code","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-inline-code","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency, plugin requires Rollup to function.","package":"rollup","optional":false}],"imports":[{"note":"The package exports a single default function; named import is not supported.","wrong":"const inlineCode = require('rollup-plugin-inline-code')","symbol":"default export","correct":"import inlineCode from 'rollup-plugin-inline-code'"},{"note":"Must use the 'inline!' prefix in the import source to trigger the plugin.","wrong":"import content from './path/to/file.js'","symbol":"Imported file content","correct":"import content from 'inline!./path/to/file.js'"},{"note":"Required for TypeScript projects to avoid import errors. Place in a .d.ts file.","wrong":"declare module 'inline!*' { export = string; }","symbol":"TypeScript type declaration","correct":"declare module 'inline!*' { const inlineCode: string; export default inlineCode; }"}],"quickstart":{"code":"// rollup.config.js\nimport inlineCode from 'rollup-plugin-inline-code';\n\nexport default {\n  input: 'src/index.js',\n  output: {\n    file: 'dist/bundle.js',\n    format: 'iife'\n  },\n  plugins: [inlineCode()]\n};\n\n// src/index.js\nimport scriptContent from 'inline!./inline.js';\nconsole.log(scriptContent);\n\n// src/inline.js\n// This file will be read as text\nconst greeting = 'Hello from inline!';\n","lang":"typescript","description":"Shows basic Rollup setup with plugin and usage of the inline prefix to import a JavaScript file's raw content."},"warnings":[{"fix":"Always prepend the prefix to import sources intended for inlining.","message":"The plugin only transforms imports with the configured prefix (default 'inline!'). Regular imports are unaffected.","severity":"gotcha","affected_versions":"*"},{"fix":"Add a global module declaration: declare module 'inline!*' { const inlineCode: string; export default inlineCode; }","message":"TypeScript users must declare a module for 'inline!*' to avoid type errors.","severity":"gotcha","affected_versions":"*"},{"fix":"Use default import syntax: import x from 'inline!./file.js'","message":"The plugin returns a string, not a module; you cannot destructure or use named exports from the imported content.","severity":"gotcha","affected_versions":"*"},{"fix":"Check compatibility with your Rollup version; restrict to known working versions.","message":"Semver range for peer dependency rollup is not specified; may break with future Rollup major versions.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Ensure the plugin is added to the plugins array in rollup.config.js and that the import source starts with 'inline!'.","cause":"Rollup cannot resolve the module because the plugin is not properly configured or the prefix is missing.","error":"Error: Could not resolve 'inline!./path/to/file.js'"},{"fix":"Run 'npm install rollup-plugin-inline-code' and add a global module declaration for 'inline!*'.","cause":"Package is not installed or TypeScript type declarations are missing.","error":"Cannot find module 'rollup-plugin-inline-code' or its corresponding type declarations."},{"fix":"Add 'declare module \"inline!*\" { const inlineCode: string; export default inlineCode; }' to a .d.ts file.","cause":"TypeScript cannot resolve the module because the declaration is missing.","error":"TS2307: Cannot find module 'inline!./file.svg' or its corresponding type declarations."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}