Skip to content

Commit 7271b4b

Browse files
author
Jannik Zschiesche
committed
Cache matches in package loader
1 parent 404c018 commit 7271b4b

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/Kaba.ts

+11-3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const { CleanWebpackPlugin } = require('clean-webpack-plugin');
1313

1414
const PACKAGE_MATCHER = /\/node_modules\/(?<package>(?:@[^@\/]+\/)?[^@\/]+)\//;
1515
type IgnoredNpmPackagesMapping = Array<RegExp|string>;
16+
const ignoredPackagesCache: {[k: string]: boolean} = {};
1617
interface PostCssLoaderOptions {[key: string]: any}
1718

1819
interface Entries
@@ -47,6 +48,11 @@ function isAllowedPath (path: string, ignoredPackages: IgnoredNpmPackagesMapping
4748

4849
const packageNameToCompile = (match.groups as any).package;
4950

51+
if (undefined !== ignoredPackagesCache[packageNameToCompile])
52+
{
53+
return ignoredPackagesCache[packageNameToCompile];
54+
}
55+
5056
const length = ignoredPackages.length;
5157
for (let i = 0; i < length; ++i)
5258
{
@@ -56,16 +62,16 @@ function isAllowedPath (path: string, ignoredPackages: IgnoredNpmPackagesMapping
5662
{
5763
if (ignoredPackage === packageNameToCompile)
5864
{
59-
return false;
65+
return ignoredPackagesCache[packageNameToCompile] = false;
6066
}
6167
}
6268
else if (ignoredPackage.test(packageNameToCompile))
6369
{
64-
return false;
70+
return ignoredPackagesCache[packageNameToCompile] = false;
6571
}
6672
}
6773

68-
return true;
74+
return ignoredPackagesCache[packageNameToCompile] = true;
6975
}
7076

7177
/**
@@ -92,6 +98,8 @@ export class Kaba
9298
private nodeSettings: webpack.Node|false = false;
9399
private ignoredNpmPackages: IgnoredNpmPackagesMapping = [
94100
/^@babel/,
101+
/^babel-/,
102+
/^core-js(-|$)/,
95103
/^regenerator-/,
96104
];
97105
private postCssLoaderOptions: PostCssLoaderOptions = {};

0 commit comments

Comments
 (0)