-
-
Notifications
You must be signed in to change notification settings - Fork 183
Deprecate cache parameter in favour of seed #57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report
@@ Coverage Diff @@
## master #57 +/- ##
==========================================
+ Coverage 89.28% 92.98% +3.69%
==========================================
Files 2 2
Lines 56 57 +1
==========================================
+ Hits 50 53 +3
+ Misses 6 4 -2
Continue to review full report at Codecov.
|
lib/plugin.js
Outdated
@@ -88,6 +90,9 @@ ManifestPlugin.prototype.apply = function(compiler) { | |||
}.bind(this), {}); | |||
} | |||
|
|||
// Add custom values last, so they don't get the basePath prefixed to them | |||
_.merge(manifest, initValue); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use manifest = _.assign({}, initValue, manifest)
@@ -214,6 +214,58 @@ describe('ManifestPlugin', function() { | |||
}); | |||
}); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a test to prove that initValue
is being overwritten
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm 👎 on this as a feature. This capability is already possible using cache
, which handles seeding a manifest with initial key value pairs. That would be the correct way to achieve this.
Admittedly, the readme docs only mention cache
in the context of multi-compiler architecture (which is a less common use case). I'd propose changing this PR to be documentation-only with the cache
article updated to denote: "A cache of key/value pairs to used to seed the manifest. This may include a set of custom key/value pairs to include in your manifest, or may be used to combine manifests across compilations in [multi-compiler mode]."
package.json
Outdated
@@ -1,6 +1,6 @@ | |||
{ | |||
"name": "webpack-manifest-plugin", | |||
"version": "1.1.2", | |||
"version": "1.1.4", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please leave the version as is :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, done
@gmac are you ok with those changes? |
spec/plugin.spec.js
Outdated
}); | ||
}); | ||
|
||
it('seed attributes do not get prefixed with basePath', function(done) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should go here with does something
style - does not prefix seed attributes with basePath
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice one, done.
spec/plugin.spec.js
Outdated
it('combines manifests of multiple compilations', function(done) { | ||
var seed = {}; | ||
webpackCompile([{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- do we need this
var
at all? - shouldn't we place a new line after
var
?
README.md
Outdated
@@ -52,4 +55,4 @@ new ManifestPlugin({ | |||
* `publicPath`: A path prefix used only on output files, similar to Webpack's [output.publicPath](https://github.com/webpack/docs/wiki/configuration#outputpublicpath). Ignored if `basePath` was also provided. | |||
* `stripSrc`: removes unwanted strings from source filenames (string or regexp) | |||
* `writeToFileEmit`: If set to `true` will emit to build folder and memory in combination with `webpack-dev-server` | |||
* `cache`: In [multi-compiler mode](https://github.com/webpack/webpack/tree/master/examples/multi-compiler) webpack will overwrite the manifest on each compilation. Passing a shared `{}` as the `cache` option into each compilation's ManifestPlugin will combine the manifest between compilations. | |||
* `seed`: A cache of key/value pairs to used to seed the manifest. This may include a set of [custom key/value](https://developer.mozilla.org/en-US/Add-ons/WebExtensions/manifest.json) pairs to include in your manifest, or may be used to combine manifests across compilations in [multi-compiler mode](https://github.com/webpack/webpack/tree/master/examples/multi-compiler). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add here the information how exactly it should be used in multi-compiler-mode?
Maybe I am missing something, but for me it is not really clear that I need to specify it as an empty object to do that - I cleared this out from tests, but who is going to read tests when he needs info?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about just adding: To combine manifests, pass a shared seed object to each compiler's plugin instance
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To combine manifests, pass a shared seed object to each compiler's plugin instance.
this can be somehow confusing for those not knowing how it all works under the hood - the first question will be what is compiler plugin instance?
I assume adding : just pass it as empty object: 'seed: {}'
before final .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find just pass it as empty object: 'seed: {}'
more confusing than helpful. It doesn't make that point that a shared singleton object must be passed to multiple plugin instances to combine their manifests. I amend my earlier text for clarity:
To combine manifests, pass a shared seed object to each compiler's ManifestPlugin instance.
If you're doing multi-compiler architecture, that should make sense. If you're not, you don't need the information anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding that extra bit of docs about a shared compiler instance would be helpful. Overall though, this looks good. 👍
README.md
Outdated
@@ -52,4 +55,4 @@ new ManifestPlugin({ | |||
* `publicPath`: A path prefix used only on output files, similar to Webpack's [output.publicPath](https://github.com/webpack/docs/wiki/configuration#outputpublicpath). Ignored if `basePath` was also provided. | |||
* `stripSrc`: removes unwanted strings from source filenames (string or regexp) | |||
* `writeToFileEmit`: If set to `true` will emit to build folder and memory in combination with `webpack-dev-server` | |||
* `cache`: In [multi-compiler mode](https://github.com/webpack/webpack/tree/master/examples/multi-compiler) webpack will overwrite the manifest on each compilation. Passing a shared `{}` as the `cache` option into each compilation's ManifestPlugin will combine the manifest between compilations. | |||
* `seed`: A cache of key/value pairs to used to seed the manifest. This may include a set of [custom key/value](https://developer.mozilla.org/en-US/Add-ons/WebExtensions/manifest.json) pairs to include in your manifest, or may be used to combine manifests across compilations in [multi-compiler mode](https://github.com/webpack/webpack/tree/master/examples/multi-compiler). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about just adding: To combine manifests, pass a shared seed object to each compiler's plugin instance
.
Thinking about further improvements here: is there a way to detect that we are in multi-compiler mode inside of a plugin and then switch to seeding mode? This would be really great and convenient - no need to specify seed as |
Sure, it's possible to detect multi-compiler mode... you just look at the number of compilers configured. Off the top of my head, I think that's managed by an array called This sounds like a potentially useful feature, although beyond the scope of this PR. There's definitely some nuances there that would need to be solved for. The way I'd see it working would be to pass an option like |
Thanks all. Updated the readme with @gmac's suggestion 👍🏼 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
👍 I will release that tonight |
Functionality for
cache
stays the same, the more generic name is better suited for when your app needs to set custom keys.requested in #55
closes #25