| | |
| | | /** @typedef {import("../Chunk").ChunkId} ChunkId */ |
| | | /** @typedef {import("../ChunkGraph")} ChunkGraph */ |
| | | /** @typedef {import("../Compilation")} Compilation */ |
| | | /** @typedef {import("../Compilation").HashWithLengthFunction} HashWithLengthFunction */ |
| | | /** @typedef {import("../TemplatedPathPlugin").TemplatePath} TemplatePath */ |
| | | |
| | | class GetChunkFilenameRuntimeModule extends RuntimeModule { |
| | |
| | | */ |
| | | constructor(contentType, name, global, getFilenameForChunk, allChunks) { |
| | | super(`get ${name} chunk filename`); |
| | | /** @type {string} */ |
| | | this.contentType = contentType; |
| | | /** @type {string} */ |
| | | this.global = global; |
| | | /** @type {(chunk: Chunk) => TemplatePath | false} */ |
| | | this.getFilenameForChunk = getFilenameForChunk; |
| | | /** @type {boolean} */ |
| | | this.allChunks = allChunks; |
| | | /** @type {boolean} */ |
| | | this.dependentHash = true; |
| | | } |
| | | |
| | | /** |
| | | * Generates runtime code for this runtime module. |
| | | * @returns {string | null} runtime code |
| | | */ |
| | | generate() { |
| | |
| | | }; |
| | | /** |
| | | * @param {string} value string |
| | | * @returns {(length: number) => string} string to put in quotes with length |
| | | * @returns {HashWithLengthFunction} string to put in quotes with length |
| | | */ |
| | | const unquotedStringifyWithLength = (value) => (length) => |
| | | unquotedStringify(`${value}`.slice(0, length)); |
| | |
| | | |
| | | /** |
| | | * @param {(chunk: Chunk) => string | number} fn function from chunk to value |
| | | * @returns {(length: number) => string} function which generates code with static mapping of results of fn for including in quoted string for specific length |
| | | * @returns {HashWithLengthFunction} function which generates code with static mapping of results of fn for including in quoted string for specific length |
| | | */ |
| | | const mapExprWithLength = (fn) => (length) => |
| | | `" + ${createMap((c) => `${fn(c)}`.slice(0, length))} + "`; |