Skip to content

Commit

Permalink
feat: backward compatibility for templates using 'modules.export'
Browse files Browse the repository at this point in the history
  • Loading branch information
mariobuikhuizen committed Oct 31, 2023
1 parent f49d62b commit 9f3ceb7
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions js/src/esmVueTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down

0 comments on commit 9f3ceb7

Please sign in to comment.