Skip to content

Commit 3ce0165

Browse files
committed
Fix reusing cache with transpilation dependencies
1 parent c6fe10a commit 3ce0165

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

packages/app/src/sandbox/eval/transpiled-module.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,6 @@ export default class TranspiledModule {
800800
// eslint-disable-next-line no-inner-declarations
801801
function require(path: string) {
802802
const usedPath = manager.getPresetAliasedPath(path);
803-
804803
const bfsModule = BrowserFS.BFSRequire(usedPath);
805804

806805
if (bfsModule) {
@@ -949,7 +948,11 @@ export default class TranspiledModule {
949948
this.isTestFile = data.isTestFile;
950949
this.source = data.source;
951950

952-
const loadModule = (depId: string, initiator = false) => {
951+
const loadModule = (
952+
depId: string,
953+
initiator = false,
954+
transpilation = false
955+
) => {
953956
if (state[depId]) {
954957
return state[depId];
955958
}
@@ -961,9 +964,17 @@ export default class TranspiledModule {
961964
const tModule = manager.getTranspiledModule(module, query);
962965

963966
if (initiator) {
964-
tModule.dependencies.add(this);
967+
if (transpilation) {
968+
tModule.transpilationDependencies.add(this);
969+
} else {
970+
tModule.dependencies.add(this);
971+
}
965972
} else {
966-
tModule.initiators.add(this);
973+
if (transpilation) {
974+
tModule.transpilationInitiators.add(this);
975+
} else {
976+
tModule.initiators.add(this);
977+
}
967978
}
968979

969980
return tModule;
@@ -979,10 +990,10 @@ export default class TranspiledModule {
979990
this.initiators.add(loadModule(depId, true));
980991
});
981992
data.transpilationDependencies.forEach((depId: string) => {
982-
this.transpilationDependencies.add(loadModule(depId));
993+
this.transpilationDependencies.add(loadModule(depId, false, true));
983994
});
984995
data.transpilationInitiators.forEach((depId: string) => {
985-
this.transpilationInitiators.add(loadModule(depId, true));
996+
this.transpilationInitiators.add(loadModule(depId, true, true));
986997
});
987998

988999
data.asyncDependencies.forEach((depId: string) => {

0 commit comments

Comments
 (0)