laravel-mix
Version:
The power of webpack, distilled for the rest of us.
35 lines (30 loc) • 829 B
JavaScript
/** @typedef {import('../../types/component').ClassComponent} ClassComponent */
/** @typedef {import('../../types/component').FunctionalComponent} FunctionalComponent */
/**
* @param {string[]} names
* @param {FunctionalComponent} component
* @returns {ClassComponent}
*/
exports.createFunctionalComponent = function createFunctionalComponent(names, component) {
return class {
/** @type {any[]} */
args = [];
name() {
return names;
}
/**
*
* @param {...any} args
*/
register(...args) {
this.args = args;
}
/**
*
* @param {import('webpack').Configuration} config
*/
webpackConfig(config) {
component.call(this, config, ...this.args);
}
};
};