| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 99eba98 commit d22c2bc
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,14 +8,14 @@ const ImportDependency = require('webpack/lib/dependencies/ImportDependency'); | |||
| 8 | 8 | export class NamedLazyChunksWebpackPlugin extends webpack.NamedChunksPlugin { | |
| 9 | 9 | constructor() { | |
| 10 | 10 | // Append a dot and number if the name already exists. | |
| 11 | - const nameMap = new Map<string, boolean>(); | ||
| 12 | - function getUniqueName(baseName: string) { | ||
| 11 | + const nameMap = new Map<string, string>(); | ||
| 12 | + function getUniqueName(baseName: string, request: string) { | ||
| 13 | 13 | let name = baseName; | |
| 14 | 14 | let num = 0; | |
| 15 | - while (nameMap.has(name)) { | ||
| 15 | + while (nameMap.has(name) && nameMap.get(name) !== request) { | ||
| 16 | 16 | name = `${baseName}.${num++}`; | |
| 17 | 17 | } | |
| 18 | - nameMap.set(name, true); | ||
| 18 | + nameMap.set(name, request); | ||
| 19 | 19 | return name; | |
| 20 | 20 | } | |
| 21 | 21 | ||
@@ -34,13 +34,13 @@ export class NamedLazyChunksWebpackPlugin extends webpack.NamedChunksPlugin { | |||
| 34 | 34 | || chunk.blocks[0].dependencies[0] instanceof ImportDependency) | |
| 35 | 35 | ) { | |
| 36 | 36 | // Create chunkname from file request, stripping ngfactory and extension. | |
| 37 | - const req = chunk.blocks[0].dependencies[0].request; | ||
| 38 | - const chunkName = basename(req).replace(/(\.ngfactory)?\.(js|ts)$/, ''); | ||
| 37 | + const request = chunk.blocks[0].dependencies[0].request; | ||
| 38 | + const chunkName = basename(request).replace(/(\.ngfactory)?\.(js|ts)$/, ''); | ||
| 39 | 39 | if (!chunkName || chunkName === '') { | |
| 40 | 40 | // Bail out if something went wrong with the name. | |
| 41 | 41 | return null; | |
| 42 | 42 | } | |
| 43 | - return getUniqueName(chunkName); | ||
| 43 | + return getUniqueName(chunkName, request); | ||
| 44 | 44 | } | |
| 45 | 45 | ||
| 46 | 46 | return null; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments