Skip to content

Commit 590d5ab

Browse files
SpaceK33zTheLarkInn
authored andcommitted
Deploy (#397)
* Improve resolve docs * Fix typo * Add table text I just want to trigger a rebuild so the CLAbot works * More consistency But really CLAbot is buggy today... * Fixed small typo in get started guide * Fixes some typos in Get Started with Webpack Adds a missing comma in webpack.config.js code example and a word in 'Using webpack with npm' section. * Minor text fixes * Use double quotes in html for consistency * Feature/add version to sidebar (#395) * feat(sidebar): add version in desktop sidebar * feat(sidebar): update bottom margin * Update sidebar.jsx remove unused var * fix(sidebar): fix index pages missing from section and fix layout * Improve HMR docs (#389) * Improve HMR docs * Fix link * Add concept page for HMR * Small improvements Really I just want to trigger a rebuild because the clabot is not working. * More devtool docs (#375)
1 parent 7508a9c commit 590d5ab

File tree

15 files changed

+299
-427
lines changed

15 files changed

+299
-427
lines changed

components/sidebar-item/sidebar-item-style.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
margin: 0.5em 0 1em;
3535
}
3636

37+
&__version {
38+
margin-bottom: 10px;
39+
}
40+
3741
&__anchor {
3842
margin:0.25em 0;
3943

components/sidebar-mobile/sidebar-mobile-style.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,15 @@
6363
text-transform: uppercase;
6464
color: getColor(mine-shaft);
6565
margin: 1em 16px 0.25em;
66+
67+
&--block {
68+
display: block;
69+
}
70+
71+
&:active,
72+
&--active {
73+
color: getColor(malibu);
74+
}
6675
}
6776

6877
.sidebar-mobile__page {

components/sidebar-mobile/sidebar-mobile.jsx

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,29 @@ export default class SidebarMobile extends React.Component {
5858
* @return {array} - Markup containing sections and links
5959
*/
6060
_getSections() {
61-
return this.props.sections.map(section => (
62-
<div key={ section.url }>
63-
<h3 className='sidebar-mobile__section'>{ section.title }</h3>
64-
{ this._getPages(section.pages) }
65-
</div>
66-
));
61+
let pathname = '';
62+
63+
if (typeof window !== 'undefined') {
64+
pathname = window.location.pathname;
65+
}
66+
67+
return this.props.sections.map(section => {
68+
let active = pathname === section.url || pathname.includes(`/${section.url}`),
69+
absoluteUrl = `/${section.url}`;
70+
return (
71+
<div key={ absoluteUrl }>
72+
<Link
73+
className={ `sidebar-mobile__section sidebar-mobile__section--block ${active ? 'sidebar-mobile__section--active' : ''}` }
74+
key={ absoluteUrl }
75+
to={ absoluteUrl }
76+
onClick={ this._close.bind(this) }>
77+
<h3>{ section.title }</h3>
78+
</Link>
79+
80+
{ this._getPages(section.pages) }
81+
</div>
82+
);
83+
});
6784
}
6885

6986
/**

components/sidebar/sidebar.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ export default props => {
88
return (
99
<nav className="sidebar">
1010
<div className="sidebar__inner">
11+
<h3 className="sidebar-item__version">Version 2.1</h3>
1112
<SidebarItem
1213
url={ `/${sectionName}` }
1314
title="Introduction"
1415
currentPage= { currentPage }
1516
/>
16-
1717
{
1818
pages.map(({ url, title, anchors }, i) =>
1919
<SidebarItem
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
title: Hot Module Replacement
3+
sort: 11
4+
contributors:
5+
- SpaceK33z
6+
- sokra
7+
---
8+
9+
Hot Module Replacement (HMR) exchanges, adds, or removes modules while an
10+
application is running without a page reload. You basically can update changed modules without a full page reload.
11+
12+
## How Does It Work?
13+
14+
### From The App View
15+
16+
The app code asks the HMR runtime to check of updates. The HMR runtime downloads the updates (async) and tell the app code that an update is available. The app code asks the HMR runtime to apply updates. The HMR runtime applies the update (sync). The app code may or may not require user interaction in this process (you decide).
17+
18+
### From The Compiler (webpack) View
19+
20+
In addition to the normal assets the compiler need to emit the "Update" to allow updating from previous version to this version. The "Update" contains two parts:
21+
22+
1. the update manifest (JSON)
23+
2. one or multiple update chunks (JavaScript)
24+
25+
The manifest contains the new compilation hash and a list of all update chunks (2.).
26+
27+
The update chunks contains code for all updated modules in this chunk (or a flag if a module was removed).
28+
29+
The compiler addtionally makes sure that module and chunk ids as consistent between these builds. It uses a "records" json file to store them between builds (on it store them in memory).
30+
31+
### From The Module View
32+
33+
HMR is an opt-in feature, so it only affects modules that contains HMR code. The documentation describes the API that is available in modules. In general the module developer writes handlers that are called when a dependency of this module is updated. The developer can also write a handler that is called when this module is updated.
34+
35+
In most cases it's not mandatory to write HMR code in every module. If a module has no HMR handlers the update bubbles up. This means a single handler can handle a update to a complete module tree. If a single module in this tree is updated, the complete module tree is reloaded (only reloaded not transferred).
36+
37+
### From The HMR Runtime View (Technical)
38+
39+
For the module system runtime is additional code emitted to track module `parents` and `children`.
40+
41+
On the management side the runtime supports two methods: `check` and `apply`.
42+
43+
A `check` does a HTTP request to the update manifest. When this request fails, there is no update available. Elsewise the list of updated chunks is compared to the list of currently loaded chunks. For each loaded chunk the corresponding update chunk is downloaded. All module updates as stored in the runtime as update. The runtime switches into the `ready` state, meaning an update has been downloaded and is ready to be applied.
44+
45+
For each new chunk request in the ready state the update chunk is also downloaded.
46+
47+
The `apply` method flags all updated modules as invalid. For each invalid module there need to be a update handler in the module or update handlers in every parent. Else the invalid buddles up and mark all parents as invalid too. This process continues until no more "bubble up" occurs. If it bubbles up from an entry point the process fails.
48+
49+
Now all invalid modules are disposed (dispose handler) and unloaded. Then the current hash is updated and all "accept" handlers are called. The runtime switches back to the `idle` state and everything continues as normal.
50+
51+
## What can I do with it?
52+
53+
You can use it in development as LiveReload replacement. webpack-dev-server supports a hot mode which tries to update with HMR before trying to reload the whole page. See how to implement [HMR with React](/guides/hmr-react) for example.
54+
55+
Some loaders already generate modules that are hot-updateable. i.e. the `style-loader` can exchange the stylesheet. You don't need to do anything special.
56+
57+
webpack's power lies in its customizability, and there are *many* ways of configuring HMR given the needs of a particular project.

content/concepts/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ contributors:
77
- grgur
88
---
99

10-
*webpack* is a _module bundler_ for modern JavaScript applications. It is [incredibly configurable](/configuration), however, there are **4 Core Concepts** we feel you should understand before you get started!
10+
*webpack* is a _module bundler_ for modern JavaScript applications. It is [incredibly configurable](/configuration), however, there are **Four Core Concepts** we feel you should understand before you get started!
1111

1212
As part of your webpack learning journey, we wrote this document aimed to give you a **high-level** overview of these concepts, while still providing links to concept specific use-cases.
1313

content/configuration/devtool.md

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,16 @@ sort: 10
44
contributors:
55
- sokra
66
- skipjack
7+
- SpaceK33z
78
---
89

9-
?> Description...
10+
This option controls if and how Source Maps are generated.
1011

1112
## `devtool`
1213

13-
`string`
14+
`string` `false`
1415

15-
Choose a style of [source mapping](http://blog.teamtreehouse.com/introduction-source-maps) to enhance the debugging process. Be aware that the following options can affect build and rebuild speed dramatically...
16-
17-
`eval` - Each module is executed with `eval` and `//@ sourceURL`
18-
19-
`source-map` - A full SourceMap is emitted
20-
21-
`hidden-source-map` - Same as `source-map`, but doesn't add a reference comment to the bundle. Useful if you only want SourceMaps to map error stack traces from error reports, but don't want to expose your SourceMap for the browser development tools.
22-
23-
`inline-source-map` - A SourceMap is added as DataUrl to the bundle
24-
25-
`eval-source-map` - Each module is executed with `eval` and a SourceMap is added as DataUrl to the `eval`
26-
27-
`cheap-source-map` - A SourceMap without column-mappings ignoring loaded source maps
28-
29-
`cheap-module-source-map` - A SourceMap without column-mappings that simplifies loaded source maps to a single mapping per line
16+
Choose a style of [source mapping](http://blog.teamtreehouse.com/introduction-source-maps) to enhance the debugging process. These values can affect build and rebuild speed dramatically.
3017

3118
devtool | build | rebuild | production | quality
3219
------------------------------|-------|---------|------------|--------------------------
@@ -38,7 +25,36 @@ Choose a style of [source mapping](http://blog.teamtreehouse.com/introduction-so
3825
eval-source-map | -- | + | no | original source
3926
source-map | -- | -- | yes | original source
4027

28+
Some of these values are suited for development and some for production. For development you typically want very fast Source Maps at the cost of bundle size, but for production you want separate Source Maps that are accurate.
29+
30+
W> There are some issues with Source Maps in Chrome. [We need your help!](https://github.com/webpack/webpack/issues/3165).
31+
32+
### For development
33+
34+
`eval` - Each module is executed with `eval()` and `//@ sourceURL`. This is very fast. The main disadvantage is that it doesn't display line numbers correctly since it gets mapped to transpiled code instead of the original code.
35+
36+
`inline-source-map` - A SourceMap is added as DataUrl to the bundle.
37+
38+
`eval-source-map` - Each module is executed with `eval()` and a SourceMap is added as DataUrl to the `eval()`. Initially it is slow, but it provides fast rebuild speed and yields real files. Line numbers are correctly mapped since it gets mapped to the original code.
39+
40+
`cheap-module-eval-source-map` - Like `eval-source-map`, each module is executed with `eval()` and a SourceMap is added as DataUrl to the `eval()`. It is "cheap" because it doesn't have column mappings, it only maps line numbers.
41+
42+
### For production
43+
44+
`source-map` - A full SourceMap is emitted as a separate file. It adds a reference comment to the bundle so development tools know where to find it.
45+
46+
`hidden-source-map` - Same as `source-map`, but doesn't add a reference comment to the bundle. Useful if you only want SourceMaps to map error stack traces from error reports, but don't want to expose your SourceMap for the browser development tools.
47+
48+
`cheap-source-map` - A SourceMap without column-mappings ignoring loaded Source Maps.
49+
50+
`cheap-module-source-map` - A SourceMap without column-mappings that simplifies loaded Source Maps to a single mapping per line.
51+
52+
T> See [`output.sourceMapFilename`](/configuration/output#output-sourcemapfilename) to customize the filenames of generated Source Maps.
53+
54+
?> This page needs more information to make it easier for users to choose a good option.
4155

42-
T> See [`output.sourceMapFilename`](/configuration/output#output-sourcemapfilename) to customize the filenames of generated source maps.
56+
# References
4357

44-
?> This section is pretty much just copied over from existing docs... imo more background is needed on the different types of source mapping, maybe via links to external sites that discuss the different types of source maps in more detail.
58+
- [Enabling Sourcemaps](http://survivejs.com/webpack/developing-with-webpack/enabling-sourcemaps/)
59+
- [webpack devtool source map](http://cheng.logdown.com/posts/2016/03/25/679045
60+
)

content/configuration/other-options.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,19 @@ amd: {
2222

2323
?> I don't think this is very clear, at least not without a link pointing to what this might be used for.
2424

25+
2526
## `bail`
2627

2728
`boolean`
2829

29-
Fail out on the first error instead of tolerating it. By default webpack will log these errors in red in the terminal, as well as the browser console when using HMR, but continue bundling. Turning it on:
30+
Fail out on the first error instead of tolerating it. By default webpack will log these errors in red in the terminal, as well as the browser console when using HMR, but continue bundling. To enable it:
3031

3132
```js
3233
bail: true
3334
```
3435

35-
will force webpack to exit it's bundling process.
36+
This will force webpack to exit its bundling process.
3637

37-
W> Note that this will become the default behavior in webpack 2.x
3838

3939
## `cache`
4040

@@ -58,8 +58,10 @@ export default {
5858
```
5959

6060
W> Don't share the cache between calls with different options.
61+
6162
?> Elaborate on the warning and example - calls with different configuration options?
6263

64+
6365
## `debug`
6466

6567
`boolean`
@@ -80,6 +82,7 @@ Expose custom values into the loader context.
8082

8183
?> Add an example...
8284

85+
8386
## `profile`
8487

8588
`boolean`
@@ -88,18 +91,21 @@ Capture a "profile" of the application, including statistics and hints, which ca
8891

8992
T> Use the [StatsPlugin](https://www.npmjs.com/package/stats-webpack-plugin) for more control over the generated profile.
9093

94+
9195
## `recordsPath`
9296

9397
Description...
9498

9599
?> Add example and description as well as details on `recordsInputPath` and `recordsOutputPath`.
96100

101+
97102
## `recordsInputPath`
98103

99104
Description...
100105

101106
?> Add example and description as well as details on `recordsInputPath` and `recordsOutputPath`.
102107

108+
103109
## `recordsOutputPath`
104110

105111
Description...

0 commit comments

Comments
 (0)