/
githubmirror
/
webpack
Обзор
Документация
Войти
/
githubmirror
/
webpack
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
test/configCases/html/output-html-split-chunks/test.js
33 строки
1 KB
Alexander Akait
feat(html): generate output.html for entrypoints with dependOn support (#21215)
18 июн 2026, 23:04
Не верифицирован
18 июн 2026, 23:04
868209f
Код
Авторство
О чём код?
const fs = require("fs"); const path = require("path"); const vm = require("vm"); const read = (file) => fs.readFileSync(path.resolve(__dirname, file), "utf-8"); // Match the `src` attribute rather than the whole tag — the page only puts // `src` on `<script>` (links use `href`), and an attribute regexp avoids // CodeQL's bad-HTML-tag-filter rule. `RegExp.exec` keeps this Node 10 safe // (no `String.prototype.matchAll`). const scriptSrcs = (html) => { const re = /src="([^"]+)"/g; const srcs = []; let match; while ((match = re.exec(html)) !== null) srcs.push(match[1]); return srcs; }; it("injects the runtime and vendor chunks before the entry chunk", () => { const srcs = scriptSrcs(read("app.html")); // runtime, vendor, app expect(srcs).toHaveLength(3); expect(srcs[0]).toMatch(/runtime/); expect(srcs[1]).toMatch(/vendor/); }); it("executes with the split chunks loaded in order", () => { const contents = scriptSrcs(read("app.html")).map(read); const sandbox = {}; sandbox.self = sandbox; vm.createContext(sandbox); for (const content of contents) vm.runInContext(content, sandbox); expect(sandbox.order).toEqual(["APP:LIB_VALUE"]); });