{"action":"created","issue":{"url":"https://api.github.com/repos/PrismJS/prism/issues/1422","repository_url":"https://api.github.com/repos/PrismJS/prism","labels_url":"https://api.github.com/repos/PrismJS/prism/issues/1422/labels{/name}","comments_url":"https://api.github.com/repos/PrismJS/prism/issues/1422/comments","events_url":"https://api.github.com/repos/PrismJS/prism/issues/1422/events","html_url":"https://github.com/PrismJS/prism/issues/1422","id":323184992,"number":1422,"title":"Big build files when using `loadLanguages` with webpack","user":{"login":"carbontwelve","id":464699,"avatar_url":"https://avatars2.githubusercontent.com/u/464699?v=4","gravatar_id":"","url":"https://api.github.com/users/carbontwelve","html_url":"https://github.com/carbontwelve","followers_url":"https://api.github.com/users/carbontwelve/followers","following_url":"https://api.github.com/users/carbontwelve/following{/other_user}","gists_url":"https://api.github.com/users/carbontwelve/gists{/gist_id}","starred_url":"https://api.github.com/users/carbontwelve/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/carbontwelve/subscriptions","organizations_url":"https://api.github.com/users/carbontwelve/orgs","repos_url":"https://api.github.com/users/carbontwelve/repos","events_url":"https://api.github.com/users/carbontwelve/events{/privacy}","received_events_url":"https://api.github.com/users/carbontwelve/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-05-15T11:55:19Z","updated_at":"2018-05-15T12:31:05Z","closed_at":"2018-05-15T12:31:05Z","author_association":"NONE","body":"There seems to be an issue with `require('prismjs/components/index.js')` that results in webpack importing all language files for prism and outputting a 530kB built file (or just over 1.5MB with map).\r\n\r\nThe following `app.js` will produce a build `app.min.js` weighing 36.7 kB:\r\n\r\n```javascript\r\nconst Prism = require('prismjs/components/prism-core');\r\nrequire('prismjs/plugins/toolbar/prism-toolbar.js');\r\nrequire('prismjs/plugins/show-language/prism-show-language.js');\r\nrequire('prismjs/plugins/line-numbers/prism-line-numbers.js');\r\n\r\nrequire('prismjs/components/prism-clike')\r\nrequire('prismjs/components/prism-markup')\r\nrequire('prismjs/components/prism-markup-templating')\r\nrequire('prismjs/components/prism-ini')\r\nrequire('prismjs/components/prism-bash')\r\nrequire('prismjs/components/prism-powershell')\r\nrequire('prismjs/components/prism-yaml')\r\nrequire('prismjs/components/prism-javascript')\r\nrequire('prismjs/components/prism-sql')\r\nrequire('prismjs/components/prism-twig')\r\nrequire('prismjs/components/prism-php')\r\nrequire('prismjs/components/prism-php-extras')\r\nrequire('prismjs/components/prism-markdown')\r\nrequire('prismjs/components/prism-basic')\r\nrequire('prismjs/components/prism-go')\r\n```\r\n\r\nHowever the following `app.js` will produce a `app.min.js` weighing 583 kB: \r\n\r\n```javascript\r\nconst Prism = require('prismjs/components/prism-core');\r\nrequire('prismjs/plugins/toolbar/prism-toolbar.js');\r\nrequire('prismjs/plugins/show-language/prism-show-language.js');\r\nrequire('prismjs/plugins/line-numbers/prism-line-numbers.js');\r\n\r\nconst loadLanguages = require('prismjs/components/index.js');\r\nloadLanguages(['ini', 'bash', 'powershell', 'yaml', 'javascript', 'sql', 'twig', 'php', 'php-extras', 'markdown', 'basic', 'go']);\r\n```\r\n\r\nThis is with using webpack 3.12.0 and the following `webpack.config.babel.js`:\r\n\r\n```javascript\r\nconst AutoPrefixCSSPlugin = require(\"less-plugin-autoprefix\");\r\nconst ExtractTextPlugin = require('extract-text-webpack-plugin');\r\nconst ManifestPlugin = require('webpack-manifest-plugin');\r\nconst ImageMinPlugin = require('imagemin-webpack-plugin').default;\r\nconst CopyWebpackPlugin = require('copy-webpack-plugin');\r\nconst CleanWebpackPlugin = require('clean-webpack-plugin');\r\n\r\nconst ExtractLESS = new ExtractTextPlugin('css/[name].[hash:8].css');\r\n\r\nmodule.exports = (env = {}) => {\r\n  if (!env.environment) {\r\n    env.environment = 'local'\r\n  }\r\n  const isProduction = env.environment === 'production';\r\n  console.log(env.environment);\r\n  console.log('isProdutaction: ', isProduction);\r\n\r\n  return {\r\n    entry: [\r\n      __dirname + \"/source/_assets/js/app.js\",\r\n      __dirname + \"/source/_assets/less/main.less\",\r\n    ],\r\n    output: {\r\n      path: __dirname + \"/source\",\r\n      filename: \"js/all.[hash:8].js\"\r\n    },\r\n    devtool: (() => {\r\n      if (isProduction) return false\r\n      else return 'cheap-module-eval-source-map'\r\n    })(),\r\n    module: {\r\n      rules: [\r\n        {\r\n          test: /\\.(html)$/,\r\n          use: {\r\n            loader: 'html-loader'\r\n          }\r\n        },\r\n        {\r\n          test: /\\.js$/,\r\n          exclude: /node_modules/,\r\n          use: {\r\n            loader: 'babel-loader',\r\n            options: {\r\n              presets: ['env']\r\n            }\r\n          }\r\n        },\r\n        {\r\n          test: /\\.less$/,\r\n          exclude: /node_modules/,\r\n          use: ExtractLESS.extract([\r\n            {\r\n              loader: 'css-loader',\r\n              options: {\r\n                sourceMap: true,\r\n                url: false\r\n              }\r\n            },\r\n            {\r\n              loader: 'less-loader',\r\n              options: {\r\n                plugins: [\r\n                  new AutoPrefixCSSPlugin({browsers: [\"last 2 versions\"]})\r\n                ],\r\n                sourceMap: true,\r\n              }\r\n            }\r\n          ])\r\n        },\r\n      ]\r\n    },\r\n    plugins: [\r\n      ExtractLESS,\r\n      new ManifestPlugin(),\r\n      new CopyWebpackPlugin([{\r\n        from: __dirname + \"/source/_assets/img/\",\r\n        to: __dirname + \"/source/img/\"\r\n      }]),\r\n      new ImageMinPlugin({\r\n        test: /\\.(jpe?g|png|gif|svg)$/i\r\n      }),\r\n      new CleanWebpackPlugin(['source/img', 'source/css', 'source/js']),\r\n    ]\r\n  };\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/PrismJS/prism/issues/comments/389149355","html_url":"https://github.com/PrismJS/prism/issues/1422#issuecomment-389149355","issue_url":"https://api.github.com/repos/PrismJS/prism/issues/1422","id":389149355,"user":{"login":"mAAdhaTTah","id":4371429,"avatar_url":"https://avatars0.githubusercontent.com/u/4371429?v=4","gravatar_id":"","url":"https://api.github.com/users/mAAdhaTTah","html_url":"https://github.com/mAAdhaTTah","followers_url":"https://api.github.com/users/mAAdhaTTah/followers","following_url":"https://api.github.com/users/mAAdhaTTah/following{/other_user}","gists_url":"https://api.github.com/users/mAAdhaTTah/gists{/gist_id}","starred_url":"https://api.github.com/users/mAAdhaTTah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mAAdhaTTah/subscriptions","organizations_url":"https://api.github.com/users/mAAdhaTTah/orgs","repos_url":"https://api.github.com/users/mAAdhaTTah/repos","events_url":"https://api.github.com/users/mAAdhaTTah/events{/privacy}","received_events_url":"https://api.github.com/users/mAAdhaTTah/received_events","type":"User","site_admin":false},"created_at":"2018-05-15T12:31:04Z","updated_at":"2018-05-15T12:31:04Z","author_association":"COLLABORATOR","body":"Duplicate of #1403. Will be solved by #1409."}}
{"actor":{"display_login":"mAAdhaTTah"}}