Add getting webpack modules as properties of the WebpackModules object
`WebpackModules.React` instead of `WebpackModules.getModuleByName('React')`
This commit is contained in:
parent
8827bdb8b0
commit
8d8c1a8080
|
@ -437,7 +437,7 @@ export default class PluginApi {
|
|||
return WebpackModules.getModuleByPrototypes(props, false);
|
||||
}
|
||||
get WebpackModules() {
|
||||
return Object.defineProperty({
|
||||
return new Proxy({
|
||||
getModule: this.getWebpackModule.bind(this),
|
||||
getModuleByName: this.getWebpackModuleByName.bind(this),
|
||||
getModuleByDisplayName: this.getWebpackModuleByName.bind(this),
|
||||
|
@ -447,9 +447,12 @@ export default class PluginApi {
|
|||
getModuleByPrototypeFields: this.getWebpackModuleByPrototypeFields.bind(this),
|
||||
getModulesByProperties: this.getWebpackModulesByProperties.bind(this),
|
||||
getModulesByPrototypeFields: this.getWebpackModulesByPrototypeFields.bind(this),
|
||||
KnownModules: WebpackModules.KnownModules
|
||||
}, 'require', {
|
||||
get: () => this.webpackRequire
|
||||
get KnownModules() { return WebpackModules.KnownModules },
|
||||
get require() { return WebpackModules.require }
|
||||
}, {
|
||||
get(WebpackModules, property) {
|
||||
return WebpackModules[property] || WebpackModules.getModuleByName(property);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -179,7 +179,7 @@ const KnownModules = {
|
|||
ExternalLink: Filters.byCode(/\.trusted\b/)
|
||||
};
|
||||
|
||||
export class WebpackModules {
|
||||
class WebpackModules {
|
||||
|
||||
/**
|
||||
* Finds a module using a filter function.
|
||||
|
@ -303,3 +303,11 @@ export class WebpackModules {
|
|||
static get KnownModules() { return KnownModules }
|
||||
|
||||
}
|
||||
|
||||
const WebpackModulesProxy = new Proxy(WebpackModules, {
|
||||
get(WebpackModules, property) {
|
||||
return WebpackModules[property] || WebpackModules.getModuleByName(property);
|
||||
}
|
||||
});
|
||||
|
||||
export { WebpackModulesProxy as WebpackModules };
|
||||
|
|
Loading…
Reference in New Issue