Skip to content

Commit 7205b1c

Browse files
committed
Prevent disposing stubbed modules
1 parent 82872a5 commit 7205b1c

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

packages/app/src/sandbox/eval/entities/module.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ export type Module = {
55
code: string,
66
requires?: Array<string>,
77
downloaded?: boolean,
8+
/** Whether the module was created as stub for the "browsers" package field */
9+
stubbed?: boolean,
810
};

packages/app/src/sandbox/eval/npm/fetch-npm-module.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ export default async function fetchModule(
334334
: pathUtils.join(currentPath, path),
335335
code: 'module.exports = {};',
336336
requires: [],
337+
stubbed: true,
337338
};
338339
}
339340

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import type { WarningStructure } from './transpilers/utils/worker-warning-handle
1717

1818
import resolveDependency from './loaders/dependency-resolver';
1919
import evaluate from './loaders/eval';
20-
import isESModule from './utils/is-es-module';
2120

2221
import type { default as Manager } from './manager';
2322
import HMR from './hmr';
@@ -977,7 +976,10 @@ export default class TranspiledModule {
977976
this.initiators.size === 0 &&
978977
this.transpilationInitiators.size === 0 &&
979978
!this.isEntry &&
980-
!manager.isFirstLoad
979+
!manager.isFirstLoad &&
980+
// Don't delete stubbed modules, they are here for a reason, most probably
981+
// because they are aliased with a browser field
982+
!this.module.stubbed
981983
) {
982984
// Remove the module from the transpiler if it's not used anymore
983985
debug(`Removing '${this.getId()}' from manager.`);

0 commit comments

Comments
 (0)