Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 11 additions & 25 deletions content/guides/migrating.md
Original file line number Diff line number Diff line change
@@ -618,35 +618,21 @@ Loaders are now cacheable by default. Loaders must opt-out if they are not cache

### Complex options

webpack 1 only supports `JSON.stringify`-able options for loaders.
webpack 2 now supports any JS object as loader options.
__webpack v1__ only supports `JSON.stringify`-able options for loaders.

Using complex options comes with one restriction. You may need to have a `ident` for the option object to make it referenceable by other loaders.
__webpack v2__ now supports any JS object as loader options.

Having an `ident` on the options object means to be able to reference this options object in inline loaders. Here is an example:
Before [v2.2.1](https://github.com/webpack/webpack/releases/tag/v2.2.1) (i.e. from v2.0.0 through v2.2.0), using complex options required using `ident` for the `options` object to allow its reference from other loaders. __This was removed in v2.2.1__ and thus current migrations do not require any use of the `ident` key.

`require("some-loader??by-ident!resource")`

``` js
```diff
{
test: /.../,
loader: "...",
options: {
ident: "by-ident",
magic: () => return Math.random()
test: /\.ext/
use: {
loader: '...',
options: {
- ident: 'id',
fn: () => require('./foo.js')
}
}
}
```

This inline style should not be used by regular code, but it's often used by loader generated code.
I. e. the `style-loader` generates a module that `require`s the remaining request (which exports the CSS).

``` js
// style-loader generated code (simplified)
var addStyle = require("./add-style");
var css = require("-!css-loader?{"modules":true}!postcss-loader??postcss-ident");

addStyle(css);
```

So if you use complex options tell your users about the `ident`.