/
githubmirror
/
webpack
Обзор
Документация
Войти
/
githubmirror
/
webpack
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
test/configCases/worker/worker-module-hashed/index.js
33 строки
1006 B
Alexander Akait
feat(esm): bake analyzable references per asset, and drop the asset wrapper no one reads (#21688)
12 авг 2026, 15:50
Не верифицирован
12 авг 2026, 15:50
7299185
Код
Авторство
О чём код?
import { Worker } from "worker_threads"; import fs from "fs"; import path from "path"; it("should run an ESM worker with a content-hashed chunk filename", async () => { const worker = new Worker(new URL("./worker.js", import.meta.url), { type: "module" }); const result = await new Promise((resolve, reject) => { worker.on("message", resolve); worker.on("error", reject); worker.postMessage("ok"); }); expect(result).toBe("data: OK, thanks"); await worker.terminate(); }); it("should bake a hashed worker chunk name the deferred pass fills in", () => { const bundle = fs.readFileSync( path.join(__STATS__.outputPath, "bundle0.mjs"), "utf8" ); const specifier = new RegExp(`worker ${"import"} \\*/ "([^"]+)"`).exec(bundle); expect(specifier).not.toBe(null); expect(fs.existsSync(path.join(__STATS__.outputPath, specifier[1]))).toBe( true ); // The name is settled, so nothing looks it up by chunk id any more. expect(bundle).not.toContain(`${"__webpack_require__"}.u`); });