{"action":"created","issue":{"url":"https://api.github.com/repos/swagger-api/swagger-codegen/issues/3336","repository_url":"https://api.github.com/repos/swagger-api/swagger-codegen","labels_url":"https://api.github.com/repos/swagger-api/swagger-codegen/issues/3336/labels{/name}","comments_url":"https://api.github.com/repos/swagger-api/swagger-codegen/issues/3336/comments","events_url":"https://api.github.com/repos/swagger-api/swagger-codegen/issues/3336/events","html_url":"https://github.com/swagger-api/swagger-codegen/issues/3336","id":164827175,"number":3336,"title":"[Javascript] webpack fail with resolving AMD module","user":{"login":"sherdeadlock","id":6625010,"avatar_url":"https://avatars.githubusercontent.com/u/6625010?v=3","gravatar_id":"","url":"https://api.github.com/users/sherdeadlock","html_url":"https://github.com/sherdeadlock","followers_url":"https://api.github.com/users/sherdeadlock/followers","following_url":"https://api.github.com/users/sherdeadlock/following{/other_user}","gists_url":"https://api.github.com/users/sherdeadlock/gists{/gist_id}","starred_url":"https://api.github.com/users/sherdeadlock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sherdeadlock/subscriptions","organizations_url":"https://api.github.com/users/sherdeadlock/orgs","repos_url":"https://api.github.com/users/sherdeadlock/repos","events_url":"https://api.github.com/users/sherdeadlock/events{/privacy}","received_events_url":"https://api.github.com/users/sherdeadlock/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-07-11T12:38:55Z","updated_at":"2016-07-13T09:48:43Z","closed_at":"2016-07-12T17:56:56Z","body":"##### Description\r\n[My Test Repository](https://github.com/sherdeadlock/minimal-webpack-swagger)\r\n\r\nMy package link to a js codegen project.\r\nWhen webpack build a bundle, it fail with the `AMD define`.\r\nIf I change the AMD path to CommonJS path, it pass. (see FIXME)\r\n```js\r\nif (typeof define === 'function' && define.amd) {\r\n    // AMD. Register as an anonymous module.\r\n    define(['ApiClient', 'api/DefaultApi'], factory);\r\n   // FIXME define(['./ApiClient', './api/DefaultApi'], factory);\r\n} else if (typeof module === 'object' && module.exports) {\r\n    // CommonJS-like environments that support module.exports, like Node.\r\n    module.exports = factory(require('./ApiClient'), require('./api/DefaultApi'));\r\n}\r\n```\r\n\r\nError message:\r\n```\r\nERROR in ./packages/minimal/src/index.js\r\nModule not found: Error: Cannot resolve module 'ApiClient' in /Users/lin/git/swagger/webpack_minimal/packages/minimal/src\r\n @ ./packages/minimal/src/index.js 32:4-52\r\n```\r\n\r\nWhen it pass, ApiClient.js raise an another error.\r\n\r\n```js\r\n// fs.ReadStream in Node.js (but not in runtime like browserify)\r\nif (typeof window === 'undefined' &&\r\n    typeof require === 'function' &&\r\n    require('fs') &&\r\n    param instanceof require('fs').ReadStream) {\r\n  return true;\r\n}\r\n\r\n```\r\n\r\n```\r\nERROR in ./packages/minimal/src/ApiClient.js\r\nModule not found: Error: Cannot resolve module 'fs' in /Users/lin/git/swagger/webpack_minimal/packages/minimal/src\r\n @ ./packages/minimal/src/ApiClient.js 103:74-87 103:108-121\r\n```\r\n\r\n\r\n##### Swagger-codegen version\r\n\r\nmaster branch > 2.1.6\r\n\r\n##### Swagger declaration file content or url\r\n\r\n```yaml\r\nswagger: '2.0'\r\ninfo:\r\n  version: 1.0.0\r\n  title: Minimal API\r\npaths:\r\n  /:\r\n    get:\r\n      responses:\r\n        200:\r\n          description: OK\r\n```\r\n\r\n##### Command line used for generation\r\n\r\n```\r\njava -jar path/to/jar generate -i minimal.yaml -o packages/minimal -l javascript --additional-properties emitJSDoc=false,usePromises=true\r\n```\r\n\r\n##### Steps to reproduce\r\n\r\ngit clone https://github.com/sherdeadlock/minimal-webpack-swagger\r\ncd minimal-webpack-swagger\r\nnpm link packages/minimal\r\nnpm install\r\nnode server.js\r\n\r\n##### Related issues\r\n\r\n\r\n\r\n##### Suggest a Fix\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/swagger-api/swagger-codegen/issues/comments/232309065","html_url":"https://github.com/swagger-api/swagger-codegen/issues/3336#issuecomment-232309065","issue_url":"https://api.github.com/repos/swagger-api/swagger-codegen/issues/3336","id":232309065,"user":{"login":"wing328","id":934260,"avatar_url":"https://avatars.githubusercontent.com/u/934260?v=3","gravatar_id":"","url":"https://api.github.com/users/wing328","html_url":"https://github.com/wing328","followers_url":"https://api.github.com/users/wing328/followers","following_url":"https://api.github.com/users/wing328/following{/other_user}","gists_url":"https://api.github.com/users/wing328/gists{/gist_id}","starred_url":"https://api.github.com/users/wing328/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wing328/subscriptions","organizations_url":"https://api.github.com/users/wing328/orgs","repos_url":"https://api.github.com/users/wing328/repos","events_url":"https://api.github.com/users/wing328/events{/privacy}","received_events_url":"https://api.github.com/users/wing328/received_events","type":"User","site_admin":false},"created_at":"2016-07-13T09:48:43Z","updated_at":"2016-07-13T09:48:43Z","body":"@sherdeadlock thanks for reporting the issue and sharing the fix."}}
{"actor":{"display_login":"wing328"}}