Getting Started with Webpack 2
blog.madewithenvy.com
blog.madewithenvy.com
Now, the JS community seems to be thinking more about stability and backwards compatibility. That's very welcome, at least from the perspective of this grumpy server-side developer.
That's exactly why the blog post suggests using yarn instead of npm, isn't it?
As a front-end dev, to me it seems to be zipping along at the same, old faster-than-it-should pace it has for the past few years. Depends on perspective I guess.
Taking the mentality that "I can break everything and just bump the major number" will lead to a project that either 1) is no longer is used by many people or 2) is a maintenance hell because people are staying on old versions and asking for bug fixes and improvements.
There's still a little churn in the framework and state management world, but the existing options are more than good enough for years to come and nothing drastically different is popping up into the spotlight anymore.
I'd hate to loose all that, but I do see the advantages of Webpack. How much control do I have with Webpack though? Can I still write my own hooks?
By writing your own, you can hook into pretty much everything you could possibly want.
If you need to do something really wild and weird, the plugin and loader architecture will let you do pretty much anything and hook into nearly everything.
We're dealing with a legacy environment here and we have a suite of plugins and loaders to handle non-standard module types, deal with files pulled from CDN at build time, deal with legacy Rails-style script imports, plugins to do all sort of bundle validation, splitting, transforming...really anything goes.
"loaders" => "rules" etc.
http://javascriptplayground.com/blog/2016/10/moving-to-webpa...
Webpack now understands them without the need to convert them to commonjs/amd.
import works statically (before the JS is run), which allows webpack to make some optimizations.
(System.import() is used for dynamic (runtime) imports)
That is just one situation though.
However Rollup currently lacks a lot of features that make Webpack a good choice for large and complex apps.
You can get a feel for the code Rollup generates at http://rollupjs.org.
> it combines modules into a single scope, rather than wrapping them in functions and shipping a module loader with the bundle
I'm really interested, I got into JS development this year and have no idea of the internals of bundlers/packagers.
The way we're looking at it, you use rollup to pre-bundle libraries where you want all of the dependencies inline and use tree shaking to make those as small as possible. You then consume rollup's output from Webpack, thus making dev time builds much, much faster and the resulting output super small.
We are just around 90% completion (http://github.com/webpack/webpack.js.org/milestone/1)
After that we will release v2. Help always wanted! <3
WP 1's sourcemap doc is confusing as hell and WP 2's doc just copied that over. I imagine debugging un-transpiled code with sourcemap is one of the most common use-cases.
And I'm not alone if you look at the disqus of WP's doc[0] and a blog by @bebraw[1], one of the guys running webpack.js.org.
I even opened an issue[2], I hope it can make into your MVP.
[0]: http://survivejs.com/webpack/developing-with-webpack/enablin...
Maybe the author is trying to make Yarn a trend?
The JavaScript community makes me a cranky old man, because yarn is even a very good idea and solves actual problems. Still that was the point in the article where I thought "fucking JS hipsters". No time to play with tooling, when there is actual work to do.
Especially with other people in your team, whose time costs actual money, I think standardization of dev environments and tools trumps almost every new feature (as long as you were using tools in the first place).
I have seen the talk (I believe it was from Instagram), which showed how Webpack could work with shared code and so on, but still: Browserify and Gulp were already working (and I believe can now do the same thing) and even Gulp has only very marginal benefits over Grunt in my opinion. I would love to go a few steps further back, but "installable via npm" is just a crushing argument against Makefiles.
Browserify was nice for simple cases, but getting it to do what's needed in a large, real world application was really difficult. Lately it has a lot of those features, but when Webpack became popular, it just didn't.
I started using Webpack after doing a length cost/benefit analysis and settling on.....gulp + browserify, because WebPack looked too complicated and people in the team had experience with browserify. After a week of trying to get it to do what we needed, I tried WebPack again and did it in an afternoon. That's when we switched.
They were not wrong, but they do a general automation (and sometimes it's needed), just a task runners and a wrong thing was to use them for web building automation collection scattered over the internet stuff together into the complex framework. So every team or project had own framework, which means no standard, and that's a bad thing. Webpack allows to defined a needed behavior in a kind of declarative way since it has a structure.
You get dependency management (resolution, pruning) for free from Closure and declarative build targets from Bazel. (Including dependencies on other targets, e.g. non-module-bundle.js)
To be fair, I don't think the (publicly) available rule set grants parity with webpack, but the syntax is a lot less gross and the concepts have been there from the start.
(Re gross: Instantiation in a config file?)