Skip to content

Commit 1ca618f

Browse files
Merge branch 'master' into feature/loader-build-time-comparison
2 parents 3d31a6d + b5ff09e commit 1ca618f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+151224
-104138
lines changed

.all-contributorsrc

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
{
2+
"projectName": "speed-measure-webpack-plugin",
3+
"projectOwner": "stephencookdev",
4+
"repoType": "github",
5+
"repoHost": "https://github.com",
6+
"files": [
7+
"README.md"
8+
],
9+
"imageSize": 100,
10+
"commit": true,
11+
"commitConvention": "none",
12+
"badgeTemplate": "<a href=\"https://travis-ci.org/stephencookdev/speed-measure-webpack-plugin\"><img src=\"https://travis-ci.org/stephencookdev/speed-measure-webpack-plugin.svg?branch=master\" /></a> <a href=\"https://npmjs.com/package/speed-measure-webpack-plugin\"><img src=\"https://img.shields.io/npm/dw/speed-measure-webpack-plugin.svg\" /></a> <a href=\"https://npmjs.com/package/speed-measure-webpack-plugin\"><img src=\"https://img.shields.io/node/v/speed-measure-webpack-plugin.svg\" /></a> <a href=\"https://github.com/prettier/prettier\"><img src=\"https://img.shields.io/badge/code_style-prettier-ff69b4.svg\" /></a> <a href=\"#contributors\"><img src=\"https://img.shields.io/badge/all_contributors-<%= contributors.length %>-orange.svg\" /></a>",
13+
"contributors": [
14+
{
15+
"login": "stephencookdev",
16+
"name": "Stephen Cook",
17+
"avatar_url": "https://avatars.githubusercontent.com/u/8496655?v=4",
18+
"profile": "https://stephencookdev.co.uk/",
19+
"contributions": [
20+
"code",
21+
"doc",
22+
"blog",
23+
"design",
24+
"question",
25+
"review"
26+
]
27+
},
28+
{
29+
"login": "scarletsky",
30+
"name": "scarletsky",
31+
"avatar_url": "https://avatars.githubusercontent.com/u/2386165?v=4",
32+
"profile": "https://scarletsky.github.io/",
33+
"contributions": [
34+
"code"
35+
]
36+
},
37+
{
38+
"login": "wayou",
39+
"name": "牛さん",
40+
"avatar_url": "https://avatars.githubusercontent.com/u/3783096?v=4",
41+
"profile": "https://github.com/wayou",
42+
"contributions": [
43+
"code",
44+
"bug"
45+
]
46+
},
47+
{
48+
"login": "ThomasHarper",
49+
"name": "Thomas Bentkowski",
50+
"avatar_url": "https://avatars.githubusercontent.com/u/3199791?v=4",
51+
"profile": "https://github.com/ThomasHarper",
52+
"contributions": [
53+
"doc"
54+
]
55+
},
56+
{
57+
"login": "alan-agius4",
58+
"name": "Alan Agius",
59+
"avatar_url": "https://avatars.githubusercontent.com/u/17563226?v=4",
60+
"profile": "https://github.com/alan-agius4",
61+
"contributions": [
62+
"code",
63+
"bug"
64+
]
65+
},
66+
{
67+
"login": "NdYAG",
68+
"name": "Ximing",
69+
"avatar_url": "https://avatars.githubusercontent.com/u/1396511?v=4",
70+
"profile": "https://daix.me/",
71+
"contributions": [
72+
"code",
73+
"bug"
74+
]
75+
},
76+
{
77+
"login": "tanhauhau",
78+
"name": "Tan Li Hau",
79+
"avatar_url": "https://avatars.githubusercontent.com/u/2338632?v=4",
80+
"profile": "https://twitter.com/lihautan",
81+
"contributions": [
82+
"code",
83+
"bug",
84+
"test"
85+
]
86+
},
87+
{
88+
"login": "ZauberNerd",
89+
"name": "Björn Brauer",
90+
"avatar_url": "https://avatars.githubusercontent.com/u/249542?v=4",
91+
"profile": "https://github.com/ZauberNerd",
92+
"contributions": [
93+
"code",
94+
"bug"
95+
]
96+
}
97+
],
98+
"contributorsPerLine": 7
99+
}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules
22
lerna-debug.log
3+
npm-debug.log

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
12.20.0

.travis.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
language: node_js
2-
node_js:
3-
- "6"
42
script:
53
- npm run test
64
- npm run functional-test

README.md

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
<div><sup><em>(for webpack)</em></sup></div>
66
</h1>
77

8-
<a href="https://travis-ci.org/stephencookdev/speed-measure-webpack-plugin"><img src="https://travis-ci.org/stephencookdev/speed-measure-webpack-plugin.svg?branch=master" /></a>
9-
<a href="https://npmjs.com/package/speed-measure-webpack-plugin"><img src="https://img.shields.io/npm/dw/speed-measure-webpack-plugin.svg" /></a>
10-
<a href="https://npmjs.com/package/speed-measure-webpack-plugin"><img src="https://img.shields.io/node/v/speed-measure-webpack-plugin.svg" /></a>
11-
<a href="https://github.com/prettier/prettier"><img src="https://img.shields.io/badge/code_style-prettier-ff69b4.svg" /></a>
8+
<!-- ALL-CONTRIBUTORS-BADGE:START -->
9+
<a href="https://travis-ci.org/stephencookdev/speed-measure-webpack-plugin"><img src="https://travis-ci.org/stephencookdev/speed-measure-webpack-plugin.svg?branch=master" /></a> <a href="https://npmjs.com/package/speed-measure-webpack-plugin"><img src="https://img.shields.io/npm/dw/speed-measure-webpack-plugin.svg" /></a> <a href="https://npmjs.com/package/speed-measure-webpack-plugin"><img src="https://img.shields.io/node/v/speed-measure-webpack-plugin.svg" /></a> <a href="https://github.com/prettier/prettier"><img src="https://img.shields.io/badge/code_style-prettier-ff69b4.svg" /></a> <a href="#contributors"><img src="https://img.shields.io/badge/all_contributors-8-orange.svg" /></a>
10+
<!-- ALL-CONTRIBUTORS-BADGE:END -->
1211

1312
</div>
1413
<br>
@@ -120,6 +119,20 @@ const webpackConfig = smp.wrap({
120119
});
121120
```
122121

122+
### `options.loaderTopFiles`
123+
124+
Type: `Number`<br>
125+
Default: `0`
126+
127+
You can configure SMP to include the files that take the most time per loader, when using `outputFormat: 'humanVerbose'`. E.g., to show the top 10 files per loader:
128+
129+
```javascript
130+
const smp = new SpeedMeasurePlugin({
131+
outputFormat: "humanVerbose",
132+
loaderTopFiles: 10,
133+
});
134+
```
135+
123136
### `options.compareLoadersBuild`
124137

125138
Type: `Object`<br>
@@ -151,6 +164,16 @@ This flag is _experimental_. Some loaders will have inaccurate results:
151164

152165
We will find solutions to these issues before removing the _(experimental)_ flag on this option.
153166

167+
## FAQ
168+
169+
### What does general output time mean?
170+
171+
This tends to be down to webpack reading in from the file-system, but in general it's anything outside of what SMP can actually measure.
172+
173+
### What does modules without loaders mean?
174+
175+
It means vanilla JS files, which webpack can handle out of the box.
176+
154177
## Contributing
155178

156179
Contributors are welcome! 😊
@@ -164,3 +187,32 @@ SMP follows [semver](https://semver.org/). If upgrading a major version, you can
164187
## License
165188

166189
[MIT](/LICENSE)
190+
191+
## Contributors ✨
192+
193+
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
194+
195+
<!-- ALL-CONTRIBUTORS-LIST:START -->
196+
<!-- prettier-ignore-start -->
197+
<!-- markdownlint-disable -->
198+
<table>
199+
<tr>
200+
<td align="center"><a href="https://stephencookdev.co.uk/"><img src="https://avatars.githubusercontent.com/u/8496655?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Stephen Cook</b></sub></a><br /><a href="https://github.com/stephencookdev/speed-measure-webpack-plugin/commits?author=stephencookdev" title="Code">💻</a> <a href="https://github.com/stephencookdev/speed-measure-webpack-plugin/commits?author=stephencookdev" title="Documentation">📖</a> <a href="#blog-stephencookdev" title="Blogposts">📝</a> <a href="#design-stephencookdev" title="Design">🎨</a> <a href="#question-stephencookdev" title="Answering Questions">💬</a> <a href="https://github.com/stephencookdev/speed-measure-webpack-plugin/pulls?q=is%3Apr+reviewed-by%3Astephencookdev" title="Reviewed Pull Requests">👀</a></td>
201+
<td align="center"><a href="https://scarletsky.github.io/"><img src="https://avatars.githubusercontent.com/u/2386165?v=4?s=100" width="100px;" alt=""/><br /><sub><b>scarletsky</b></sub></a><br /><a href="https://github.com/stephencookdev/speed-measure-webpack-plugin/commits?author=scarletsky" title="Code">💻</a></td>
202+
<td align="center"><a href="https://github.com/wayou"><img src="https://avatars.githubusercontent.com/u/3783096?v=4?s=100" width="100px;" alt=""/><br /><sub><b>牛さん</b></sub></a><br /><a href="https://github.com/stephencookdev/speed-measure-webpack-plugin/commits?author=wayou" title="Code">💻</a> <a href="https://github.com/stephencookdev/speed-measure-webpack-plugin/issues?q=author%3Awayou" title="Bug reports">🐛</a></td>
203+
<td align="center"><a href="https://github.com/ThomasHarper"><img src="https://avatars.githubusercontent.com/u/3199791?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Thomas Bentkowski</b></sub></a><br /><a href="https://github.com/stephencookdev/speed-measure-webpack-plugin/commits?author=ThomasHarper" title="Documentation">📖</a></td>
204+
<td align="center"><a href="https://github.com/alan-agius4"><img src="https://avatars.githubusercontent.com/u/17563226?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Alan Agius</b></sub></a><br /><a href="https://github.com/stephencookdev/speed-measure-webpack-plugin/commits?author=alan-agius4" title="Code">💻</a> <a href="https://github.com/stephencookdev/speed-measure-webpack-plugin/issues?q=author%3Aalan-agius4" title="Bug reports">🐛</a></td>
205+
<td align="center"><a href="https://daix.me/"><img src="https://avatars.githubusercontent.com/u/1396511?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ximing</b></sub></a><br /><a href="https://github.com/stephencookdev/speed-measure-webpack-plugin/commits?author=NdYAG" title="Code">💻</a> <a href="https://github.com/stephencookdev/speed-measure-webpack-plugin/issues?q=author%3ANdYAG" title="Bug reports">🐛</a></td>
206+
<td align="center"><a href="https://twitter.com/lihautan"><img src="https://avatars.githubusercontent.com/u/2338632?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Tan Li Hau</b></sub></a><br /><a href="https://github.com/stephencookdev/speed-measure-webpack-plugin/commits?author=tanhauhau" title="Code">💻</a> <a href="https://github.com/stephencookdev/speed-measure-webpack-plugin/issues?q=author%3Atanhauhau" title="Bug reports">🐛</a> <a href="https://github.com/stephencookdev/speed-measure-webpack-plugin/commits?author=tanhauhau" title="Tests">⚠️</a></td>
207+
</tr>
208+
<tr>
209+
<td align="center"><a href="https://github.com/ZauberNerd"><img src="https://avatars.githubusercontent.com/u/249542?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Björn Brauer</b></sub></a><br /><a href="https://github.com/stephencookdev/speed-measure-webpack-plugin/commits?author=ZauberNerd" title="Code">💻</a> <a href="https://github.com/stephencookdev/speed-measure-webpack-plugin/issues?q=author%3AZauberNerd" title="Bug reports">🐛</a></td>
210+
</tr>
211+
</table>
212+
213+
<!-- markdownlint-restore -->
214+
<!-- prettier-ignore-end -->
215+
216+
<!-- ALL-CONTRIBUTORS-LIST:END -->
217+
218+
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!

WrappedPlugin/index.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ const wrapHooks = (orig, pluginName, smp, type) => {
125125
get: (target, property) => {
126126
const raw = Reflect.get(target, property);
127127

128+
if (Object.isFrozen(target)) {
129+
return raw;
130+
}
131+
128132
if (property === "tap" && typeof raw === "function")
129133
return wrapTap(raw, pluginName, smp, type, method).bind(proxy);
130134
if (property === "tapAsync" && typeof raw === "function")
@@ -164,12 +168,16 @@ const construcNamesToWrap = [
164168
];
165169

166170
const wrappedObjs = [];
167-
const wrap = (orig, pluginName, smp, addEndEvent) => {
168-
if (!orig) return orig;
171+
const findWrappedObj = (orig, pluginName) => {
169172
const prevWrapped = wrappedObjs.find(
170173
w => w.pluginName === pluginName && (w.orig === orig || w.wrapped === orig)
171174
);
172175
if (prevWrapped) return prevWrapped.wrapped;
176+
};
177+
const wrap = (orig, pluginName, smp, addEndEvent) => {
178+
if (!orig) return orig;
179+
const prevWrapped = findWrappedObj(orig, pluginName);
180+
if (prevWrapped) return prevWrapped;
173181

174182
const getOrigConstrucName = target =>
175183
target && target.constructor && target.constructor.name;
@@ -217,6 +225,13 @@ const wrap = (orig, pluginName, smp, addEndEvent) => {
217225
getOrigConstrucName(target)
218226
);
219227

228+
if (shouldWrap && property === "compiler") {
229+
const prevWrapped = findWrappedObj(raw, pluginName);
230+
if (prevWrapped) {
231+
return prevWrapped;
232+
}
233+
}
234+
220235
if (typeof raw === "function") {
221236
const ret = raw.bind(proxy);
222237
if (property === "constructor")

0 commit comments

Comments
 (0)