Skip to content

Commit 5e8b1ee

Browse files
fix
fix
1 parent 4f70b3b commit 5e8b1ee

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

packages/vite/src/hbs.ts

+17
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
templateOnlyComponentSource,
1010
syntheticJStoHBS,
1111
} from '@embroider/core';
12+
import { extname } from 'path';
1213

1314
const resolverLoader = new ResolverLoader(process.cwd());
1415
const hbsFilter = createFilter('**/*.hbs?([?]*)');
@@ -72,6 +73,22 @@ export function hbs(): Plugin {
7273
}
7374
},
7475

76+
handleHotUpdate(ctx) {
77+
let id = ctx.file;
78+
let modules = ctx.modules.slice();
79+
if (isInComponents(id, resolverLoader.resolver.packageCache)) {
80+
let jsFilename = id.slice(0, -1 * extname(id).length) + '.js';
81+
if (jsFilename !== id) {
82+
// we don't actually do any transformation of these files here, but
83+
// Babel is going to run the colocation plugin to wire js and hbs
84+
// together, and it doesn't know about the extra dependency between
85+
// them. We can invalidate the whole transform step from here.
86+
modules.push((this as any).getModuleInfo(jsFilename));
87+
}
88+
}
89+
return modules;
90+
},
91+
7592
load(id: string) {
7693
if (getMeta(this, id)?.type === 'template-only-component-js') {
7794
return {

0 commit comments

Comments
 (0)