{"action":"created","issue":{"url":"https://api.github.com/repos/babel/babel/issues/7657","repository_url":"https://api.github.com/repos/babel/babel","labels_url":"https://api.github.com/repos/babel/babel/issues/7657/labels{/name}","comments_url":"https://api.github.com/repos/babel/babel/issues/7657/comments","events_url":"https://api.github.com/repos/babel/babel/issues/7657/events","html_url":"https://github.com/babel/babel/issues/7657","id":310611531,"number":7657,"title":"[transform-modules-amd] Add option to add 'require' to amdArgs","user":{"login":"justinfagnani","id":522948,"avatar_url":"https://avatars0.githubusercontent.com/u/522948?v=4","gravatar_id":"","url":"https://api.github.com/users/justinfagnani","html_url":"https://github.com/justinfagnani","followers_url":"https://api.github.com/users/justinfagnani/followers","following_url":"https://api.github.com/users/justinfagnani/following{/other_user}","gists_url":"https://api.github.com/users/justinfagnani/gists{/gist_id}","starred_url":"https://api.github.com/users/justinfagnani/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justinfagnani/subscriptions","organizations_url":"https://api.github.com/users/justinfagnani/orgs","repos_url":"https://api.github.com/users/justinfagnani/repos","events_url":"https://api.github.com/users/justinfagnani/events{/privacy}","received_events_url":"https://api.github.com/users/justinfagnani/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-04-02T21:06:02Z","updated_at":"2018-04-02T21:13:06Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"Choose one: is this a bug report or feature request?: Feature request\r\n\r\nI'm writing a dynamic import transform for AMD, and while the transform is quite simple, it requires the AMD module definition to depend on the `\"require\"` module ID. There's no easy way to add AMD dependencies with the current transform.\r\n\r\nHere's the dynamic import transform for reference.\r\n\r\n```ts\r\nexport const dynamicImportAMD = {\r\n  inherits: dyanamicImportSyntax,\r\n  visitor: {\r\n    CallExpression(path: NodePath<CallExpression>) {\r\n      if (path.node.callee.type as string === 'Import') {\r\n        const specifier = path.node.arguments[0];\r\n        path.replaceWith(ast`(new Promise((res, rej) => require([${specifier}], res, rej)))`);\r\n      }\r\n    },\r\n  },\r\n};\r\n```\r\n\r\n### Possible Solution\r\nOne solution is to add an option for extra module IDs to add to `amdArgs`. Another is to implement dynamic import directly in the AMD transform.\r\n"},"comment":{"url":"https://api.github.com/repos/babel/babel/issues/comments/378048418","html_url":"https://github.com/babel/babel/issues/7657#issuecomment-378048418","issue_url":"https://api.github.com/repos/babel/babel/issues/7657","id":378048418,"user":{"login":"loganfsmyth","id":132260,"avatar_url":"https://avatars1.githubusercontent.com/u/132260?v=4","gravatar_id":"","url":"https://api.github.com/users/loganfsmyth","html_url":"https://github.com/loganfsmyth","followers_url":"https://api.github.com/users/loganfsmyth/followers","following_url":"https://api.github.com/users/loganfsmyth/following{/other_user}","gists_url":"https://api.github.com/users/loganfsmyth/gists{/gist_id}","starred_url":"https://api.github.com/users/loganfsmyth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/loganfsmyth/subscriptions","organizations_url":"https://api.github.com/users/loganfsmyth/orgs","repos_url":"https://api.github.com/users/loganfsmyth/repos","events_url":"https://api.github.com/users/loganfsmyth/events{/privacy}","received_events_url":"https://api.github.com/users/loganfsmyth/received_events","type":"User","site_admin":false},"created_at":"2018-04-02T21:13:06Z","updated_at":"2018-04-02T21:13:06Z","author_association":"OWNER","body":"Would it work to add `import require from \"require\"` to the ES6 file?"}}
{"actor":{"display_login":"loganfsmyth"}}