It’s finally here. And it’s beautiful.

🍾🚀 webpack 3: Official Release!! 🚀🍾

Scope Hoisting, “magic comments”, and more!

Sean T. Larkin
Jun 19, 2017 · 3 min read

After we released webpack v2, we made some promises to the community. We promised that we would deliver the features you voted for. Moreover, we promised to deliver them in a faster, more stable release cycle.

No more year-long betas, no breaking changes between release candidates. We promised to do you right by you, the community that makes webpack thrive.

The webpack team is proud to announce that today we have released webpack 3.0.0!!! You can download or upgrade to it today!!

npm install webpack@3.0.0 --save-dev

or with

yarn add webpack@3.0.0 --dev

Migrating from webpack 2 to 3, should involve no effort beyond running the upgrade commands in your terminal. We marked this as a Major change because of internal breaking changes that could affect some plugins.

So far we’ve seen 98% of users upgrade with no breaking functionality at all!!!

What’s new?

As we mentioned, we aimed to deliver the features that you voted for! Because of the overwhelming GitHub contributions, support from our backers and sponsors, we have been able to hit each one. 😍

Scope Hoisting is the flagship feature of webpack 3. One of webpack’s trade-offs when bundling was that each module in your bundle would be wrapped in individual function closures. These wrapper functions made it slower for your JavaScript to execute in the browser. In comparison, tools like Closure Compiler and RollupJS ‘hoist’ or concatenate the scope of all your modules into one closure and allow for your code to have a faster execution time in the browser.

As of today, with webpack 3, you can now add the following plugin to your configuration to enable scope hoisting:

module.exports = {  
plugins: [
new webpack.optimize.ModuleConcatenationPlugin()

Scope Hoisting is specifically a feature made possible by ECMAScript Module syntax. Because of this webpack may fallback to normal bundling based on what kind of modules you are using, and other conditions.

To stay informed on what triggers these fallbacks, we’ve added a --display-optimization-bailout cli flag that will tell you what caused the fallback.

Because scope hoisting will remove function wrappers around your modules, you may see some small size improvements. However, the significant improvement will be how fast the JavaScript loads in the browser. If you have awesome before and after comparisons, feel free to respond with some data as we’d be honored to share it!

When we introduced in webpack 2 the ability to use the dynamic import syntax ( import() ), users expressed their concerns that they could not create named chunks like they were able to with require.ensure.

We have now introduced what the community has coined “magic comments”, the ability to pass chunk name, and more as an inline comment to your import() statements.

By using comments, we are able to stay true to the load specification, and still give you the great chunk naming features you love.

Although these are technically features we released in v2.4 and v2.6, we worked to stabilize and fix bugs for these features that have landed in v3. This now allows the dynamic import syntax to have the same flexibility as require.ensure.

To learn more information, see our newest documentation guide on code-splitting that highlights these features!!!

😍 What’s next? 😍

We have quite a few features and enhancements that we are hoping to bring you!!! But to take control of the ones we should be working one, stop by our vote page, and upvote the features you would like to see!

Here are some of those things we are hoping to bring you still:

  • Better Build Caching
  • Faster initial and incremental builds
  • Better TypeScript experience
  • Revamped Long term caching
  • WASM Module Support
  • Improve User Experience

🙇Thank you 🙇

All of our users, contributors, documentation writers, bloggers, sponsors, backers, and maintainers are all shareholders in helping us ensure webpack is successful for years to come.

For this, we thank you all. It is not possible without you and we can’t wait to share what is in store for the future!!

No time to help contribute? Want to give back in other ways? Become a Backer or Sponsor to webpack by donating to our open collective. Open Collective not only helps support the Core Team, but also supports contributors who have spent significant time improving our organization on their free time! ❤


The official Medium publication for the webpack open source…

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store