diff --git a/src/exportMapBuilder.js b/src/exportMapBuilder.js index 2993c9971..5aeb306d0 100644 --- a/src/exportMapBuilder.js +++ b/src/exportMapBuilder.js @@ -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); @@ -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') {