{"id":1989,"date":"2017-10-13T16:54:32","date_gmt":"2017-10-13T11:54:32","guid":{"rendered":"https:\/\/thedevcouple.com\/?p=1989"},"modified":"2017-10-13T17:27:38","modified_gmt":"2017-10-13T12:27:38","slug":"webpack-for-wordpress","status":"publish","type":"post","link":"https:\/\/thedevcouple.com\/webpack-for-wordpress\/","title":{"rendered":"Webpack Makes It to the WordPress Core as A JS Bundle Manager"},"content":{"rendered":"<p>In late 2014, to split JavaScript files into maintainable modules, <strong><a href=\"http:\/\/browserify.org\/\" rel=\"nofollow noopener\" target=\"_blank\">Browserify<\/a><\/strong> was introduced. Recently, WordPress is rapidly moving towards JavaScript.<\/p>\n<p>A significant part of Gutenberg is composed of JavaScript. So, it is quite obvious to take a step towards the latest bundle manager available for JavaScript.<\/p>\n<p>That&#8217;s why Adam Silverstein <a href=\"https:\/\/core.trac.wordpress.org\/ticket\/40894\" rel=\"nofollow noopener\" target=\"_blank\">proposed<\/a> to replace Browserify with <strong><a href=\"https:\/\/webpack.js.org\/\" rel=\"nofollow noopener\" target=\"_blank\">Webpack<\/a><\/strong> four months ago.<\/p>\n<div class=\"eckosc eckosc_full_width_block\">\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-2009\" src=\"https:\/\/thedevcouple.com\/wp-content\/uploads\/2017\/10\/Webpack-for-WordPress.jpg\" alt=\"\" width=\"1280\" height=\"721\" srcset=\"https:\/\/thedevcouple.com\/wp-content\/uploads\/2017\/10\/Webpack-for-WordPress.jpg 1280w, https:\/\/thedevcouple.com\/wp-content\/uploads\/2017\/10\/Webpack-for-WordPress-300x169.jpg 300w, https:\/\/thedevcouple.com\/wp-content\/uploads\/2017\/10\/Webpack-for-WordPress-768x433.jpg 768w, https:\/\/thedevcouple.com\/wp-content\/uploads\/2017\/10\/Webpack-for-WordPress-1024x577.jpg 1024w, https:\/\/thedevcouple.com\/wp-content\/uploads\/2017\/10\/Webpack-for-WordPress-1240x698.jpg 1240w, https:\/\/thedevcouple.com\/wp-content\/uploads\/2017\/10\/Webpack-for-WordPress-860x484.jpg 860w, https:\/\/thedevcouple.com\/wp-content\/uploads\/2017\/10\/Webpack-for-WordPress-680x383.jpg 680w, https:\/\/thedevcouple.com\/wp-content\/uploads\/2017\/10\/Webpack-for-WordPress-500x282.jpg 500w, https:\/\/thedevcouple.com\/wp-content\/uploads\/2017\/10\/Webpack-for-WordPress-400x225.jpg 400w, https:\/\/thedevcouple.com\/wp-content\/uploads\/2017\/10\/Webpack-for-WordPress-200x113.jpg 200w, https:\/\/thedevcouple.com\/wp-content\/uploads\/2017\/10\/Webpack-for-WordPress-50x28.jpg 50w\" sizes=\"(max-width: 1280px) 100vw, 1280px\"><\/p>\n<\/div>\n<blockquote class=\"eckosc eckosc_quote eckosc_quote_blockquote\"><p> While Browserify has served us well, Webpack is probably a better long-term choice for the project, especially with the introduction of a new JavaScript framework that may require a build.<\/p> <a href=\"https:\/\/core.trac.wordpress.org\/ticket\/40894\" rel=\"nofollow noopener\" target=\"_blank\"><cite>\u2014 Use Webpack instead of Browserify for build process<\/cite><\/a><\/blockquote>\n<p>WordPress contributors made this decision four months ago. They even <a href=\"https:\/\/core.trac.wordpress.org\/ticket\/40894#comment:14\" rel=\"nofollow noopener\" target=\"_blank\">reached out to the contributors of Webpack<\/a> for their review.<\/p>\n<blockquote><p>\ud83c\udfc6 After four months of hard work, the ticket <a href=\"https:\/\/core.trac.wordpress.org\/ticket\/40894#comment:44\" rel=\"nofollow noopener\" target=\"_blank\">finally made it to WordPress core on October 4th, 2017<\/a>.<\/p><\/blockquote>\n<p>\ud83c\udf89\u00a0Kudos to the contributors who made it all possible.<\/p>\n<h2>\ud83e\udd14\u00a0What is a Bundle Manager?<\/h2>\n<p>To put in simple words, a bundle manager lets you use all of your project dependencies in the browser. It can also perform some other tasks like <strong>minifying<\/strong>, <strong>linting<\/strong>, <strong>testing<\/strong>, etc. Browserify and Webpack are the names of bundle\u00a0managers for JavaScript.<\/p>\n<blockquote><p>WordPress used to have Browserify to maintain its JS components. Webpack replaced it last week.<\/p><\/blockquote>\n<p>Here are some of the qualities of Webpack which made it a more natural choice.<\/p>\n<h2>\u2714\ufe0e Pros of Using Webpack<\/h2>\n<ul>\n<li>Webpack is easy to implement.<\/li>\n<li>Webpack does not require automation scripts like Gulp or Grunt.<\/li>\n<li>It has a single configuration file for the entire build process.<\/li>\n<li>Webpack provides automation tasks like minification out of the box.<\/li>\n<li>It also supports live\u00a0reloading.<\/li>\n<li>And it does all of these tasks without requiring help from the outside scripts.<\/li>\n<\/ul>\n<p>It is imminent that a <a href=\"https:\/\/make.wordpress.org\/core\/2017\/09\/27\/javascript-chat-summary-for-sept-26th\/\" rel=\"nofollow noopener\" target=\"_blank\">JavaScript framework might land in WordPress core<\/a>.\u00a0So, Webpack looks like a smart choice to have around when that happens.<\/p>\n<p>Do you think it was a smart decision? Let us know in the comments.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In late 2014, to split JavaScript files into maintainable modules, Browserify was introduced. Recently, WordPress is rapidly moving towards JavaScript. A significant part of Gutenberg is composed of JavaScript. So, it is quite obvious to take a step towards the latest bundle manager available for JavaScript. That&#8217;s why Adam Silverstein proposed to replace Browserify with [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":2011,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":""},"categories":[6],"tags":[],"coauthors":[],"jetpack_featured_media_url":"https:\/\/thedevcouple.com\/wp-content\/uploads\/2017\/10\/Webpack-WordPress-2.jpg","amp_enabled":true,"_links":{"self":[{"href":"https:\/\/thedevcouple.com\/api\/wp\/v2\/posts\/1989"}],"collection":[{"href":"https:\/\/thedevcouple.com\/api\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thedevcouple.com\/api\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thedevcouple.com\/api\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/thedevcouple.com\/api\/wp\/v2\/comments?post=1989"}],"version-history":[{"count":0,"href":"https:\/\/thedevcouple.com\/api\/wp\/v2\/posts\/1989\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/thedevcouple.com\/api\/wp\/v2\/media\/2011"}],"wp:attachment":[{"href":"https:\/\/thedevcouple.com\/api\/wp\/v2\/media?parent=1989"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thedevcouple.com\/api\/wp\/v2\/categories?post=1989"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thedevcouple.com\/api\/wp\/v2\/tags?post=1989"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/thedevcouple.com\/api\/wp\/v2\/coauthors?post=1989"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}