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

108 строки
2.9 KiB

  1. "use strict";Object.defineProperty(exports, "__esModule", {value: true});
  2. var _chunk4PQK4PHQjs = require('./chunk-4PQK4PHQ.js');
  3. // src/index.ts
  4. var _unplugin = require('unplugin');
  5. var _common = require('@vue-macros/common');
  6. function resolveOption(options) {
  7. const root = options.root || process.cwd();
  8. const version = options.version || _common.detectVueVersion.call(void 0, root);
  9. return {
  10. include: [_common.REGEX_SRC_FILE],
  11. exclude: [_common.REGEX_SETUP_SFC, _common.REGEX_VUE_SUB, _common.REGEX_NODE_MODULES],
  12. ...options,
  13. root,
  14. version
  15. };
  16. }
  17. var name = "unplugin-vue-setup-component";
  18. var PrePlugin = _unplugin.createUnplugin.call(void 0,
  19. (userOptions = {}, meta) => {
  20. const options = resolveOption(userOptions);
  21. const filter = _common.createFilter.call(void 0, options);
  22. const setupComponentContext = {};
  23. return {
  24. name: `${name}-pre`,
  25. enforce: "pre",
  26. resolveId(id, importer) {
  27. if (_chunk4PQK4PHQjs.SETUP_COMPONENT_ID_REGEX.test(id))
  28. return id;
  29. if (["rollup", "vite"].includes(meta.framework) && importer && _chunk4PQK4PHQjs.isSubModule.call(void 0, importer)) {
  30. const mainModule = _chunk4PQK4PHQjs.getMainModule.call(void 0, importer, options.root);
  31. return this.resolve(id, mainModule, {
  32. skipSelf: true
  33. });
  34. }
  35. },
  36. loadInclude(id) {
  37. return _chunk4PQK4PHQjs.SETUP_COMPONENT_ID_REGEX.test(id);
  38. },
  39. load(id) {
  40. return _chunk4PQK4PHQjs.loadSetupComponent.call(void 0, id, setupComponentContext, options.root);
  41. },
  42. transformInclude(id) {
  43. return filter(id);
  44. },
  45. transform(code, id) {
  46. return _chunk4PQK4PHQjs.transformSetupComponent.call(void 0, code, id, setupComponentContext);
  47. },
  48. vite: {
  49. configResolved(config) {
  50. options.root = config.root;
  51. },
  52. handleHotUpdate: (ctx) => {
  53. if (filter(ctx.file)) {
  54. return _chunk4PQK4PHQjs.hotUpdateSetupComponent.call(void 0, ctx, setupComponentContext);
  55. }
  56. }
  57. }
  58. };
  59. }
  60. );
  61. var PostPlugin = _unplugin.createUnplugin.call(void 0, () => {
  62. return {
  63. name: `${name}-post`,
  64. enforce: "post",
  65. transformInclude(id) {
  66. return _chunk4PQK4PHQjs.isSubModule.call(void 0, id);
  67. },
  68. transform(code, id) {
  69. return _chunk4PQK4PHQjs.transformPost.call(void 0, code, id);
  70. },
  71. rollup: {
  72. transform: {
  73. order: "post",
  74. handler(code, id) {
  75. if (!_chunk4PQK4PHQjs.isSubModule.call(void 0, id))
  76. return;
  77. return _chunk4PQK4PHQjs.transformPost.call(void 0, code, id);
  78. }
  79. }
  80. }
  81. };
  82. });
  83. var plugin = _unplugin.createUnplugin.call(void 0,
  84. (options = {}, meta) => {
  85. return [PrePlugin.raw(options, meta), PostPlugin.raw(options, meta)];
  86. }
  87. );
  88. var src_default = plugin;
  89. exports.src_default = src_default;