(compilation, chunk, runtimeChunk)
| 36 | * @returns {string} the relative path |
| 37 | */ |
| 38 | const getRelativePath = (compilation, chunk, runtimeChunk) => { |
| 39 | const currentOutputName = compilation |
| 40 | .getPath( |
| 41 | getChunkFilenameTemplate(runtimeChunk, compilation.outputOptions), |
| 42 | { |
| 43 | chunk: runtimeChunk, |
| 44 | contentHashType: "javascript" |
| 45 | } |
| 46 | ) |
| 47 | .replace(/^\/+/g, "") |
| 48 | .split("/"); |
| 49 | const baseOutputName = [...currentOutputName]; |
| 50 | const chunkOutputName = compilation |
| 51 | .getPath(getChunkFilenameTemplate(chunk, compilation.outputOptions), { |
| 52 | chunk, |
| 53 | contentHashType: "javascript" |
| 54 | }) |
| 55 | .replace(/^\/+/g, "") |
| 56 | .split("/"); |
| 57 | |
| 58 | // remove common parts except filename |
| 59 | while ( |
| 60 | baseOutputName.length > 1 && |
| 61 | chunkOutputName.length > 1 && |
| 62 | baseOutputName[0] === chunkOutputName[0] |
| 63 | ) { |
| 64 | baseOutputName.shift(); |
| 65 | chunkOutputName.shift(); |
| 66 | } |
| 67 | const last = chunkOutputName.join("/"); |
| 68 | // create final path |
| 69 | return getUndoPath(baseOutputName.join("/"), last, true) + last; |
| 70 | }; |
| 71 | |
| 72 | /** |
| 73 | * Renders chunk import. |
no test coverage detected