mirror of
https://github.com/thelounge/thelounge.git
synced 2026-08-01 07:36:26 -04:00
``` Webpack vs Vite Build Comparison ┌────────────┬──────────────────────┬────────────────────┬───────────────┐ │ Metric │ Webpack 5 │ Vite 8 (Rolldown) │ Change │ ├────────────┼──────────────────────┼────────────────────┼───────────────┤ │ Build time │ 1,961ms (2.96s wall) │ 612ms (0.82s wall) │ 3.2x faster │ ├────────────┼──────────────────────┼────────────────────┼───────────────┤ │ CPU time │ 11.0s user │ 1.3s user │ 8.5x less CPU │ └────────────┴──────────────────────┴────────────────────┴───────────────┘ Bundle sizes (gzipped) ┌────────────────┬─────────┬────────┬────────┐ │ Asset │ Webpack │ Vite │ Change │ ├────────────────┼─────────┼────────┼────────┤ │ App JS │ 152.6K │ 104.9K │ -31% │ ├────────────────┼─────────┼────────┼────────┤ │ Vendor JS │ 251.1K │ 81.6K │ -68% │ ├────────────────┼─────────┼────────┼────────┤ │ Runtime JS │ — │ 0.5K │ new │ ├────────────────┼─────────┼────────┼────────┤ │ Total JS │ 403.7K │ 187.0K │ -54% │ ├────────────────┼─────────┼────────┼────────┤ │ CSS │ 12.5K │ 11.9K │ -5% │ ├────────────────┼─────────┼────────┼────────┤ │ Total transfer │ 416.2K │ 198.9K │ -52% │ └────────────────┴─────────┴────────┴────────┘ Raw (uncompressed) ┌───────────────┬─────────┬──────┬────────┐ │ Asset │ Webpack │ Vite │ Change │ ├───────────────┼─────────┼──────┼────────┤ │ App JS │ 1.3M │ 304K │ -77% │ ├───────────────┼─────────┼──────┼────────┤ │ Vendor JS │ 1.1M │ 236K │ -79% │ ├───────────────┼─────────┼──────┼────────┤ │ CSS │ 64K │ 56K │ -13% │ ├───────────────┼─────────┼──────┼────────┤ │ Total public/ │ 5.1M │ 3.4M │ -33% │ └───────────────┴─────────┴──────┴────────┘ ``` --------- Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
60 lines
1.5 KiB
TypeScript
60 lines
1.5 KiB
TypeScript
import {expect} from "vitest";
|
|
|
|
import Msg from "../../server/models/msg";
|
|
import User from "../../server/models/user";
|
|
import {LinkPreview} from "../../shared/types/msg";
|
|
|
|
describe("Msg", function () {
|
|
["from", "target"].forEach((prop) => {
|
|
it(`should keep a copy of the original user in the \`${prop}\` property`, function () {
|
|
const prefixLookup = {modeToSymbol: {a: "&", o: "@"}};
|
|
const user = new User(
|
|
{
|
|
modes: ["o"],
|
|
nick: "foo",
|
|
},
|
|
prefixLookup as any
|
|
);
|
|
const msg = new Msg({[prop]: user});
|
|
|
|
// Mutating the user
|
|
user.setModes(["a"], prefixLookup as any);
|
|
user.nick = "bar";
|
|
|
|
// Message's `.from`/etc. should still refer to the original user
|
|
expect(msg[prop]).to.deep.equal({mode: "@", nick: "foo"});
|
|
});
|
|
});
|
|
|
|
describe("#findPreview(link)", function () {
|
|
const msg = new Msg({
|
|
previews: [
|
|
{
|
|
body: "",
|
|
head: "Example Domain",
|
|
link: "https://example.org/",
|
|
thumb: "",
|
|
type: "link",
|
|
shown: true,
|
|
},
|
|
{
|
|
body: "",
|
|
head: "The Lounge",
|
|
link: "https://thelounge.chat/",
|
|
thumb: "",
|
|
type: "link",
|
|
shown: true,
|
|
},
|
|
] as LinkPreview[],
|
|
});
|
|
|
|
it("should find a preview given an existing link", function () {
|
|
expect(msg.findPreview("https://thelounge.chat/")?.head).to.equal("The Lounge");
|
|
});
|
|
|
|
it("should not find a preview that does not exist", function () {
|
|
expect(msg.findPreview("https://github.com/thelounge/thelounge")).to.be.undefined;
|
|
});
|
|
});
|
|
});
|