Skip to content

Commit

Permalink
fix: empty cache on each server reload (#431)
Browse files Browse the repository at this point in the history
Fixes #230
  • Loading branch information
JulienPradet authored and gregberge committed Sep 19, 2019
1 parent f1e75b6 commit d4428c6
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/server/__fixtures__/letters-A.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = 'a'
1 change: 1 addition & 0 deletions packages/server/__fixtures__/letters-B.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = 'b'
1 change: 1 addition & 0 deletions packages/server/__fixtures__/letters-C.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = 'c'
1 change: 1 addition & 0 deletions packages/server/__fixtures__/letters-D.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = 'd'
1 change: 1 addition & 0 deletions packages/server/__fixtures__/letters-E.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = 'e'
15 changes: 15 additions & 0 deletions packages/server/src/ChunkExtractor.js
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,21 @@ class ChunkExtractor {
const assets = this.getChunkAssets(entrypoint)
const mainAsset = assets.find(asset => asset.scriptType === 'script')
invariant(mainAsset, 'asset not found')

this.stats.assets
.filter(({ name }) => {
const type = extensionToScriptType(
path
.extname(name)
.split('?')[0]
.toLowerCase(),
)
return type === 'script'
})
.forEach(({ name }) => {
smartRequire(path.join(this.outputPath, name.split('?')[0]))
})

return smartRequire(mainAsset.path)
}

Expand Down

0 comments on commit d4428c6

Please sign in to comment.