Skip to content

Commit

Permalink
(snowpack) - avoid running in ssr
Browse files Browse the repository at this point in the history
  • Loading branch information
natemoo-re committed Jan 20, 2021
1 parent eb31fc3 commit 3825a9a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/small-turtles-kneel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@prefresh/snowpack': patch
---

Avoid running in `snowpack@3.0.0` SSR mode
9 changes: 7 additions & 2 deletions packages/snowpack/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@ export default function preactRefreshPlugin(config, pluginOptions) {
'@prefresh/snowpack/runtime',
'@prefresh/snowpack/utils',
],
async transform({ contents, urlPath, isDev, id }) {
if (!isDev || !urlPath.endsWith('.js') || config.devOptions.hmr === false)
async transform({ contents, urlPath, isDev, isSSR, id }) {
if (
isSSR ||
!isDev ||
!urlPath.endsWith('.js') ||
config.devOptions.hmr === false
)
return;

let hasRefeshReg = /\$RefreshReg\$\(/.test(contents);
Expand Down

0 comments on commit 3825a9a

Please sign in to comment.