{"id":13774162,"url":"https://github.com/piuccio/rollup-plugin-amd","last_synced_at":"2025-04-14T02:31:26.956Z","repository":{"id":143906851,"uuid":"69481691","full_name":"piuccio/rollup-plugin-amd","owner":"piuccio","description":"Convert AMD files to ES2016 modules","archived":false,"fork":false,"pushed_at":"2022-12-02T04:21:12.000Z","size":22,"stargazers_count":23,"open_issues_count":3,"forks_count":11,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-08T16:24:50.125Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/piuccio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-09-28T16:19:48.000Z","updated_at":"2024-02-24T22:58:45.000Z","dependencies_parsed_at":"2023-05-02T18:33:22.399Z","dependency_job_id":null,"html_url":"https://github.com/piuccio/rollup-plugin-amd","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piuccio%2Frollup-plugin-amd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piuccio%2Frollup-plugin-amd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piuccio%2Frollup-plugin-amd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/piuccio%2Frollup-plugin-amd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/piuccio","download_url":"https://codeload.github.com/piuccio/rollup-plugin-amd/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248810883,"owners_count":21165195,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T17:01:24.276Z","updated_at":"2025-04-14T02:31:26.613Z","avatar_url":"https://github.com/piuccio.png","language":"JavaScript","funding_links":[],"categories":["Plugins"],"sub_categories":["Modules"],"readme":"# rollup-plugin-amd\n\nConvert AMD files to ES2016 modules, so they can be included in a Rollup bundle.\n\n## Installation\n\n`npm install --save-dev rollup-plugin-amd`\n\n## Usage\n\n```js\nimport { rollup } from 'rollup';\nimport amd from 'rollup-plugin-amd';\n\nrollup({\n    entry: 'main.js',\n    plugins: [\n        amd()\n    ]\n});\n```\n\nThe configuration above converts\n\n```js\ndefine(['utils/array', 'react'], function (array, React) {\n    React.render();\n});\n```\n\ninto\n\n```js\nimport array from './javascripts/utils/array';\nimport React from './node_modules/react/react.js';\n\nReact.render();\n```\n\n### Options\n\n```js\nimport { rollup } from 'rollup';\nimport amd from 'rollup-plugin-amd';\n\nrollup({\n    entry: 'main.js',\n    plugins: [\n        amd({\n            include: 'src/**', // Optional, Default: undefined (everything)\n            exclude: [ 'node_modules/**' ], // Optional, Default: undefined (nothing)\n            converter: {}, // Optional, Default: { sourceMap: true }\n            rewire: function (moduleId, parentPath) { // Optional, Default: false\n                return './basePath/' + moduleId;\n            }\n        })\n    ]\n});\n```\n\n* __converter__ options to pass down to the AMD to ES6 [converter](https://github.com/buxlabs/amd-to-es6#options).\n  - Please note that `converter` option is set to `{ sourceMap: true }` by default. If you want to disable sourcemap, you can set it as `{ sourceMap: false }`. However, this may bring some [sourcemap related issues](https://rollupjs.org/guide/en/#warning-sourcemap-is-likely-to-be-incorrect)\n  - Other options for converter can be passed down in the same way as we set the sourcemap\n    ```js\n    converter: {\n        sourceMap: true, // Default\n        someOtherOption: someOtherOptionValue\n        ...\n    }\n    ```\n\n* __rewire__ allows to modify the imported path of `define` dependencies.\n  - `moduleId` is the dependency ID\n  - `parentPath` is the path of the file including the dependency\n\n```js\ndefine(['lodash'], function (_) {});\n```\n\nbecomes\n\n```js\nimport _ from './basePath/lodash';\n```\n\nIf you're converting AMD modules from requirejs, you can use [node-module-lookup-amd](https://github.com/dependents/node-module-lookup-amd) to rewire your dependencies\n\n```js\nimport { rollup } from 'rollup';\nimport amd from 'rollup-plugin-amd';\nimport lookup from 'module-lookup-amd';\n\nrollup({\n    entry: 'main.js',\n    plugins: [\n        amd({\n            rewire: function (moduleId, parentPath) { // Optional, Default: false\n                return lookup({\n                    partial: moduleId,\n                    filename: parentPath,\n                    config: 'path-to-requirejs.config' // Or an object\n                });\n            }\n        })\n    ]\n});\n```\n\n## License\n\nApache-2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpiuccio%2Frollup-plugin-amd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpiuccio%2Frollup-plugin-amd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpiuccio%2Frollup-plugin-amd/lists"}