mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-12-01 07:45:22 +03:00
Try making the compiled Elm garbage collectable by using the tip from https://gist.github.com/supermario/4c2615806c6c561a16edf5dd7208a759.
This commit is contained in:
parent
246a9d8a06
commit
f3937241e4
@ -14,10 +14,23 @@ async function spawnElmMake(elmEntrypointPath, outputPath, cwd) {
|
||||
|
||||
await fs.promises.writeFile(
|
||||
fullOutputPath,
|
||||
elmFileContent.replace(
|
||||
/return \$elm\$json\$Json\$Encode\$string\(.REPLACE_ME_WITH_JSON_STRINGIFY.\)/g,
|
||||
"return " + (debug ? "_Json_wrap(x)" : "x")
|
||||
)
|
||||
elmFileContent
|
||||
.replace(
|
||||
/return \$elm\$json\$Json\$Encode\$string\(.REPLACE_ME_WITH_JSON_STRINGIFY.\)/g,
|
||||
"return " + (debug ? "_Json_wrap(x)" : "x")
|
||||
)
|
||||
.replace(
|
||||
"return ports ? { ports: ports } : {};",
|
||||
`const die = function() {
|
||||
console.log('App dying')
|
||||
managers = null
|
||||
model = null
|
||||
stepper = null
|
||||
ports = null
|
||||
}
|
||||
|
||||
return ports ? { ports: ports, die: die } : { die: die };`
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -81,6 +81,8 @@ function runElmApp(compiledElmPath, pagePath, request, addDataSourceWatcher) {
|
||||
const args = fromElm.args[0];
|
||||
global.staticHttpCache = args.staticHttpCache;
|
||||
|
||||
app.die();
|
||||
delete require.cache[require.resolve(compiledElmPath)];
|
||||
if (isJson) {
|
||||
resolve({
|
||||
kind: "json",
|
||||
|
Loading…
Reference in New Issue
Block a user