UNPKG

vue-jsx-vapor

Version:
63 lines (61 loc) 2.5 kB
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } }); const require_chunk = require('./chunk-C0xms8kb.cjs'); const require_core = require('./core-CM75Ciyx.cjs'); let _vue_jsx_vapor_macros_raw = require("@vue-jsx-vapor/macros/raw"); _vue_jsx_vapor_macros_raw = require_chunk.__toESM(_vue_jsx_vapor_macros_raw); let _vue_jsx_vapor_runtime_raw = require("@vue-jsx-vapor/runtime/raw"); let pathe = require("pathe"); let unplugin_utils = require("unplugin-utils"); //#region src/raw.ts const plugin = (options = {}) => { let root = ""; let needHMR = false; let needSourceMap = options.sourceMap || false; const helperId = /^\/vue-jsx-vapor\//; return [...options.macros === false ? [] : options.macros ? (0, _vue_jsx_vapor_macros_raw.default)(options.macros === true ? void 0 : options.macros) : [], { enforce: "pre", name: "vue-jsx-vapor", vite: { config(config) { return { define: { __VUE_OPTIONS_API__: config.define?.__VUE_OPTIONS_API__ ?? true, __VUE_PROD_DEVTOOLS__: config.define?.__VUE_PROD_DEVTOOLS__ ?? false, __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: config.define?.__VUE_PROD_HYDRATION_MISMATCH_DETAILS__ ?? false } }; }, configResolved(config) { root = config.root; needHMR = config.command === "serve"; needSourceMap ||= config.command === "serve" || !!config.build.sourcemap; } }, resolveId: { filter: { id: helperId }, handler: (id) => id }, load: { filter: { id: helperId }, handler(id) { if (id === _vue_jsx_vapor_runtime_raw.ssrHelperId) return _vue_jsx_vapor_runtime_raw.ssrHelperCode; if (id === _vue_jsx_vapor_runtime_raw.propsHelperId) return _vue_jsx_vapor_runtime_raw.propsHelperCode; if (id === _vue_jsx_vapor_runtime_raw.vdomHelperId) return _vue_jsx_vapor_runtime_raw.vdomHelperCode; if (id === _vue_jsx_vapor_runtime_raw.vaporHelperId) return _vue_jsx_vapor_runtime_raw.vaporHelperCode; } }, transform: { filter: { id: { include: options?.include || /\.[cm]?[jt]sx(?=$|[?#])/, exclude: options?.exclude || /node_modules/ } }, handler(code, id, opt) { const result = require_core.transformVueJsxVapor(code, opt?.ssr ? (0, unplugin_utils.normalizePath)((0, pathe.relative)(root, id)) : id, options, needSourceMap, needHMR, opt?.ssr); if (result?.code) return { code: result.code, map: result.map ? JSON.parse(result.map) : null }; } } }]; }; //#endregion exports.default = plugin;