Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #5

Open
wants to merge 2 commits into
base: watch-tests
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions packages/vite/src/hbs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
templateOnlyComponentSource,
syntheticJStoHBS,
} from '@embroider/core';
import { extname } from 'path';

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

handleHotUpdate(ctx) {
let id = ctx.file;
let modules = ctx.modules.slice();
if (isInComponents(id, resolverLoader.resolver.packageCache)) {
let jsFilename = id.slice(0, -1 * extname(id).length) + '.js';
if (jsFilename !== id) {
// we don't actually do any transformation of these files here, but
// Babel is going to run the colocation plugin to wire js and hbs
// together, and it doesn't know about the extra dependency between
// them. We can invalidate the whole transform step from here.
modules.push((this as any).getModuleInfo(jsFilename));
}
}
return modules;
},

load(id: string) {
if (getMeta(this, id)?.type === 'template-only-component-js') {
return {
Expand Down
Loading