Skip to content

Commit 3d33811

Browse files
Add a migration guide
1 parent fcd2b71 commit 3d33811

3 files changed

Lines changed: 76 additions & 1 deletion

File tree

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ or
2525
yarn add speed-measure-webpack-plugin
2626
```
2727

28+
## Migrating
29+
30+
SMP follows [semver](https://semver.org/). If upgrading a major version, you can consult [the migration guide](./migration.md).
31+
2832
## Usage
2933

3034
Change your webpack config from

migration.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Migration Guide
2+
3+
SMP follows [semver](https://semver.org/). This guide should help with upgrading major versions.
4+
5+
## v0 → v1
6+
7+
### If Using Static Constructor
8+
9+
If you're using the `SpeedMeasurePlugin.wrapPlugins(plugins, options)` static method, then
10+
11+
* remove all `.wrapPlugins` calls
12+
* instantiate an `smp`
13+
* call `smp.wrap` on your entire config
14+
15+
e.g.
16+
17+
```javascript
18+
// v0
19+
const webpackConfig = {
20+
plugins: SpeedMeasurePlugin.wrapPlugins({
21+
FooPlugin: new FooPlugin()
22+
}, smpOptions)
23+
};
24+
25+
// v1
26+
const smp = new SpeedMeasurePlugin(smpOptions);
27+
const webpackConfig = smp.wrap({
28+
plugins: [new FooPlugin()]
29+
});
30+
```
31+
32+
### If Using `smp` Instance
33+
34+
If you're using the `smp.wrapPlugins(plugins)` method, then
35+
36+
* remove all `.wrapPlugins` calls
37+
* call `smp.wrap` on your entire config
38+
39+
e.g.
40+
41+
```javascript
42+
// v0
43+
const smp = new SpeedMeasurePlugin(smpOptions);
44+
const webpackConfig = {
45+
plugins: smp.wrapPlugins({
46+
FooPlugin: new FooPlugin()
47+
})
48+
};
49+
50+
// v1
51+
const smp = new SpeedMeasurePlugin(smpOptions);
52+
const webpackConfig = smp.wrap({
53+
plugins: [new FooPlugin()]
54+
});
55+
```
56+
57+
### If Using Custom Names
58+
59+
v1 no longer requires you to manually enter each plugin name. If you want to keep any of your custom plugin names, then you can use the new `options.pluginNames` option:
60+
61+
```javascript
62+
const fooPlugin = new FooPlugin();
63+
const smp = new SpeedMeasurePlugin({
64+
pluginNames: {
65+
customFooPluginName: fooPlugin
66+
}
67+
});
68+
const webpackConfig = smp.wrap({
69+
plugins: [fooPlugin]
70+
});
71+
```

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "speed-measure-webpack-plugin",
3-
"version": "1.0.0-beta-0",
3+
"version": "1.0.0-beta-1",
44
"description": "Measure + analyse the speed of your webpack loaders and plugins",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)