版博士V2.0程序
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 

99 строки
2.4 KiB

  1. "use strict";Object.defineProperty(exports, "__esModule", {value: true});
  2. var _chunkZU56XJIDjs = require('./chunk-ZU56XJID.js');
  3. // src/index.ts
  4. var _utils = require('@antfu/utils');
  5. // src/vite.ts
  6. var getVitePlugin = (factory) => {
  7. return (userOptions) => {
  8. const { plugins } = factory(userOptions, { framework: "vite" });
  9. return resolvePlugins(plugins, "vite");
  10. };
  11. };
  12. // src/esbuild.ts
  13. var getEsbuildPlugin = (factory) => {
  14. return (userOptions) => {
  15. const { name, plugins } = factory(userOptions, { framework: "esbuild" });
  16. return {
  17. name,
  18. setup(build) {
  19. for (const plugin of resolvePlugins(plugins, "esbuild")) {
  20. plugin.setup(build);
  21. }
  22. }
  23. };
  24. };
  25. };
  26. // src/webpack.ts
  27. var getWebpackPlugin = (factory) => {
  28. return (userOptions) => {
  29. const { plugins } = factory(userOptions, { framework: "webpack" });
  30. return (compiler) => {
  31. for (const plugin of resolvePlugins(plugins, "webpack")) {
  32. if (typeof plugin === "object") {
  33. plugin.apply.call(compiler, compiler);
  34. } else {
  35. plugin.call(compiler, compiler);
  36. }
  37. }
  38. };
  39. };
  40. };
  41. // src/index.ts
  42. function flatPlugins(plugins) {
  43. return _utils.toArray.call(void 0, plugins).flat(Number.POSITIVE_INFINITY);
  44. }
  45. function resolvePlugins(plugins, type) {
  46. return flatPlugins(plugins).filter(Boolean).map((plugin) => {
  47. if ("instance" in plugin) {
  48. const { instance, options } = plugin;
  49. return instance[type](options);
  50. }
  51. return plugin;
  52. });
  53. }
  54. var createCombinePlugin = (factory) => {
  55. return {
  56. get rollup() {
  57. return getRollupPlugin(factory);
  58. },
  59. get vite() {
  60. return getVitePlugin(factory);
  61. },
  62. get esbuild() {
  63. return getEsbuildPlugin(factory);
  64. },
  65. get webpack() {
  66. return getWebpackPlugin(factory);
  67. },
  68. get raw() {
  69. return factory;
  70. },
  71. get plugins() {
  72. return _chunkZU56XJIDjs.getPluginList.call(void 0, factory);
  73. }
  74. };
  75. };
  76. // src/rollup.ts
  77. var getRollupPlugin = (factory) => {
  78. return (userOptions) => {
  79. const { plugins } = factory(userOptions, { framework: "rollup" });
  80. return resolvePlugins(plugins, "rollup");
  81. };
  82. };
  83. exports.getRollupPlugin = getRollupPlugin; exports.getVitePlugin = getVitePlugin; exports.getWebpackPlugin = getWebpackPlugin; exports.resolvePlugins = resolvePlugins; exports.createCombinePlugin = createCombinePlugin; exports.getEsbuildPlugin = getEsbuildPlugin;