Skip to content

Commit

Permalink
Enforce running the hbs transform before any others
Browse files Browse the repository at this point in the history
  • Loading branch information
simonihmig committed Oct 8, 2024
1 parent 37fa5f4 commit 8f53b7a
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions packages/addon-dev/src/rollup-hbs-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,22 @@ export default function rollupHbsPlugin({
}
},

transform(code: string, id: string) {
let hbsFilename = id.replace(/\.\w{1,3}$/, '') + '.hbs';
if (hbsFilename !== id) {
this.addWatchFile(hbsFilename);
if (getMeta(this, id)?.type === 'template-only-component-js') {
this.addWatchFile(id);
transform: {
// Enforce running the hbs transform before any others like babel that expect valid JS
order: 'pre',
handler(code: string, id: string) {
let hbsFilename = id.replace(/\.\w{1,3}$/, '') + '.hbs';
if (hbsFilename !== id) {
this.addWatchFile(hbsFilename);
if (getMeta(this, id)?.type === 'template-only-component-js') {
this.addWatchFile(id);
}
}
}
if (!hbsFilter(id)) {
return null;
}
return hbsToJS(code);
if (!hbsFilter(id)) {
return null;
}
return hbsToJS(code);
},
},
};
}
Expand Down

0 comments on commit 8f53b7a

Please sign in to comment.