Skip to content

Commit f9f45a2

Browse files
feat(): reduce generated moduleNameMapper entry to one line
using an optimized regex which matches either an empty string or the subpath after the packageRoot
1 parent edfb575 commit f9f45a2

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/lib/library/library.factory.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,9 @@ function updateJestConfig(
113113
if (!jestOptions.moduleNameMapper) {
114114
jestOptions.moduleNameMapper = {};
115115
}
116-
const packageKeyRegex = '^' + packageKey + '$';
117-
const deepPackagePathRegex = '^' + packageKey + '/(.*)' + '$';
116+
const packageKeyRegex = '^' + packageKey + '(|/.*)$';
118117
const packageRoot = join('<rootDir>' as Path, distRoot);
119-
jestOptions.moduleNameMapper[deepPackagePathRegex] = join(packageRoot, '$1');
120-
jestOptions.moduleNameMapper[packageKeyRegex] = packageRoot;
118+
jestOptions.moduleNameMapper[packageKeyRegex] = join(packageRoot, '$1');
121119
}
122120

123121
function updateNpmScripts(

0 commit comments

Comments
 (0)