chunkStem
uses node:path
A chunk's name without its content hash (app-B4pb5ZHr.js → app, .js): the chunk a later build's of the same
name replaces, which a browser can use as a dictionary for it. Undefined for a file that isn't a chunk.
import path from "node:path"; export function chunkStem(file: string): { stem: string; ext: string } | undefined { const m = /^(.+)-[A-Za-z0-9_-]{8}(\.(?:js|css))$/.exec(path.basename(file)); return m ? { stem: m[1]!, ext: m[2]! } : undefined; }