Optimize loading of date-fns

This commit is contained in:
Bill Thornton 2022-11-03 00:52:12 -04:00
parent 88a01888bf
commit b3febe49ad
4 changed files with 97 additions and 74 deletions

View file

@ -113,6 +113,21 @@ const config = {
return `node_modules.${parts[0]}.${parts[1]}`;
}
if (packageName === 'date-fns') {
const parts = module.context
.substring(module.context.lastIndexOf(packageName))
.split(/[\\/]/);
let name = `node_modules.${parts[0]}`;
if (parts[1]) {
name += `.${parts[1]}`;
}
if (parts[1] === 'locale') {
name += `.${parts[2]}`;
}
return name;
}
return `node_modules.${packageName}`;
}
}