
Security News
Feross on TBPN: How North Korea Hijacked Axios
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.
rollup-plugin-amd
Advanced tools
Convert AMD files to ES2016 modules, so they can be included in a Rollup bundle.
npm install --save-dev rollup-plugin-amd
import { rollup } from 'rollup';
import amd from 'rollup-plugin-amd';
rollup({
entry: 'main.js',
plugins: [
amd()
]
});
The configuration above converts
define(['utils/array', 'react'], function (array, React) {
React.render();
});
into
import array from './javascripts/utils/array';
import React from './node_modules/react/react.js';
React.render();
import { rollup } from 'rollup';
import amd from 'rollup-plugin-amd';
rollup({
entry: 'main.js',
plugins: [
amd({
include: 'src/**', // Optional, Default: undefined (everything)
exclude: [ 'node_modules/**' ], // Optional, Default: undefined (nothing)
converter: {}, // Optional, Default: undefined
rewire: function (moduleId, parentPath) { // Optional, Default: false
return './basePath/' + moduleId;
}
})
]
});
converter options to pass down to the AMD to ES6 converter.
rewire allows to modify the imported path of define dependencies.
moduleId is the dependency IDparentPath is the path of the file including the dependencydefine(['lodash'], function (_) {});
becomes
import _ from './basePath/lodash';
If you're converting AMD modules from requirejs, you can use node-module-lookup-amd to rewire your dependencies
import { rollup } from 'rollup';
import amd from 'rollup-plugin-amd';
import lookup from 'module-lookup-amd';
rollup({
entry: 'main.js',
plugins: [
amd({
rewire: function (moduleId, parentPath) { // Optional, Default: false
return lookup({
partial: moduleId,
filename: parentPath,
config: 'path-to-requirejs.config' // Or an object
});
}
})
]
});
Apache-2.0
FAQs
Convert AMD files to ES2016 modules
The npm package rollup-plugin-amd receives a total of 2,925 weekly downloads. As such, rollup-plugin-amd popularity was classified as popular.
We found that rollup-plugin-amd demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.

Security News
OpenSSF has issued a high-severity advisory warning open source developers of an active Slack-based campaign using impersonation to deliver malware.

Research
/Security News
Malicious packages published to npm, PyPI, Go Modules, crates.io, and Packagist impersonate developer tooling to fetch staged malware, steal credentials and wallets, and enable remote access.