Use clear-module to clear require cache of dependencies
This commit is contained in:
parent
423f19de68
commit
b247d73fcb
@ -54,6 +54,7 @@
|
||||
"@typescript-eslint/eslint-plugin": "^4.2.0",
|
||||
"@typescript-eslint/parser": "^4.2.0",
|
||||
"chokidar": "^3.5.1",
|
||||
"clear-module": "^4.1.1",
|
||||
"concurrently": "^6.0.0",
|
||||
"eslint": "^7.9.0",
|
||||
"eslint-plugin-import": "^2.22.1",
|
||||
|
@ -1,9 +1,9 @@
|
||||
import "../../node_modules/svelte/register.js";
|
||||
|
||||
import clearModule from "clear-module";
|
||||
import config from "config";
|
||||
import crypto from "crypto";
|
||||
import {promises as fs} from 'fs';
|
||||
import {nanoid} from "nanoid";
|
||||
import path from "path";
|
||||
import requireFromString from "require-from-string";
|
||||
import {compile, preprocess} from "svelte/compiler";
|
||||
@ -304,7 +304,9 @@ export default class SvelteViewEngine extends ViewEngine {
|
||||
});
|
||||
|
||||
// Load module and render
|
||||
return requireFromString(svelteSsr.js.code, file + nanoid() + '.js').default.render();
|
||||
const moduleId = path.resolve(file);
|
||||
clearModule.single(moduleId);
|
||||
return requireFromString(svelteSsr.js.code, moduleId).default.render();
|
||||
}
|
||||
}
|
||||
|
||||
|
17
yarn.lock
17
yarn.lock
@ -1642,7 +1642,7 @@ callsite@1.0.0:
|
||||
resolved "https://registry.yarnpkg.com/callsite/-/callsite-1.0.0.tgz#280398e5d664bd74038b6f0905153e6e8af1bc20"
|
||||
integrity sha1-KAOY5dZkvXQDi28JBRU+borxvCA=
|
||||
|
||||
callsites@^3.0.0:
|
||||
callsites@^3.0.0, callsites@^3.1.0:
|
||||
version "3.1.0"
|
||||
resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73"
|
||||
integrity sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==
|
||||
@ -1794,6 +1794,14 @@ clean-css@^4.2.1:
|
||||
dependencies:
|
||||
source-map "~0.6.0"
|
||||
|
||||
clear-module@^4.1.1:
|
||||
version "4.1.1"
|
||||
resolved "https://registry.yarnpkg.com/clear-module/-/clear-module-4.1.1.tgz#bf8ba3b62eb70ee1e0adec90589741425cf32db8"
|
||||
integrity sha512-ng0E7LeODcT3QkazOckzZqbca+JByQy/Q2Z6qO24YsTp+pLxCfohGz2gJYJqZS0CWTX3LEUiHOqe5KlYeUbEMw==
|
||||
dependencies:
|
||||
parent-module "^2.0.0"
|
||||
resolve-from "^5.0.0"
|
||||
|
||||
cli-boxes@^2.2.0:
|
||||
version "2.2.1"
|
||||
resolved "https://registry.yarnpkg.com/cli-boxes/-/cli-boxes-2.2.1.tgz#ddd5035d25094fce220e9cab40a45840a440318f"
|
||||
@ -5682,6 +5690,13 @@ parent-module@^1.0.0:
|
||||
dependencies:
|
||||
callsites "^3.0.0"
|
||||
|
||||
parent-module@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/parent-module/-/parent-module-2.0.0.tgz#fa71f88ff1a50c27e15d8ff74e0e3a9523bf8708"
|
||||
integrity sha512-uo0Z9JJeWzv8BG+tRcapBKNJ0dro9cLyczGzulS6EfeyAdeC9sbojtW6XwvYxJkEne9En+J2XEl4zyglVeIwFg==
|
||||
dependencies:
|
||||
callsites "^3.1.0"
|
||||
|
||||
parse-json@^2.2.0:
|
||||
version "2.2.0"
|
||||
resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-2.2.0.tgz#f480f40434ef80741f8469099f8dea18f55a4dc9"
|
||||
|
Loading…
Reference in New Issue
Block a user