@vuebro/loader-sfc 2.0.0 → 2.0.2
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.d.ts +1 -2
- package/dist/loader-sfc.esm-browser.prod.js +1550 -1549
- package/dist/loader-sfc.js +20 -19
- package/package.json +3 -4
package/dist/loader-sfc.js
CHANGED
|
@@ -22,14 +22,12 @@ const fetchText = async (url) => {
|
|
|
22
22
|
URL.revokeObjectURL(objectURL);
|
|
23
23
|
return value;
|
|
24
24
|
}, loadModule = async (filename) => {
|
|
25
|
-
const id = hash(filename)
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
},
|
|
30
|
-
scoped: styles.some(({ scoped }) => scoped),
|
|
25
|
+
const alerts = new Set(), id = `data-v-${hash(filename)}`, { descriptor, errors } = parse((await (await fetchText(filename)).text()) || "<template></template>"), { script, scriptSetup, slotted, styles, template } = descriptor;
|
|
26
|
+
const compilerOptions = {
|
|
27
|
+
expressionPlugins: ["jsx", "typescript"],
|
|
28
|
+
scopeId: id,
|
|
31
29
|
slotted,
|
|
32
|
-
};
|
|
30
|
+
}, scoped = styles.some(({ scoped }) => scoped), module = scoped ? { __scopeId: id } : {};
|
|
33
31
|
log(errors);
|
|
34
32
|
let el = document.getElementById(id);
|
|
35
33
|
if (!(el instanceof HTMLStyleElement)) {
|
|
@@ -38,37 +36,40 @@ const fetchText = async (url) => {
|
|
|
38
36
|
document.head.appendChild(el);
|
|
39
37
|
}
|
|
40
38
|
el.textContent = (await Promise.all(styles.map(async ({ content, module, scoped = false, src }) => {
|
|
39
|
+
if (module)
|
|
40
|
+
alerts.add("<style module> is not supported in the playground.");
|
|
41
41
|
const { code, errors } = await compileStyleAsync({
|
|
42
42
|
filename,
|
|
43
43
|
id,
|
|
44
|
-
modules: !!module,
|
|
45
44
|
scoped,
|
|
46
45
|
source: src ? await (await fetchText(src)).text() : content,
|
|
47
46
|
});
|
|
48
47
|
log(errors);
|
|
49
48
|
return code;
|
|
50
49
|
}))).join("\n");
|
|
50
|
+
log([...alerts]);
|
|
51
51
|
if (script || scriptSetup) {
|
|
52
|
-
const { content, warnings = [] } = compileScript(descriptor, {
|
|
53
|
-
id,
|
|
54
|
-
...(template ? templateOptions : {}),
|
|
55
|
-
});
|
|
52
|
+
const { bindings, content, warnings = [], } = compileScript(descriptor, { id });
|
|
56
53
|
log(warnings);
|
|
57
|
-
|
|
54
|
+
if (bindings)
|
|
55
|
+
compilerOptions.bindingMetadata = bindings;
|
|
56
|
+
Object.assign(module, (await inject(transform(content, options).code)).default);
|
|
58
57
|
}
|
|
59
|
-
|
|
60
|
-
const { content: source } = template;
|
|
58
|
+
if (template) {
|
|
59
|
+
const { ast, content: source } = template;
|
|
61
60
|
const { code, errors, tips } = compileTemplate({
|
|
62
|
-
...
|
|
61
|
+
...(ast && { ast }),
|
|
62
|
+
compilerOptions,
|
|
63
63
|
filename,
|
|
64
64
|
id,
|
|
65
|
+
scoped,
|
|
66
|
+
slotted,
|
|
65
67
|
source,
|
|
66
68
|
});
|
|
67
69
|
log(errors);
|
|
68
70
|
log(tips);
|
|
69
|
-
|
|
71
|
+
Object.assign(module, await inject(transform(code, options).code));
|
|
70
72
|
}
|
|
71
|
-
|
|
72
|
-
return {};
|
|
73
|
+
return module;
|
|
73
74
|
};
|
|
74
75
|
export default loadModule;
|
package/package.json
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"url": "git+https://github.com/vuebro/loader-sfc.git"
|
|
22
22
|
},
|
|
23
23
|
"license": "AGPL-3.0-only",
|
|
24
|
-
"version": "2.0.
|
|
24
|
+
"version": "2.0.2",
|
|
25
25
|
"type": "module",
|
|
26
26
|
"main": "./dist/loader-sfc.js",
|
|
27
27
|
"types": "./dist/loader-sfc.d.ts",
|
|
@@ -44,12 +44,11 @@
|
|
|
44
44
|
"jiti": "^2.6.1",
|
|
45
45
|
"typescript": "^5.9.3",
|
|
46
46
|
"typescript-eslint": "^8.45.0",
|
|
47
|
-
"vite": "^7.1.
|
|
47
|
+
"vite": "^7.1.9"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@vue/compiler-sfc": "^3.5.22",
|
|
51
51
|
"hash-sum": "^2.0.0",
|
|
52
|
-
"sucrase": "^3.35.0"
|
|
53
|
-
"vue": "^3.5.22"
|
|
52
|
+
"sucrase": "^3.35.0"
|
|
54
53
|
}
|
|
55
54
|
}
|