@vuebro/loader-sfc 2.0.0 → 2.0.1
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 +1331 -1331
- package/dist/loader-sfc.js +13 -18
- package/package.json +2 -3
package/dist/loader-sfc.js
CHANGED
|
@@ -22,14 +22,9 @@ const fetchText = async (url) => {
|
|
|
22
22
|
URL.revokeObjectURL(objectURL);
|
|
23
23
|
return value;
|
|
24
24
|
}, loadModule = async (filename) => {
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
expressionPlugins: ["jsx", "typescript"],
|
|
29
|
-
},
|
|
30
|
-
scoped: styles.some(({ scoped }) => scoped),
|
|
31
|
-
slotted,
|
|
32
|
-
};
|
|
25
|
+
const compilerOptions = {
|
|
26
|
+
expressionPlugins: ["jsx", "typescript"],
|
|
27
|
+
}, id = hash(filename), module = {}, { descriptor, errors } = parse((await (await fetchText(filename)).text()) || "<template></template>"), { script, scriptSetup, slotted, styles, template } = descriptor;
|
|
33
28
|
log(errors);
|
|
34
29
|
let el = document.getElementById(id);
|
|
35
30
|
if (!(el instanceof HTMLStyleElement)) {
|
|
@@ -49,26 +44,26 @@ const fetchText = async (url) => {
|
|
|
49
44
|
return code;
|
|
50
45
|
}))).join("\n");
|
|
51
46
|
if (script || scriptSetup) {
|
|
52
|
-
const { content, warnings = [] } = compileScript(descriptor, {
|
|
53
|
-
id,
|
|
54
|
-
...(template ? templateOptions : {}),
|
|
55
|
-
});
|
|
47
|
+
const { bindings, content, warnings = [], } = compileScript(descriptor, { id });
|
|
56
48
|
log(warnings);
|
|
57
|
-
|
|
49
|
+
if (bindings)
|
|
50
|
+
compilerOptions.bindingMetadata = bindings;
|
|
51
|
+
Object.assign(module, (await inject(transform(content, options).code)).default);
|
|
58
52
|
}
|
|
59
|
-
|
|
53
|
+
if (template) {
|
|
60
54
|
const { content: source } = template;
|
|
61
55
|
const { code, errors, tips } = compileTemplate({
|
|
62
|
-
|
|
56
|
+
compilerOptions,
|
|
63
57
|
filename,
|
|
64
58
|
id,
|
|
59
|
+
scoped: styles.some(({ scoped }) => scoped),
|
|
60
|
+
slotted,
|
|
65
61
|
source,
|
|
66
62
|
});
|
|
67
63
|
log(errors);
|
|
68
64
|
log(tips);
|
|
69
|
-
|
|
65
|
+
Object.assign(module, await inject(transform(code, options).code));
|
|
70
66
|
}
|
|
71
|
-
|
|
72
|
-
return {};
|
|
67
|
+
return module;
|
|
73
68
|
};
|
|
74
69
|
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.1",
|
|
25
25
|
"type": "module",
|
|
26
26
|
"main": "./dist/loader-sfc.js",
|
|
27
27
|
"types": "./dist/loader-sfc.d.ts",
|
|
@@ -49,7 +49,6 @@
|
|
|
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
|
}
|