mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-11 08:07:26 +02:00
perf(v2): skip runtime fileHash cache in prod & get timestamp asynchronously (#1951)
* skip hash calculation in prod when generating file * perf: convert lastUpdated to be async process * changelog
This commit is contained in:
parent
e04c8f140f
commit
639d8d3eac
8 changed files with 107 additions and 42 deletions
|
@ -17,8 +17,16 @@ export async function generate(
|
|||
generatedFilesDir: string,
|
||||
file: string,
|
||||
content: any,
|
||||
skipCache: boolean = process.env.NODE_ENV === 'production',
|
||||
): Promise<void> {
|
||||
const filepath = path.join(generatedFilesDir, file);
|
||||
|
||||
if (skipCache) {
|
||||
await fs.ensureDir(path.dirname(filepath));
|
||||
await fs.writeFile(filepath, content);
|
||||
return;
|
||||
}
|
||||
|
||||
const lastHash = fileHash.get(filepath);
|
||||
const currentHash = createHash('md5')
|
||||
.update(content)
|
||||
|
@ -110,7 +118,7 @@ export function genChunkName(
|
|||
modulePath: string,
|
||||
prefix?: string,
|
||||
preferredName?: string,
|
||||
shortId?: boolean,
|
||||
shortId: boolean = process.env.NODE_ENV === 'production',
|
||||
): string {
|
||||
let chunkName: string | undefined = chunkNameCache.get(modulePath);
|
||||
if (!chunkName) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue