Skip to content

Commit

Permalink
fix: use flatMap/map
Browse files Browse the repository at this point in the history
  • Loading branch information
nolanlawson committed Apr 14, 2022
1 parent 72c40f9 commit 88867d1
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions packages/@lwc/babel-plugin-component/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,16 @@ function getEngineImportsStatements(path) {

function getEngineImportSpecifiers(path) {
const imports = getEngineImportsStatements(path);

return imports
.reduce((acc, importStatement) => {
return (
imports
// Flat-map the specifier list for each import statement
return [...acc, ...importStatement.get('specifiers')];
}, [])
.reduce((acc, specifier) => {
.flatMap((importStatement) => importStatement.get('specifiers'))
// Get the list of specifiers with their name
const imported = specifier.get('imported').node.name;
return [...acc, { name: imported, path: specifier }];
}, []);
.map((specifier) => {
const imported = specifier.get('imported').node.name;
return { name: imported, path: specifier };
})
);
}

function normalizeFilename(source) {
Expand Down

0 comments on commit 88867d1

Please sign in to comment.