mirror of
https://github.com/hanzoai/swc.git
synced 2026-10-30 19:42:53 +00:00
## Summary - add new `binding_html_wasm` crate based on the html node binding behavior - expose wasm-bindgen APIs for `minify`, `minifySync`, `minifyFragment`, and `minifyFragmentSync` - wire html wasm publish into release workflows (`publish.yml` + `publish-npm-package.yml`) - include `binding_html_wasm` in xtask wasm version bump list ## Validation - `git submodule update --init --recursive` - `./scripts/test.sh` (binding_html_wasm) - `./scripts/test.sh` (binding_core_wasm) - `./scripts/test.sh` (binding_minifier_wasm) - `./scripts/test.sh` (binding_typescript_wasm) - `./scripts/test.sh` (binding_es_ast_viewer) - `cargo test -p binding_html_wasm` - `cargo test -p xtask` - `cargo fmt --all` - `cargo clippy --all --all-targets -- -D warnings`
39 lines
1.2 KiB
JavaScript
39 lines
1.2 KiB
JavaScript
const swc = require("../pkg");
|
|
|
|
describe("html minify", () => {
|
|
it("supports sync minification", () => {
|
|
const output = swc.minifySync(
|
|
"<!doctype html><html><body><div class='a'> Hello world </div></body></html>",
|
|
{
|
|
collapseWhitespaces: "all",
|
|
removeComments: true,
|
|
}
|
|
);
|
|
|
|
expect(output.code).toBe("<!doctype html><div class=a>Hello world</div>");
|
|
expect(output.errors).toBeUndefined();
|
|
});
|
|
|
|
it("supports async minification", async () => {
|
|
const output = await swc.minify("<div> hello wasm </div>", {
|
|
collapseWhitespaces: "all",
|
|
});
|
|
|
|
expect(output.code).toBe("<div>hello wasm</div>");
|
|
});
|
|
|
|
it("supports fragment minification", async () => {
|
|
const output = await swc.minifyFragment("<span> foo </span>", {
|
|
collapseWhitespaces: "all",
|
|
contextElement: {
|
|
tagName: "template",
|
|
namespace: "http://www.w3.org/1999/xhtml",
|
|
attributes: [],
|
|
isSelfClosing: false,
|
|
},
|
|
});
|
|
|
|
expect(output.code).toBe("<span>foo</span>");
|
|
});
|
|
});
|