@vuebro/loader-sfc 2.3.18 → 2.3.20
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/loader-sfc.esm-browser.prod.js +13 -20
- package/dist/loader-sfc.js +30 -42
- package/package.json +3 -3
|
@@ -23699,32 +23699,25 @@ const Xg = async (e) => {
|
|
|
23699
23699
|
URL.revokeObjectURL(t);
|
|
23700
23700
|
}
|
|
23701
23701
|
}, JP = async (e, { parseOptions: t, scriptOptions: { templateOptions: { compilerOptions: { expressionPlugins: s, ...n } = {}, ...i } = {}, ...o } = {}, styleOptions: c } = {}) => {
|
|
23702
|
-
|
|
23703
|
-
|
|
23704
|
-
const C = [], A = document.getElementById(l) instanceof HTMLStyleElement ? Promise.resolve([]) : Promise.all(g.map(async ({ content: Y, module: le, scoped: J = !1, src: $ }) => {
|
|
23702
|
+
let l = "";
|
|
23703
|
+
const p = `data-v-${zT(e)}`, d = [], { descriptor: f, errors: m } = ib(await Xg(e) ?? "<template></template>", { filename: e, ...t }), { script: x, scriptSetup: g, slotted: y, styles: v, template: b } = f, E = new Set([x, g].filter((Y) => Y !== null).flatMap(({ lang: Y = "js" }) => [.../[jt]sx$/.test(Y) ? ["jsx"] : [], .../tsx?$/.test(Y) ? ["typescript"] : []])), w = { expressionPlugins: [.../* @__PURE__ */ new Set([...s ?? [], ...E])], filename: e, scopeId: p, slotted: y, ...n }, C = { compilerOptions: w, filename: e, id: p, scoped: v.some(({ scoped: Y }) => Y), slotted: y, ...i }, A = { id: p, templateOptions: C, ...o }, O = document.getElementById(p) instanceof HTMLStyleElement ? Promise.resolve([]) : Promise.all(v.map(async ({ content: Y, module: le, scoped: J = !1, src: $ }) => {
|
|
23705
23704
|
const ie = !!le;
|
|
23706
|
-
if (ie && !
|
|
23705
|
+
if (ie && !l) return l = "<style module> is not supported in the playground.", "";
|
|
23707
23706
|
{
|
|
23708
|
-
const { code: Q, errors: se } = await sP({ filename: e, id:
|
|
23709
|
-
return
|
|
23710
|
-
}
|
|
23711
|
-
})),
|
|
23712
|
-
U && (
|
|
23713
|
-
const { code: V, errors: F, tips: q } = !
|
|
23714
|
-
[...
|
|
23715
|
-
|
|
23716
|
-
}), [...W ?? [], ...w ? [w] : []].forEach((Y) => {
|
|
23717
|
-
co.warn(Y);
|
|
23718
|
-
}), [...q ?? []].forEach((Y) => {
|
|
23719
|
-
co.info(Y);
|
|
23720
|
-
});
|
|
23721
|
-
const [G, ee, ae] = await Promise.all([A, X ? Kg(v.size ? nd(X, j).code : X) : Promise.resolve(void 0), V ? Kg(v.size ? nd(V, j).code : V) : Promise.resolve(void 0)]), be = G.join(`
|
|
23707
|
+
const { code: Q, errors: se } = await sP({ filename: e, id: p, modules: ie, scoped: J, source: $ ? await Xg($) ?? "" : Y, ...c });
|
|
23708
|
+
return d.push(...se), Q;
|
|
23709
|
+
}
|
|
23710
|
+
})), D = { jsxRuntime: "preserve", transforms: [...E] }, { ast: N, content: j = "" } = b ?? {}, { bindings: U, content: X, warnings: W } = x || g ? WP(f, A) : {};
|
|
23711
|
+
U && (w.bindingMetadata = U);
|
|
23712
|
+
const { code: V, errors: F, tips: q } = !b || g && A.inlineTemplate ? {} : l0({ ...N, filename: e, id: p, source: j, ...C });
|
|
23713
|
+
[...m, ...F ?? [], ...d].forEach(co.error), [...W ?? [], ...l ? [l] : []].forEach(co.warn), [...q ?? []].forEach(co.info);
|
|
23714
|
+
const [G, ee, ae] = await Promise.all([O, X ? Kg(E.size ? nd(X, D).code : X) : Promise.resolve(void 0), V ? Kg(E.size ? nd(V, D).code : V) : Promise.resolve(void 0)]), be = G.join(`
|
|
23722
23715
|
`).trim();
|
|
23723
23716
|
if (be) {
|
|
23724
23717
|
const Y = document.createElement("style");
|
|
23725
|
-
Y.id =
|
|
23718
|
+
Y.id = p, Y.textContent = be, document.head.appendChild(Y);
|
|
23726
23719
|
}
|
|
23727
|
-
return { __scopeId:
|
|
23720
|
+
return { __scopeId: p, ...ee?.default, ...ae };
|
|
23728
23721
|
};
|
|
23729
23722
|
export {
|
|
23730
23723
|
JP as default
|
package/dist/loader-sfc.js
CHANGED
|
@@ -21,39 +21,14 @@ const fetching = async (input) => {
|
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
23
|
export default async (filename, { parseOptions, scriptOptions: { templateOptions: { compilerOptions: { expressionPlugins, ...restCompilerOptions } = {}, ...restTemplateOptions } = {}, ...restScriptOptions } = {}, styleOptions, } = {}) => {
|
|
24
|
-
|
|
25
|
-
const { descriptor, errors: parseErrors } = parse((await fetching(filename)) ?? "<template></template>", { filename, ...parseOptions });
|
|
26
|
-
const { script, scriptSetup, slotted, styles, template } = descriptor;
|
|
24
|
+
let styleWarning = "";
|
|
25
|
+
const id = `data-v-${hash(filename)}`, styleErrors = [], { descriptor, errors: parseErrors } = parse((await fetching(filename)) ?? "<template></template>", { filename, ...parseOptions }), { script, scriptSetup, slotted, styles, template } = descriptor;
|
|
27
26
|
const langs = new Set([script, scriptSetup]
|
|
28
27
|
.filter((scriptBlock) => scriptBlock !== null)
|
|
29
28
|
.flatMap(({ lang = "js" }) => [
|
|
30
29
|
...(/[jt]sx$/.test(lang) ? ["jsx"] : []),
|
|
31
30
|
...(/tsx?$/.test(lang) ? ["typescript"] : []),
|
|
32
|
-
])),
|
|
33
|
-
let styleWarning = "";
|
|
34
|
-
const styleErrors = [];
|
|
35
|
-
const style = !(document.getElementById(id) instanceof HTMLStyleElement)
|
|
36
|
-
? Promise.all(styles.map(async ({ content, module, scoped = false, src }) => {
|
|
37
|
-
const modules = !!module;
|
|
38
|
-
if (modules && !styleWarning) {
|
|
39
|
-
styleWarning = "<style module> is not supported in the playground.";
|
|
40
|
-
return "";
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
const { code, errors } = await compileStyleAsync({
|
|
44
|
-
filename,
|
|
45
|
-
id,
|
|
46
|
-
modules,
|
|
47
|
-
scoped,
|
|
48
|
-
source: src ? ((await fetching(src)) ?? "") : content,
|
|
49
|
-
...styleOptions,
|
|
50
|
-
});
|
|
51
|
-
styleErrors.push(...errors);
|
|
52
|
-
return code;
|
|
53
|
-
}
|
|
54
|
-
}))
|
|
55
|
-
: Promise.resolve([]);
|
|
56
|
-
const compilerOptions = {
|
|
31
|
+
])), compilerOptions = {
|
|
57
32
|
expressionPlugins: [
|
|
58
33
|
...new Set([...(expressionPlugins ?? []), ...langs]),
|
|
59
34
|
],
|
|
@@ -72,11 +47,31 @@ export default async (filename, { parseOptions, scriptOptions: { templateOptions
|
|
|
72
47
|
id,
|
|
73
48
|
templateOptions,
|
|
74
49
|
...restScriptOptions,
|
|
75
|
-
},
|
|
50
|
+
}, style = !(document.getElementById(id) instanceof HTMLStyleElement)
|
|
51
|
+
? Promise.all(styles.map(async ({ content, module, scoped = false, src }) => {
|
|
52
|
+
const modules = !!module;
|
|
53
|
+
if (modules && !styleWarning) {
|
|
54
|
+
styleWarning =
|
|
55
|
+
"<style module> is not supported in the playground.";
|
|
56
|
+
return "";
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
const { code, errors } = await compileStyleAsync({
|
|
60
|
+
filename,
|
|
61
|
+
id,
|
|
62
|
+
modules,
|
|
63
|
+
scoped,
|
|
64
|
+
source: src ? ((await fetching(src)) ?? "") : content,
|
|
65
|
+
...styleOptions,
|
|
66
|
+
});
|
|
67
|
+
styleErrors.push(...errors);
|
|
68
|
+
return code;
|
|
69
|
+
}
|
|
70
|
+
}))
|
|
71
|
+
: Promise.resolve([]), sucraseOptions = {
|
|
76
72
|
jsxRuntime: "preserve",
|
|
77
73
|
transforms: [...langs],
|
|
78
|
-
};
|
|
79
|
-
const { bindings, content, warnings: scriptWarnings, } = script || scriptSetup ? compileScript(descriptor, scriptOptions) : {};
|
|
74
|
+
}, { ast, content: source = "" } = template ?? {}, { bindings, content, warnings: scriptWarnings, } = script || scriptSetup ? compileScript(descriptor, scriptOptions) : {};
|
|
80
75
|
if (bindings)
|
|
81
76
|
compilerOptions.bindingMetadata = bindings;
|
|
82
77
|
const { code, errors: templateErrors, tips: templateTips, } = template && (!scriptSetup || !scriptOptions.inlineTemplate)
|
|
@@ -88,15 +83,9 @@ export default async (filename, { parseOptions, scriptOptions: { templateOptions
|
|
|
88
83
|
...templateOptions,
|
|
89
84
|
})
|
|
90
85
|
: {};
|
|
91
|
-
[...parseErrors, ...(templateErrors ?? []), ...styleErrors].forEach(
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
[...(scriptWarnings ?? []), ...(styleWarning ? [styleWarning] : [])].forEach((warn) => {
|
|
95
|
-
consola.warn(warn);
|
|
96
|
-
});
|
|
97
|
-
[...(templateTips ?? [])].forEach((info) => {
|
|
98
|
-
consola.info(info);
|
|
99
|
-
});
|
|
86
|
+
[...parseErrors, ...(templateErrors ?? []), ...styleErrors].forEach(consola.error);
|
|
87
|
+
[...(scriptWarnings ?? []), ...(styleWarning ? [styleWarning] : [])].forEach(consola.warn);
|
|
88
|
+
[...(templateTips ?? [])].forEach(consola.info);
|
|
100
89
|
const [styleResult, scriptResult, templateResult] = await Promise.all([
|
|
101
90
|
style,
|
|
102
91
|
content
|
|
@@ -105,8 +94,7 @@ export default async (filename, { parseOptions, scriptOptions: { templateOptions
|
|
|
105
94
|
code
|
|
106
95
|
? inject(langs.size ? transform(code, sucraseOptions).code : code)
|
|
107
96
|
: Promise.resolve(undefined),
|
|
108
|
-
]);
|
|
109
|
-
const textContent = styleResult.join("\n").trim();
|
|
97
|
+
]), textContent = styleResult.join("\n").trim();
|
|
110
98
|
if (textContent) {
|
|
111
99
|
const el = document.createElement("style");
|
|
112
100
|
el.id = id;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vuebro/loader-sfc",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.20",
|
|
4
4
|
"description": "Vue3 Single File Component (SFC) loader. Load .vue files directly from your browser without any build step.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vue",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@rollup/plugin-terser": "^0.4.4",
|
|
45
45
|
"@types/hash-sum": "^1.0.2",
|
|
46
|
-
"@types/node": "^24.
|
|
47
|
-
"@vuebro/configs": "^1.1.
|
|
46
|
+
"@types/node": "^24.10.0",
|
|
47
|
+
"@vuebro/configs": "^1.1.57",
|
|
48
48
|
"eslint": "^9.39.0",
|
|
49
49
|
"vite": "^7.1.12"
|
|
50
50
|
}
|