( modulePath: string, prefix?: string, preferredName?: string, shortId: boolean = process.env.NODE_ENV === 'production', )
| 53 | * other characters. Useful for bundle size. Defaults to `true` in production. |
| 54 | */ |
| 55 | export function genChunkName( |
| 56 | modulePath: string, |
| 57 | prefix?: string, |
| 58 | preferredName?: string, |
| 59 | shortId: boolean = process.env.NODE_ENV === 'production', |
| 60 | ): string { |
| 61 | let chunkName = chunkNameCache.get(modulePath); |
| 62 | if (!chunkName) { |
| 63 | if (shortId) { |
| 64 | chunkName = simpleHash(modulePath, 8); |
| 65 | } else { |
| 66 | let str = modulePath; |
| 67 | if (preferredName) { |
| 68 | const shortHash = simpleHash(modulePath, 3); |
| 69 | str = `${preferredName}${shortHash}`; |
| 70 | } |
| 71 | const name = docuHash(str); |
| 72 | chunkName = prefix ? `${prefix}---${name}` : name; |
| 73 | } |
| 74 | const seenCount = (chunkNameCount.get(chunkName) ?? 0) + 1; |
| 75 | if (seenCount > 1) { |
| 76 | chunkName += seenCount.toString(36); |
| 77 | } |
| 78 | chunkNameCache.set(modulePath, chunkName); |
| 79 | chunkNameCount.set(chunkName, seenCount); |
| 80 | } |
| 81 | return chunkName; |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * Takes a piece of route config, and serializes it into raw JS code. The shape |
no test coverage detected
searching dependent graphs…