Skip to content

Commit

Permalink
Add -loader to every loader name
Browse files Browse the repository at this point in the history
Aligns with breaking change introduced with webpack/webpack#3102
See webpack/webpack#2986
  • Loading branch information
jhnns committed Oct 25, 2016
1 parent 2113601 commit ce140ca
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 81 deletions.
14 changes: 7 additions & 7 deletions antwar.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module.exports = {
'/': root(
function() {
return require.context(
'json!yaml-frontmatter!./content',
'json-loader!yaml-frontmatter-loader!./content',
false,
/^\.\/.*\.md$/
);
Expand All @@ -41,7 +41,7 @@ module.exports = {
'Concepts',
function() {
return require.context(
'json!yaml-frontmatter!./content/concepts',
'json-loader!yaml-frontmatter-loader!./content/concepts',
false,
/^\.\/.*\.md$/
);
Expand All @@ -51,7 +51,7 @@ module.exports = {
'Configuration',
function() {
return require.context(
'json!yaml-frontmatter!./content/configuration',
'json-loader!yaml-frontmatter-loader!./content/configuration',
false,
/^\.\/.*\.md$/
);
Expand All @@ -61,7 +61,7 @@ module.exports = {
'How to',
function() {
return require.context(
'json!yaml-frontmatter!./content/how-to',
'json-loader!yaml-frontmatter-loader!./content/how-to',
true,
/^\.\/.*\.md$/
);
Expand All @@ -71,7 +71,7 @@ module.exports = {
'API',
function() {
return require.context(
'json!yaml-frontmatter!./content/api',
'json-loader!yaml-frontmatter-loader!./content/api',
false,
/^\.\/.*\.md$/
);
Expand All @@ -81,7 +81,7 @@ module.exports = {
'Loaders',
function() {
return require.context(
'json!yaml-frontmatter!./generated/loaders',
'json-loader!yaml-frontmatter-loader!./generated/loaders',
false,
/^\.\/.*\.md$/
);
Expand All @@ -91,7 +91,7 @@ module.exports = {
'Plugins',
function() {
return require.context(
'json!yaml-frontmatter!./generated/plugins',
'json-loader!yaml-frontmatter-loader!./generated/plugins',
false,
/^\.\/.*\.md$/
);
Expand Down
1 change: 1 addition & 0 deletions content/concepts/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: Introduction
contributors:
- TheLarkInn
- jhnns
---

*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!
Expand Down
1 change: 1 addition & 0 deletions content/concepts/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ title: Plugins
sort: 3
contributors:
- TheLarkInn
- jhnns
---

**Plugins** are the [backbone](https://github.com/webpack/tapable) of webpack. webpack itself is built on the **same plugin system** that you use in your webpack configuration!!
Expand Down
5 changes: 3 additions & 2 deletions content/how-to/hot-module-reload.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: How to Configure Hot Module Replacement?
contributors:
- jmreidy
- jhnns
---

Hot Module Replacement (HMR) exchanges, adds, or removes modules while an
Expand Down Expand Up @@ -116,14 +117,14 @@ module.exports = env => {
loaders: [
{ test: /\.js$/,
loaders: [
'babel',
'babel-loader',
],
exclude: /node_modules/
},
{
test: /\.css$/,
loaders: [
'style',
'style-loader',
'css-loader?modules',
'postcss-loader',
],
Expand Down
5 changes: 3 additions & 2 deletions content/how-to/set-up-hmr-with-react.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: How to Set Up Hot Module Replacement with React?
contributors:
- jmreidy
- jhnns
---
Hot Module Replacement (HMR) exchanges, adds, or removes modules while an
application is running without a page reload.
Expand Down Expand Up @@ -110,14 +111,14 @@ module.exports = env => {
loaders: [
{ test: /\.js$/,
loaders: [
'babel',
'babel-loader',
],
exclude: /node_modules/
},
{
test: /\.css$/,
loaders: [
'style',
'style-loader',
'css-loader?modules',
'postcss-loader',
],
Expand Down
7 changes: 5 additions & 2 deletions content/how-to/shim.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
---
title: How to Shim Third Party Libraries?
contributors:
- pksjce
- jhnns
---

`webpack` as a module bundler can understand modules written as ES2015 modules, CommonJS or AMD. But many times, while using third party libraries, we see that they expect dependencies which are global aka `$` for `jquery`. They might also be creating global variables which need to be exported. Here we will see different ways to help webpack understand these __broken modules__.
Expand Down Expand Up @@ -48,7 +51,7 @@ module: {
loaders: [
{
test: /[\/\\]node_modules[\/\\]some-module[\/\\]index\.js$/,
loader: "imports?this=>window"
loader: "imports-loader?this=>window"
}
]
}
Expand Down Expand Up @@ -108,4 +111,4 @@ module: {
/[\/\\]node_modules[\/\\]angular[\/\\]angular\.js$/
]
}
```
```
128 changes: 72 additions & 56 deletions content/how-to/upgrade-from-webpack-1.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
title: How to Upgrade from Webpack 1?
contributors:
- sokra
- jhnns
---

### `resolve.root`, `resolve.fallback`, `resolve.modulesDirectories`
Expand All @@ -26,21 +27,65 @@ This option no longer requires passing an empty string. This behavior was moved

More stuff was changed here. Not listed in detail as it's not commonly used. See [resolving](/configuration/resolve) for details.

### `debug`
### `module.loaders` is now `module.rules`

The `debug` option switched loaders to debug mode in webpack 1. This need to be passed via loader options in long-term. See loader documentation for relevant options.
The old loader configuration was superseded by a more powerful rules system, which allows to configure loaders and more.
For compatibility reasons the old syntax is still valid and the old names are parsed.
The new naming is easier to understand to there are good reasons to upgrade the configuration.

The debug mode for loaders will be removed in webpack 3 or later.
``` diff
module: {
- loaders: [
+ rules: [
{
test: /\.css$/,
- loaders: [
+ use: [
{
loader: "style-loader"
},
{
loader: "css-loader",
- query: {
+ options: {
modules: true
}
]
}
]
}
```

To keep compatibility with old loaders, loaders can be switched to debug mode via plugin:
### Automatic `-loader` module name extension removed

It is not possible anymore to omit the `-loader` extension when referencing loaders:

``` diff
- debug: true,
plugins: [
+ new webpack.LoaderOptionsPlugin({
+ debug: true
+ })
]
loaders: [
- "style",
+ "style-loader",
- "css",
+ "css-loader",
- "less",
+ "less-loader",
]
```

See [#2986](https://github.com/webpack/webpack/issues/2986) for the reason behind this change.

### `module.preLoaders` and `module.postLoaders` was removed

``` diff
module: {
- preLoaders: [
+ rules: [
{
test: /\.js$/,
+ enforce: "pre",
loader: "eslint-loader"
}
]
}
```

### `UglifyJsPlugin` sourceMap
Expand Down Expand Up @@ -117,7 +162,7 @@ plugins: [
```


### full dynamic requires now fail by default
### Full dynamic requires now fail by default

A dependency with only an expression (i. e. `require(expr)`) will now create an empty context instead of an context of the complete directory.

Expand Down Expand Up @@ -157,64 +202,35 @@ See [CLI](../api/cli).

These functions are now always asynchronous instead of calling their callback sync if the chunk is already loaded.

### `module.loaders` is now `module.rules`

The old loader configuration was superseded by a more powerful rules system, which allows to configure loaders and more.
### `LoaderOptionsPlugin` context

For compatibility reasons the old syntax is still valid and the old names are parsed.
Some loaders need context information and read them from the configuration. This need to be passed via loader options in long-term. See loader documentation for relevant options.

The new naming is easier to understand to there are good reasons to upgrade the configuration.
To keep compatibility with old loaders, this information can be passed via plugin:

``` diff
module: {
- loaders: [
+ rules: [
{
test: /\.css$/,
- loaders: [
+ use: [
{
loader: "style-loader"
},
{
loader: "css-loader",
- query: {
+ options: {
modules: true
}
]
}
]
}
plugins: [
+ new webpack.LoaderOptionsPlugin({
+ options: {
+ context: __dirname
+ }
+ })
]
```

### `module.preLoaders` and `module.postLoaders` was removed

``` diff
module: {
- preLoaders: [
+ rules: [
{
test: /\.js$/,
+ enforce: "pre",
loader: "eslint-loader"
}
]
}
```
### `debug`

### `LoaderOptionPlugin` context
The `debug` option switched loaders to debug mode in webpack 1. This need to be passed via loader options in long-term. See loader documentation for relevant options.

Some loaders need context information and read them from the configuration. This need to be passed via loader options in long-term. See loader documentation for relevant options.
The debug mode for loaders will be removed in webpack 3 or later.

To keep compatibility with old loaders, this information can be passed via plugin:
To keep compatibility with old loaders, loaders can be switched to debug mode via plugin:

``` diff
- debug: true,
plugins: [
+ new webpack.LoaderOptionsPlugin({
+ options: {
+ context: __dirname
+ }
+ debug: true
+ })
]
```
Expand Down
Loading

0 comments on commit ce140ca

Please sign in to comment.