Skip to content

Commit

Permalink
move thunkfor out of class
Browse files Browse the repository at this point in the history
  • Loading branch information
soryy708 committed Mar 25, 2024
1 parent 76846b4 commit 4d276ef
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/exportMapBuilder.js
Expand Up @@ -202,6 +202,16 @@ export function recursivePatternCapture(pattern, callback) {
}
}

/**
* The creation of this closure is isolated from other scopes
* to avoid over-retention of unrelated variables, which has
* caused memory leaks. See #1266.
*/
function thunkFor(p, context) {
// eslint-disable-next-line no-use-before-define
return () => ExportMapBuilder.for(childContext(p, context));
}

export default class ExportMapBuilder {
static get(source, context) {
const path = resolve(source, context);
Expand Down Expand Up @@ -326,15 +336,6 @@ export default class ExportMapBuilder {
return resolve.relative(value, path, context.settings);
}

/**
* The creation of this closure is isolated from other scopes
* to avoid over-retention of unrelated variables, which has
* caused memory leaks. See #1266.
*/
function thunkFor(p, context) {
return () => ExportMapBuilder.for(childContext(p, context));
}

function processDynamicImport(source) {
hasDynamicImports = true;
if (source.type !== 'Literal') {
Expand Down

0 comments on commit 4d276ef

Please sign in to comment.