{"id":21912,"library":"rollup-plugin-amd","title":"rollup-plugin-amd","description":"Rollup plugin that converts AMD modules (e.g., RequireJS) to ES2016 modules for bundling. Version 4.0.0 requires Node >=8 and Rollup 1.x+. It wraps the amd-to-es6 converter and provides include/exclude filtering and a rewire function to map AMD dependency IDs to file paths. Compared to manual conversion, it automates the transform within the Rollup build pipeline. Release cadence is low; last major update was in 2019.","status":"maintenance","version":"4.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/piuccio/rollup-plugin-amd","tags":["javascript","rollup","rollup-plugin","requirejs","amd"],"install":[{"cmd":"npm install rollup-plugin-amd","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-amd","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-amd","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency; plugin requires Rollup to function.","package":"rollup","optional":true}],"imports":[{"note":"ESM-only; the package does not export a CommonJS version. Use dynamic import if needed in CJS.","wrong":"const amd = require('rollup-plugin-amd')","symbol":"default (amd)","correct":"import amd from 'rollup-plugin-amd'"},{"note":"There is no named export; only a default export.","wrong":"import { amd } from 'rollup-plugin-amd'","symbol":"amd (named)","correct":"import amd from 'rollup-plugin-amd'"},{"note":"The plugin is a function, not a class. Do not use 'new'.","wrong":"new amd()","symbol":"Plugin as Rollup plugin","correct":"amd({ include: 'src/**', exclude: ['node_modules/**'] })"}],"quickstart":{"code":"import { rollup } from 'rollup';\nimport amd from 'rollup-plugin-amd';\n\nasync function build() {\n  const bundle = await rollup({\n    input: 'main.js',\n    plugins: [\n      amd({\n        include: 'src/**',\n        exclude: ['node_modules/**'],\n        rewire: (moduleId, parentPath) => {\n          // Map AMD module IDs to file paths\n          return './javascripts/' + moduleId;\n        }\n      })\n    ]\n  });\n  await bundle.write({ file: 'bundle.js', format: 'iife' });\n}\n\nbuild().catch(console.error);","lang":"javascript","description":"Shows basic usage: import the plugin, create a Rollup config, apply the plugin with include/exclude and a custom rewire function."},"warnings":[{"fix":"Consider using an alternative plugin that supports modern Rollup, or downgrade Rollup to 1.x.","message":"Pugin v4.0.0 only supports Rollup 1.x. May not work with Rollup 2+ or newer.","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Upgrade to v4.0.0 or later.","message":"The package uses the deprecated 'rollup.watch' in older versions.","severity":"deprecated","affected_versions":"<4.0.0"},{"fix":"Ensure the returned path is relative to the current file, not absolute.","message":"The 'rewire' function must return a relative path; otherwise imports may be resolved incorrectly.","severity":"gotcha","affected_versions":">=3.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run 'npm install --save-dev rollup-plugin-amd' and use import syntax.","cause":"Forgot to install the plugin or are using a CJS require in an ESM-only package.","error":"Error: Cannot find module 'rollup-plugin-amd'"},{"fix":"Ensure the file being transformed is a plain JavaScript file.","cause":"The plugin received a non-string file content, possibly due to a virtual file plugin conflict.","error":"The 'code' argument must be a string in amd-to-es6"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}