{"action":"created","issue":{"url":"https://api.github.com/repos/webpack/webpack/issues/965","labels_url":"https://api.github.com/repos/webpack/webpack/issues/965/labels{/name}","comments_url":"https://api.github.com/repos/webpack/webpack/issues/965/comments","events_url":"https://api.github.com/repos/webpack/webpack/issues/965/events","html_url":"https://github.com/webpack/webpack/issues/965","id":67486218,"number":965,"title":"Webpack fails to parse modules that use a json file as the index","user":{"login":"murphyrandle","id":1227109,"avatar_url":"https://avatars.githubusercontent.com/u/1227109?v=3","gravatar_id":"","url":"https://api.github.com/users/murphyrandle","html_url":"https://github.com/murphyrandle","followers_url":"https://api.github.com/users/murphyrandle/followers","following_url":"https://api.github.com/users/murphyrandle/following{/other_user}","gists_url":"https://api.github.com/users/murphyrandle/gists{/gist_id}","starred_url":"https://api.github.com/users/murphyrandle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/murphyrandle/subscriptions","organizations_url":"https://api.github.com/users/murphyrandle/orgs","repos_url":"https://api.github.com/users/murphyrandle/repos","events_url":"https://api.github.com/users/murphyrandle/events{/privacy}","received_events_url":"https://api.github.com/users/murphyrandle/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-04-10T01:38:23Z","updated_at":"2015-04-28T19:09:54Z","closed_at":"2015-04-10T08:21:11Z","body":"Hi there!\r\n\r\nWhen I `require` the module https://github.com/dfcreative/color-name, Webpack fails with the following error:\r\n\r\n```\r\nERROR in ./~/color-name/index.json\r\nModule parse failed: [redacted]/node_modules/color-name/index.json Line 2: Unexpected token :\r\nYou may need an appropriate loader to handle this file type.\r\n| {\r\n|   \"aliceblue\": [240, 248, 255],\r\n|   \"antiquewhite\": [250, 235, 215],\r\n|   \"aqua\": [0, 255, 255],\r\n @ ./app/client/index.jsx 17:8-29\r\n```\r\n\r\nAnd it's because the color-name module specifies `index.json` as the module entrypoint in its `package.json`.\r\n\r\nWhen I change the filename inside that module to `index.js` and modify it to use `module.exports = ...` everything works fine.\r\n\r\nI tried addding json-loader to my webpack config, but it looks like webpack expects only to find .js files when requiring something from `node_modules`.\r\n\r\nIt's strange that the color-name module uses a json file as its index, but Node supports it, so it seems like Webpack maybe should too?"},"comment":{"url":"https://api.github.com/repos/webpack/webpack/issues/comments/97172770","html_url":"https://github.com/webpack/webpack/issues/965#issuecomment-97172770","issue_url":"https://api.github.com/repos/webpack/webpack/issues/965","id":97172770,"user":{"login":"murphyrandle","id":1227109,"avatar_url":"https://avatars.githubusercontent.com/u/1227109?v=3","gravatar_id":"","url":"https://api.github.com/users/murphyrandle","html_url":"https://github.com/murphyrandle","followers_url":"https://api.github.com/users/murphyrandle/followers","following_url":"https://api.github.com/users/murphyrandle/following{/other_user}","gists_url":"https://api.github.com/users/murphyrandle/gists{/gist_id}","starred_url":"https://api.github.com/users/murphyrandle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/murphyrandle/subscriptions","organizations_url":"https://api.github.com/users/murphyrandle/orgs","repos_url":"https://api.github.com/users/murphyrandle/repos","events_url":"https://api.github.com/users/murphyrandle/events{/privacy}","received_events_url":"https://api.github.com/users/murphyrandle/received_events","type":"User","site_admin":false},"created_at":"2015-04-28T19:09:54Z","updated_at":"2015-04-28T19:09:54Z","body":"Sorry I've taken so long to get back, here's what my webpack config looks like:\r\n\r\n```\r\nvar path = require('path')\r\n\r\nmodule.exports = {\r\n  entry: \"./app/client/index.jsx\",\r\n  output: {\r\n    path: path.join(__dirname, 'app', 'static', 'generated'),\r\n    filename: 'bundle.js'\r\n  },\r\n\r\n  resolve: {\r\n    extensions: ['', '.js', '.jsx', 'index.js', 'index.jsx', '.json', 'index.json']\r\n  },\r\n\r\n  module: {\r\n    preLoaders: [\r\n        { test: /\\.json$/, exclude: /node_modules/, loader: 'json'},\r\n    ],\r\n    loaders: [\r\n        { test: /\\.js$/, exclude: /node_modules/, loader: 'babel'},\r\n        { test: /\\.jsx$/, exclude: /node_modules/, loader: 'babel'},\r\n        { test: /\\.css$/, exclude: /static/, loader: 'style!css'}\r\n    ]\r\n  },\r\n\r\n  devtool: '#eval'\r\n}\r\n```"}}