Webpack 2 Deep Dive Explicit Dependencies
This course has been updated! We now recommend you take the Webpack 4 Fundamentals course.
Transcript from the "Explicit Dependencies" Lesson
>> Kent C Dodds: Yeah, and we're actually gonna skip past this one too, because I think it's also pretty straightforward. Again, this is all in the spirit of iterating slowly, like working our way into Webpack world. Because even with the way the we had it, it's still not technically explicit dependencies.
[00:00:22] We need to like, we're acquiring this file but it's just tacking stuff onto the window dot app. So we want to instead require specific things from those different modules and then from each one of these modules we want to export specific things. Here we're using a CommonJS. I start with CommonJS because I feel like most of you are probably more familiar with CommonJS than you are with your six modules.
[00:00:48] We'll move on to modules a little bit later. But yeah, that's the basic idea of what we're doing in this step, is making the exports explicit as well as the imports of the require statements explicit. And the cool thing about that is now if, let's say that in this helpers file or inside of app.js we require helpers.
[00:01:15] But we somehow we don't end up using helpers in this file at all, then we know that we don't not only do not need to require it in this file, but maybe we don't need that file in our project at all. We can get rid of it. So that's having explicit dependencies solves a lot of problems.
[00:01:32] Just kind of out of the box for us.