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 Nov 1, 2023
1 parent f49d62b commit 9d8a21e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions js/src/esmVueTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ 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 ");
}
}
return {
...(template && {render: Vue.compile(template.content)}),
mixins: [script ? (await toModule(script.content)).default : {}, mixin],
Expand Down

0 comments on commit 9d8a21e

Please sign in to comment.