Files
dioxus/packages/playwright-tests/wasm-split.spec.js
T
Jonathan Kelley bdeedc13eb feat: router-based wasm bundle splitting (#3683)
* feat: wasm-split base implementation

* kinda sorta works with the cli

* okay great it actually works

* fix: cache busting for chunks

* cleaned up version

* it works with the router

* wip: migrate to a faster linear solution using id remapping

* add a good harness

* it works completely on the docsite

* the super tight build works too

* make parallelizable

* works on the docsite but not the harness

* light cleanups, fix for both harness and docsite

* make codegen smaller by extract some shared functions to prevent monos

* chunking works, but tbd on tuning heuristics

* extract used module

* wip: cleaning up module

* wip: much better understanding of how imports work

* fix the call graph

* working again...

* wip: thinking about ifuncs

* ifunc approach works

* yes the ifunc approach works!!

* it all works completely even with chunks

* small cleanups

* comments

* actually locate all of the symbols

* clean up final implementation

* clean up tomls, revert some mono changs

* clean up, add some more comments / docs in places

* hoist more packages

* clean up impl a bit more

* clean cli

* move harness to playwright

* update playwright

* extract codgen

* add lazy to components

* Add docs to split loader

* clippy

* typos

* clippy, don't generate splits if not on wasm

* whoops, const

* Typos and docs

* enable optimizations in ci

* add optimizations to ci

* add wasm-split router feature

* parallel playwright?

* fix no case check

* disable pre-compress... think that might be the issue

* better logging, no default pre-compress, caching of shared symbols
* Fix: compressing assets

* fix non-interactive logging for serve

* cache playwright even on failure, use the cli with optimizations

* fix prebuild

* fix playwright webserver
2025-02-13 18:54:38 -08:00

50 lines
2.1 KiB
JavaScript

// @ts-check
const { test, expect } = require("@playwright/test");
test("wasm-split page is functional", async ({ page }) => {
// Wait for the dev server to load
await page.goto("http://localhost:8001");
// Make sure the local button works - no broken wasm
const counter = page.locator("#counter-display");
await expect(counter).toContainText("Count: 1");
await page.locator("#increment-counter").click();
await expect(counter).toContainText("Count: 2");
// Make sure the global button works - no broken wasm
const counterGlobal = page.locator("#global-counter");
await expect(counterGlobal).toContainText("Global Counter: 0");
await page.locator("#increment-counter-global").click();
await expect(counterGlobal).toContainText("Global Counter: 1");
// Fire one of the wasm modules to load. Should update the counter and add some text
const addBodyTextButton = page.locator("#add-body-text");
await addBodyTextButton.click();
await expect(counterGlobal).toContainText("Global Counter: 2");
const outputBox = page.locator("#output-box");
await expect(outputBox).toContainText("Rendered!");
// The other wasm module
const addBodyElementButton = page.locator("#add-body-element");
await addBodyElementButton.click();
await expect(counterGlobal).toContainText("Global Counter: 4");
await expect(outputBox).toContainText("Some inner div");
// Load the gzip and brotli modules
const gzipButton = page.locator("#gzip-it");
await gzipButton.click();
await expect(counterGlobal).toContainText("Global Counter: 7");
const brotliButton = page.locator("#brotli-it");
await brotliButton.click();
await expect(counterGlobal).toContainText("Global Counter: 11");
// Ignore the requests in CI
// Load the other router module
const childRouteButton = page.locator("#link-child");
await childRouteButton.click();
const nestedChildCounter = page.locator("#nested-child-count");
await expect(nestedChildCounter).toContainText("Count: hello");
await page.locator("#nested-child-add-world").click();
await expect(nestedChildCounter).toContainText("Count: hello world");
});