Skip to content

Commit 9f3ceb7

Browse files
feat: backward compatibility for templates using 'modules.export'
1 parent f49d62b commit 9f3ceb7

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

js/src/esmVueTemplate.js

+9
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ export async function compileSfc(sfcStr, mixin) {
2222
}
2323
});
2424

25+
if (script) {
26+
/* For backward compatibility, if module(s).export is used, replace everything before the first { with
27+
* export default
28+
*/
29+
if (/modules?\.export.*?{/.test(script.content)) {
30+
script.content = script.content.replace(/^[^{]+(?={)/, "export default ");
31+
}
32+
console.log(script.content)
33+
}
2534
return {
2635
...(template && {render: Vue.compile(template.content)}),
2736
mixins: [script ? (await toModule(script.content)).default : {}, mixin],

0 commit comments

Comments
 (0)