Skip to content

Commit

Permalink
fix HMR in new app template structure
Browse files Browse the repository at this point in the history
  • Loading branch information
FredKSchott committed Dec 13, 2020
1 parent ad69063 commit 004b874
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion snowpack/src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ class FileBuilder {
this.filesToResolve = {};
const isSSR = this.config.experiments.ssr;
const srcExt = path.extname(url.fileURLToPath(this.fileURL));
const fileOutput = this.mountEntry.static
// Workaround: HMR plugins need to add scripts to HTML file, even if static.
// TODO: Remove once no longer needed in dev.
const fileOutput = (this.mountEntry.static && srcExt !== '.html')
? {[srcExt]: {code: await readFile(this.fileURL)}}
: await buildFile(this.fileURL, {
plugins: this.config.plugins,
Expand Down
5 changes: 4 additions & 1 deletion snowpack/src/commands/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,10 @@ export async function startDevServer(commandOptions: CommandOptions): Promise<Sn
return finalResponse;
}

const {fileLoc, isStatic, isResolve} = foundFile;
const {fileLoc, isStatic: _isStatic, isResolve} = foundFile;
// Workaround: HMR plugins need to add scripts to HTML file, even if static.
// TODO: Once plugins are able to add virtual files + imports, this will no longer be needed.
const isStatic = _isStatic && !fileLoc.endsWith('.html');

// 1. Check the hot build cache. If it's already found, then just serve it.
let hotCachedResponse: SnowpackBuildMap | undefined = inMemoryBuildCache.get(
Expand Down

1 comment on commit 004b874

@vercel
Copy link

@vercel vercel bot commented on 004b874 Dec 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.