Change plugin API WebpackModules

getModule[…] returns a module (first = true)
getModules[…] returns an array (first = false)
This commit is contained in:
Samuel Elliott 2018-04-01 23:17:33 +01:00
parent a0f60dddb2
commit 027ca8d639
No known key found for this signature in database
GPG Key ID: 8420C7CDE43DC4D6
1 changed files with 19 additions and 7 deletions

View File

@ -402,14 +402,23 @@ export default class PluginApi {
getWebpackModuleByName(name, fallback) { getWebpackModuleByName(name, fallback) {
return WebpackModules.getModuleByName(name, fallback); return WebpackModules.getModuleByName(name, fallback);
} }
getWebpackModuleByRegex(regex, first = true) { getWebpackModuleByRegex(regex) {
return WebpackModules.getModuleByRegex(regex, first); return WebpackModules.getModuleByRegex(regex, true);
} }
getWebpackModuleByProperties(props, first = true) { getWebpackModulesByRegex(regex) {
return WebpackModules.getModuleByProps(props, first); return WebpackModules.getModuleByRegex(regex, false);
} }
getWebpackModuleByPrototypeFields(props, first = true) { getWebpackModuleByProperties(...props) {
return WebpackModules.getModuleByPrototypes(props, first); return WebpackModules.getModuleByProps(props, true);
}
getWebpackModuleByPrototypeFields(...props) {
return WebpackModules.getModuleByPrototypes(props, true);
}
getWebpackModulesByProperties(...props) {
return WebpackModules.getModuleByProps(props, false);
}
getWebpackModulesByPrototypeFields(...props) {
return WebpackModules.getModuleByPrototypes(props, false);
} }
get WebpackModules() { get WebpackModules() {
return Object.defineProperty({ return Object.defineProperty({
@ -417,8 +426,11 @@ export default class PluginApi {
getModuleByName: this.getWebpackModuleByName.bind(this), getModuleByName: this.getWebpackModuleByName.bind(this),
getModuleByDisplayName: this.getWebpackModuleByName.bind(this), getModuleByDisplayName: this.getWebpackModuleByName.bind(this),
getModuleByRegex: this.getWebpackModuleByRegex.bind(this), getModuleByRegex: this.getWebpackModuleByRegex.bind(this),
getModulesByRegex: this.getWebpackModulesByRegex.bind(this),
getModuleByProperties: this.getWebpackModuleByProperties.bind(this), getModuleByProperties: this.getWebpackModuleByProperties.bind(this),
getModuleByPrototypeFields: this.getWebpackModuleByPrototypeFields.bind(this) getModuleByPrototypeFields: this.getWebpackModuleByPrototypeFields.bind(this),
getModulesByProperties: this.getWebpackModulesByProperties.bind(this),
getModulesByPrototypeFields: this.getWebpackModulesByPrototypeFields.bind(this)
}, 'require', { }, 'require', {
get: () => this.webpackRequire get: () => this.webpackRequire
}); });