{"id":22088,"library":"rollup-plugin-insert","title":"rollup-plugin-insert","description":"A Rollup plugin for string mutation operations on file contents: append, prepend, wrap, and custom transforms. Current stable version is 1.3.2 (last released March 2021). The plugin supports MagicString for source map-aware transformations, ships TypeScript types, and operates in maintenance mode with no recent activity. Key differentiators include separate importable functions, optional source map support, and file filtering via include/exclude patterns. Unlike general-purpose plugins like rollup-plugin-string, it focuses specifically on string insertion/wrapping transforms.","status":"maintenance","version":"1.3.2","language":"javascript","source_language":"en","source_url":"https://github.com/rx-ts/rollup","tags":["javascript","typescript"],"install":[{"cmd":"npm install rollup-plugin-insert","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-insert","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-insert","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency; the plugin requires Rollup's plugin API and MagicString","package":"rollup","optional":false}],"imports":[{"note":"append is a named export, not a default export.","wrong":"import append from 'rollup-plugin-insert'","symbol":"append","correct":"import { append } from 'rollup-plugin-insert'"},{"note":"CommonJS require() works but ESM with named import is recommended.","wrong":"const prepend = require('rollup-plugin-insert').prepend","symbol":"prepend","correct":"import { prepend } from 'rollup-plugin-insert'"},{"note":"wrap is a named export; no common wrong usage.","wrong":"","symbol":"wrap","correct":"import { wrap } from 'rollup-plugin-insert'"},{"note":"Default import exists but not recommended; use named imports for tree-shaking.","wrong":"import insert from 'rollup-plugin-insert'; const transform = insert.transform","symbol":"transform","correct":"import { transform } from 'rollup-plugin-insert'"}],"quickstart":{"code":"// rollup.config.js\nimport { append, prepend, wrap, transform } from 'rollup-plugin-insert';\n\nexport default {\n  input: 'src/main.js',\n  output: { file: 'dist/bundle.js', format: 'iife' },\n  plugins: [\n    append('\\n// Appended footer'),\n    prepend('// Prepended header\\n'),\n    wrap('/* start */', '/* end */'),\n    transform((magicString, code, id) => code.toUpperCase()),\n  ],\n};","lang":"javascript","description":"Shows usage of all four main functions (append, prepend, wrap, transform) in a Rollup config."},"warnings":[{"fix":"Always return a value from transform callback, e.g., code or magicString.toString()","message":"Transform callback must return a string or MagicString; returning undefined silently removes output.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Consider migrating to alternative plugins like rollup-plugin-string or @rollup/plugin-replace if using Rollup 4+.","message":"The plugin has not been updated since 2021; relies on older Rollup versions (<4).","severity":"deprecated","affected_versions":">=1.3.2"},{"fix":"Explicitly set { sourceMap: false } in the options object if not needed.","message":"Source map is enabled by default and may cause memory issues with large files.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use correct signature: append('string', { include: '**/*.txt' })","message":"Include/exclude patterns are not applied to the options object but as a separate argument.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.3.2':25 '2021':29 'activ':51 'append':15 'awar':38 'content':14 'current':21 'custom':19 'differenti':53 'file':13,63 'filter':64 'focus':79 'function':57 'general':70 'general-purpos':69 'import':56 'includ':54 'include/exclude':66 'insert':4 'insertion/wrapping':83 'javascript':85 'key':52 'last':26 'like':73 'magicstr':33 'mainten':46 'map':37,60 'map-awar':36 'march':28 'mode':47 'mutat':10 'oper':11,44 'option':58 'pattern':67 'plugin':3,7,31,72,76 'prepend':16 'purpos':71 'recent':50 'releas':27 'rollup':2,6,75 'rollup-plugin-insert':1 'rollup-plugin-str':74 'separ':55 'ship':40 'sourc':35,59 'specif':80 'stabl':22 'string':9,77,82 'support':32,61 'transform':20,39,84 'type':42 'typescript':41,86 'unlik':68 'version':23 'via':65 'wrap':17","created_at":"2026-04-27T17:03:19.763576+00:00","updated_at":"2026-04-27T17:03:19.763576+00:00","problems":[{"fix":"Use named imports: import { append } from 'rollup-plugin-insert'","cause":"Using default import instead of named import; default import is an object with methods.","error":"TypeError: insert.append is not a function"},{"fix":"Run npm install --save-dev rollup-plugin-insert","cause":"Plugin not installed or missing from dependencies.","error":"Error: Could not resolve 'rollup-plugin-insert'"},{"fix":"Use named import: import { transform } from 'rollup-plugin-insert'","cause":"Accessing .transform on the default export incorrectly.","error":"TypeError: Cannot read property 'transform' of undefined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/rx-ts/rollup","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/rollup-plugin-insert","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-18","next_check":"2026-07-26","install_tag":null}}