vue-jsx-vapor 2.6.8 → 2.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.cjs +1 -1
- package/dist/api.d.cts +4 -4
- package/dist/api.d.ts +4 -4
- package/dist/api.js +1 -1
- package/dist/astro.cjs +3 -3
- package/dist/astro.d.cts +2 -3
- package/dist/astro.d.ts +1 -1
- package/dist/astro.js +3 -3
- package/dist/core-BeuKLsFR.cjs +22 -0
- package/dist/core-CfhBppKN.js +15 -0
- package/dist/esbuild.cjs +3 -3
- package/dist/esbuild.d.cts +4 -5
- package/dist/esbuild.d.ts +3 -3
- package/dist/esbuild.js +3 -3
- package/dist/index.js +2 -0
- package/dist/nuxt.cjs +7 -6
- package/dist/nuxt.d.cts +1 -1
- package/dist/nuxt.d.ts +3 -3
- package/dist/nuxt.js +5 -5
- package/dist/{options-CBMw6D8V.d.ts → options-D6zn5V49.d.ts} +1 -1
- package/dist/{options-jKAq0dFf.d.cts → options-DxHQU8-_.d.cts} +1 -1
- package/dist/raw-B3KlYN7X.js +119 -0
- package/dist/raw-DG3OYbEe.cjs +132 -0
- package/dist/raw.cjs +2 -2
- package/dist/raw.d.cts +2 -3
- package/dist/raw.d.ts +1 -1
- package/dist/raw.js +2 -2
- package/dist/rolldown.cjs +5 -4
- package/dist/rolldown.d.cts +4 -5
- package/dist/rolldown.d.ts +3 -3
- package/dist/rolldown.js +3 -3
- package/dist/rollup.cjs +3 -3
- package/dist/rollup.d.cts +4 -5
- package/dist/rollup.d.ts +3 -3
- package/dist/rollup.js +3 -3
- package/dist/rspack.cjs +3 -3
- package/dist/rspack.d.cts +2 -3
- package/dist/rspack.d.ts +1 -1
- package/dist/rspack.js +3 -3
- package/dist/{unplugin-aKVZLoq9.cjs → unplugin-6bs2zQro.cjs} +3 -2
- package/dist/{unplugin-CyifZGPt.js → unplugin-BPAlTDcQ.js} +2 -2
- package/dist/unplugin.cjs +3 -3
- package/dist/unplugin.d.cts +4 -4
- package/dist/unplugin.d.ts +4 -4
- package/dist/unplugin.js +3 -3
- package/dist/{vite-C63GJQHT.cjs → vite-D8MCYNCu.cjs} +1 -1
- package/dist/vite-EGcRF3B5.js +7 -0
- package/dist/vite.cjs +4 -4
- package/dist/vite.d.cts +4 -5
- package/dist/vite.d.ts +3 -3
- package/dist/vite.js +4 -4
- package/dist/volar.cjs +10 -5
- package/dist/volar.d.cts +1 -1
- package/dist/volar.d.ts +1 -1
- package/dist/{webpack-CeAur76z.cjs → webpack-CAtjl4UN.cjs} +1 -1
- package/dist/webpack-DdK9_Sb1.js +7 -0
- package/dist/webpack.cjs +4 -4
- package/dist/webpack.d.cts +4 -5
- package/dist/webpack.d.ts +3 -3
- package/dist/webpack.js +4 -4
- package/package.json +4 -5
- package/dist/core-C-41-Q2Y.cjs +0 -33
- package/dist/core-CJgJmh2O.js +0 -27
- package/dist/options.d.cjs +0 -0
- package/dist/options.d.cts +0 -2
- package/dist/options.d.ts +0 -2
- package/dist/raw-B2YMrqwY.cjs +0 -213
- package/dist/raw-CWZ5g7Vk.js +0 -207
- package/dist/vite-Djd6MAt9.js +0 -7
- package/dist/webpack-3fgVTA33.js +0 -7
package/dist/raw-CWZ5g7Vk.js
DELETED
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
import { transformVueJsxVapor } from "./core-CJgJmh2O.js";
|
|
2
|
-
import { transformSync } from "@babel/core";
|
|
3
|
-
import babelTypescript from "@babel/plugin-transform-typescript";
|
|
4
|
-
import macros from "@vue-jsx-vapor/macros/raw";
|
|
5
|
-
import { transformJsxDirective } from "@vue-macros/jsx-directive/api";
|
|
6
|
-
import { createFilter, normalizePath } from "unplugin-utils";
|
|
7
|
-
import { isFunctionalNode } from "@vue-jsx-vapor/macros/api";
|
|
8
|
-
import getHash from "hash-sum";
|
|
9
|
-
import { relative } from "pathe";
|
|
10
|
-
import jsx from "@vue/babel-plugin-jsx";
|
|
11
|
-
|
|
12
|
-
//#region src/core/ssr.ts
|
|
13
|
-
const ssrRegisterHelperId = "/__vue-jsx-ssr-register-helper";
|
|
14
|
-
const ssrRegisterHelperCode = `import { useSSRContext } from "vue"\nexport const ssrRegisterHelper = ${ssrRegisterHelper.toString()}`;
|
|
15
|
-
/**
|
|
16
|
-
* This function is serialized with toString() and evaluated as a virtual
|
|
17
|
-
* module during SSR
|
|
18
|
-
*/
|
|
19
|
-
function ssrRegisterHelper(comp, filename) {
|
|
20
|
-
const setup = comp.setup;
|
|
21
|
-
comp.setup = (props, ctx) => {
|
|
22
|
-
const ssrContext = useSSRContext();
|
|
23
|
-
(ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add(filename);
|
|
24
|
-
if (setup) return setup(props, ctx);
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
function injectSSR(id, hotComponents, root = "") {
|
|
28
|
-
const normalizedId = normalizePath(relative(root, id));
|
|
29
|
-
let ssrInjectCode = `\nimport { ssrRegisterHelper } from "${ssrRegisterHelperId}"\nconst __moduleId = ${JSON.stringify(normalizedId)}`;
|
|
30
|
-
for (const { local } of hotComponents) ssrInjectCode += `\nssrRegisterHelper(${local}, __moduleId)`;
|
|
31
|
-
return ssrInjectCode;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
//#endregion
|
|
35
|
-
//#region src/core/hmr.ts
|
|
36
|
-
function injectHMRAndSSR(result, id, options) {
|
|
37
|
-
const ssr = options?.ssr;
|
|
38
|
-
const defineComponentNames = options?.defineComponentNames ?? ["defineComponent", "defineVaporComponent"];
|
|
39
|
-
const { ast } = result;
|
|
40
|
-
const declaredComponents = [];
|
|
41
|
-
const hotComponents = [];
|
|
42
|
-
let hasDefaultExport = false;
|
|
43
|
-
for (const node of ast.program.body) {
|
|
44
|
-
if (node.type === "VariableDeclaration") {
|
|
45
|
-
const names = parseComponentDecls(node, defineComponentNames);
|
|
46
|
-
if (names.length) declaredComponents.push(...names);
|
|
47
|
-
}
|
|
48
|
-
if (node.type === "ExportNamedDeclaration") {
|
|
49
|
-
if (node.declaration && node.declaration.type === "VariableDeclaration") hotComponents.push(...parseComponentDecls(node.declaration, defineComponentNames).map((name) => ({
|
|
50
|
-
local: name,
|
|
51
|
-
exported: name,
|
|
52
|
-
id: getHash(id + name)
|
|
53
|
-
})));
|
|
54
|
-
else if (node.specifiers.length) {
|
|
55
|
-
for (const spec of node.specifiers) if (spec.type === "ExportSpecifier" && spec.exported.type === "Identifier") {
|
|
56
|
-
const matched = declaredComponents.find((name) => name === spec.local.name);
|
|
57
|
-
if (matched) hotComponents.push({
|
|
58
|
-
local: spec.local.name,
|
|
59
|
-
exported: spec.exported.name,
|
|
60
|
-
id: getHash(id + spec.exported.name)
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
if (node.type === "ExportDefaultDeclaration") {
|
|
66
|
-
if (node.declaration.type === "Identifier") {
|
|
67
|
-
const _name = node.declaration.name;
|
|
68
|
-
const matched = declaredComponents.find((name) => name === _name);
|
|
69
|
-
if (matched) hotComponents.push({
|
|
70
|
-
local: _name,
|
|
71
|
-
exported: "default",
|
|
72
|
-
id: getHash(`${id}default`)
|
|
73
|
-
});
|
|
74
|
-
} else if (isDefineComponentCall(node.declaration, defineComponentNames) || isFunctionalNode(node.declaration)) {
|
|
75
|
-
hasDefaultExport = true;
|
|
76
|
-
hotComponents.push({
|
|
77
|
-
local: "__default__",
|
|
78
|
-
exported: "default",
|
|
79
|
-
id: getHash(`${id}default`)
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
if (hotComponents.length) {
|
|
85
|
-
if (hasDefaultExport || ssr) result.code = `${result.code.replaceAll(`export default `, `const __default__ = `)}\nexport default __default__;`;
|
|
86
|
-
if (!ssr && !/\?vue&type=script/.test(id)) {
|
|
87
|
-
let code = result.code;
|
|
88
|
-
let callbackCode = ``;
|
|
89
|
-
for (const { local, exported, id: id$1 } of hotComponents) {
|
|
90
|
-
code += `\n${local}.__hmrId = "${id$1}";\n__VUE_HMR_RUNTIME__.createRecord("${id$1}", ${local});`;
|
|
91
|
-
callbackCode += `
|
|
92
|
-
__VUE_HMR_RUNTIME__[typeof mod['${exported}'] === 'function' ? 'rerender' : 'reload'](mod['${exported}'].__hmrId, mod['${exported}']);`;
|
|
93
|
-
}
|
|
94
|
-
code += `
|
|
95
|
-
if (import.meta.hot) {
|
|
96
|
-
import.meta.hot.accept(mod => {${callbackCode}\n });
|
|
97
|
-
}`;
|
|
98
|
-
result.code = code;
|
|
99
|
-
}
|
|
100
|
-
if (ssr) result.code += injectSSR(id, hotComponents, options?.root);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
function parseComponentDecls(node, fnNames) {
|
|
104
|
-
const names = [];
|
|
105
|
-
for (const decl of node.declarations) if (decl.id.type === "Identifier" && (isDefineComponentCall(decl.init, fnNames) || isFunctionalNode(decl.init))) names.push(decl.id.name);
|
|
106
|
-
return names;
|
|
107
|
-
}
|
|
108
|
-
function isDefineComponentCall(node, names) {
|
|
109
|
-
return !!(node && node.type === "CallExpression" && node.callee.type === "Identifier" && names.includes(node.callee.name));
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
//#endregion
|
|
113
|
-
//#region src/core/vue-jsx.ts
|
|
114
|
-
function transformVueJsx(code, id, needSourceMap = false) {
|
|
115
|
-
const result = transformSync(code, {
|
|
116
|
-
plugins: [jsx, ...id.endsWith(".tsx") ? [[babelTypescript, {
|
|
117
|
-
isTSX: true,
|
|
118
|
-
allowExtensions: true
|
|
119
|
-
}]] : []],
|
|
120
|
-
filename: id,
|
|
121
|
-
sourceMaps: needSourceMap,
|
|
122
|
-
sourceFileName: id,
|
|
123
|
-
babelrc: false,
|
|
124
|
-
configFile: false
|
|
125
|
-
});
|
|
126
|
-
if (result?.code && result.code !== code) return {
|
|
127
|
-
code: result.code,
|
|
128
|
-
map: result.map
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
//#endregion
|
|
133
|
-
//#region src/raw.ts
|
|
134
|
-
const plugin = (options = {}) => {
|
|
135
|
-
const transformInclude = createFilter(options?.include || /\.[cm]?[jt]sx$/, options?.exclude || /node_modules/);
|
|
136
|
-
let root = "";
|
|
137
|
-
let needHMR = false;
|
|
138
|
-
let needSourceMap = options.sourceMap || false;
|
|
139
|
-
return [
|
|
140
|
-
{
|
|
141
|
-
name: "vue-jsx-vapor",
|
|
142
|
-
vite: {
|
|
143
|
-
config(config) {
|
|
144
|
-
return {
|
|
145
|
-
esbuild: { include: /\.ts$/ },
|
|
146
|
-
define: {
|
|
147
|
-
__VUE_OPTIONS_API__: config.define?.__VUE_OPTIONS_API__ ?? true,
|
|
148
|
-
__VUE_PROD_DEVTOOLS__: config.define?.__VUE_PROD_DEVTOOLS__ ?? false,
|
|
149
|
-
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: config.define?.__VUE_PROD_HYDRATION_MISMATCH_DETAILS__ ?? false
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
},
|
|
153
|
-
configResolved(config) {
|
|
154
|
-
root = config.root;
|
|
155
|
-
needHMR = config.command === "serve";
|
|
156
|
-
needSourceMap ||= config.command === "serve" || !!config.build.sourcemap;
|
|
157
|
-
}
|
|
158
|
-
},
|
|
159
|
-
resolveId(id) {
|
|
160
|
-
if (id === ssrRegisterHelperId) return id;
|
|
161
|
-
},
|
|
162
|
-
loadInclude(id) {
|
|
163
|
-
if (id === ssrRegisterHelperId) return true;
|
|
164
|
-
},
|
|
165
|
-
load(id) {
|
|
166
|
-
if (id === ssrRegisterHelperId) return ssrRegisterHelperCode;
|
|
167
|
-
},
|
|
168
|
-
transformInclude,
|
|
169
|
-
transform(code, id, opt) {
|
|
170
|
-
const result = transformVueJsxVapor(code, id, options, needSourceMap);
|
|
171
|
-
if (result?.code) {
|
|
172
|
-
(needHMR || opt?.ssr) && injectHMRAndSSR(result, id, {
|
|
173
|
-
ssr: opt?.ssr,
|
|
174
|
-
root
|
|
175
|
-
});
|
|
176
|
-
return {
|
|
177
|
-
code: result.code,
|
|
178
|
-
map: result.map
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
},
|
|
183
|
-
{
|
|
184
|
-
name: "@vue-macros/jsx-directive",
|
|
185
|
-
transformInclude,
|
|
186
|
-
transform(code, id, opt) {
|
|
187
|
-
if (options.interop || opt?.ssr) return transformJsxDirective(code, id, {
|
|
188
|
-
lib: "vue",
|
|
189
|
-
prefix: "v-",
|
|
190
|
-
version: 3.6
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
},
|
|
194
|
-
{
|
|
195
|
-
name: "@vitejs/plugin-vue-jsx",
|
|
196
|
-
transformInclude,
|
|
197
|
-
transform(code, id, opt) {
|
|
198
|
-
if (options.interop || opt?.ssr) return transformVueJsx(code, id, needSourceMap);
|
|
199
|
-
}
|
|
200
|
-
},
|
|
201
|
-
...options.macros === false ? [] : options.macros ? [macros(options.macros === true ? void 0 : options.macros)] : []
|
|
202
|
-
];
|
|
203
|
-
};
|
|
204
|
-
var raw_default = plugin;
|
|
205
|
-
|
|
206
|
-
//#endregion
|
|
207
|
-
export { raw_default };
|
package/dist/vite-Djd6MAt9.js
DELETED