From 849cd9f11d0d355ebfe1b6c117e0254b965022ce Mon Sep 17 00:00:00 2001 From: Conduitry Date: Tue, 12 Oct 2021 15:50:05 -0400 Subject: [PATCH] DRY rewriting of imports --- src/compiler/compile/create_module.ts | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/compiler/compile/create_module.ts b/src/compiler/compile/create_module.ts index d501bde95a..c9f925c4b4 100644 --- a/src/compiler/compile/create_module.ts +++ b/src/compiler/compile/create_module.ts @@ -93,20 +93,15 @@ function esm( const internal_globals = get_internal_globals(globals, helpers); // edit user imports - imports.forEach(node => { + function rewrite_import(node) { const value = edit_source(node.source.value, sveltePath); if (node.source.value !== value) { node.source.value = value; node.source.raw = null; } - }); - exports_from.forEach(node => { - const value = edit_source(node.source.value, sveltePath); - if (node.source.value !== value) { - node.source.value = value; - node.source.raw = null; - } - }); + } + imports.forEach(rewrite_import); + exports_from.forEach(rewrite_import); const exports = module_exports.length > 0 && { type: 'ExportNamedDeclaration',