diff --git a/js/src/esmVueTemplate.js b/js/src/esmVueTemplate.js index 4d66d17..dcd1b58 100644 --- a/js/src/esmVueTemplate.js +++ b/js/src/esmVueTemplate.js @@ -22,6 +22,15 @@ export async function compileSfc(sfcStr, mixin) { } }); + if (script) { + /* For backward compatibility, if module(s).export is used, replace everything before the first { with + * export default + */ + if (/modules?\.export.*?{/.test(script.content)) { + script.content = script.content.replace(/^[^{]+(?={)/, "export default "); + } + console.log(script.content) + } return { ...(template && {render: Vue.compile(template.content)}), mixins: [script ? (await toModule(script.content)).default : {}, mixin],