-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add "HMR" on files inside web-ssr-server/src (#2)
- Loading branch information
1 parent
016b057
commit f4d4bde
Showing
6 changed files
with
69 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
function clearRequireCache(predicate) { | ||
for ( | ||
let i = 0, ids = Object.keys(require.cache), l = ids.length, id; | ||
i < l; | ||
++i | ||
) { | ||
id = ids[i]; | ||
|
||
if (predicate(id)) { | ||
delete require.cache[id]; | ||
} | ||
} | ||
} | ||
|
||
const ssrServerFilenamePattern = /web-ssr-server\/src/; | ||
|
||
function isServerFile(id) { | ||
return ssrServerFilenamePattern.test(id); | ||
} | ||
|
||
export function clearServerCache() { | ||
// eslint-disable-next-line no-console | ||
console.log('Started to clear web-ssr-server modules cache'); | ||
|
||
clearRequireCache(isServerFile); | ||
|
||
// eslint-disable-next-line no-console | ||
console.log('Finished to clear web-ssr-server modules cache'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import chokidar from 'chokidar'; | ||
import path from 'path'; | ||
|
||
const packageSrcPath = path.join(__dirname, '..'); | ||
|
||
export function watchServer() { | ||
const watcher = chokidar.watch(packageSrcPath); | ||
return watcher; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters