You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
930 B

2 years ago
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. Object.defineProperty(exports, "default", {
  6. enumerable: true,
  7. get: ()=>_default
  8. });
  9. function createPlugin(plugin, config) {
  10. return {
  11. handler: plugin,
  12. config
  13. };
  14. }
  15. createPlugin.withOptions = function(pluginFunction, configFunction = ()=>({})) {
  16. const optionsFunction = function(options) {
  17. return {
  18. __options: options,
  19. handler: pluginFunction(options),
  20. config: configFunction(options)
  21. };
  22. };
  23. optionsFunction.__isOptionsFunction = true;
  24. // Expose plugin dependencies so that `object-hash` returns a different
  25. // value if anything here changes, to ensure a rebuild is triggered.
  26. optionsFunction.__pluginFunction = pluginFunction;
  27. optionsFunction.__configFunction = configFunction;
  28. return optionsFunction;
  29. };
  30. const _default = createPlugin;