plugins.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.getDefaultVueLanguagePlugins = void 0;
  4. const useHtmlFilePlugin = require("./plugins/file-html");
  5. const useMdFilePlugin = require("./plugins/file-md");
  6. const useVueFilePlugin = require("./plugins/file-vue");
  7. const useVueSfcCustomBlocks = require("./plugins/vue-sfc-customblocks");
  8. const useVueSfcScriptsFormat = require("./plugins/vue-sfc-scripts");
  9. const useVueSfcStyles = require("./plugins/vue-sfc-styles");
  10. const useVueSfcTemplate = require("./plugins/vue-sfc-template");
  11. const useHtmlTemplatePlugin = require("./plugins/vue-template-html");
  12. const vue_tsx_1 = require("./plugins/vue-tsx");
  13. const CompilerDOM = require("@vue/compiler-dom");
  14. const CompilerVue2 = require("./utils/vue2TemplateCompiler");
  15. function getDefaultVueLanguagePlugins(ts, compilerOptions, vueCompilerOptions, codegenStack) {
  16. const plugins = [
  17. useMdFilePlugin,
  18. useHtmlFilePlugin,
  19. useVueFilePlugin,
  20. useHtmlTemplatePlugin,
  21. useVueSfcStyles,
  22. useVueSfcCustomBlocks,
  23. useVueSfcScriptsFormat,
  24. useVueSfcTemplate,
  25. vue_tsx_1.default,
  26. ...vueCompilerOptions.plugins,
  27. ];
  28. const pluginCtx = {
  29. modules: {
  30. '@vue/compiler-dom': vueCompilerOptions.target < 3 ? CompilerVue2 : CompilerDOM,
  31. typescript: ts,
  32. },
  33. compilerOptions,
  34. vueCompilerOptions,
  35. codegenStack,
  36. };
  37. const pluginInstances = plugins
  38. .map(plugin => plugin(pluginCtx))
  39. .sort((a, b) => {
  40. const aOrder = a.order ?? 0;
  41. const bOrder = b.order ?? 0;
  42. return aOrder - bOrder;
  43. });
  44. return pluginInstances.filter((plugin) => {
  45. const valid = plugin.version >= 1 && plugin.version < 2;
  46. if (!valid) {
  47. console.warn(`Plugin ${JSON.stringify(plugin.name)} API version incompatible, expected 1.x but got ${JSON.stringify(plugin.version)}`);
  48. }
  49. return valid;
  50. });
  51. }
  52. exports.getDefaultVueLanguagePlugins = getDefaultVueLanguagePlugins;
  53. //# sourceMappingURL=plugins.js.map