Skip to content

Commit

Permalink
Make requireFiles do less work for larger applications (#470)
Browse files Browse the repository at this point in the history
  • Loading branch information
misterbyrne authored and patocallaghan committed Oct 21, 2022
1 parent 01d7eb5 commit e82fd54
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions addon/utils/helper-functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export function parseUrl(url) {
}

// always exclude jshint or jscs files
export const excludeRegex = new RegExp('[^\\s]+(\\.(jscs|jshint))$', 'i');
export const excludeRegex = /\.(jscs|jshint)$/i;

/**
* Find files that have been seen by some tree in the application
Expand All @@ -210,7 +210,10 @@ export const excludeRegex = new RegExp('[^\\s]+(\\.(jscs|jshint))$', 'i');
export function requireFiles(filePattern) {
let filesSeen = Object.keys(requirejs._eak_seen);

return filesSeen.filter((moduleName) => {
return !excludeRegex.test(moduleName) && filePattern.test(moduleName);
}).map((moduleName) => require(moduleName, null, null, true));
return filesSeen
.filter(
(moduleName) =>
filePattern.test(moduleName) && !excludeRegex.test(moduleName)
)
.map((moduleName) => require(moduleName, null, null, true));
}

0 comments on commit e82fd54

Please sign in to comment.