mirror of
https://github.com/larvit/adf-codec.git
synced 2026-11-19 06:35:44 +01:00
Measure each package as a namespace so default exports count, add the loaded JavaScript to the WebAssembly row, drop the growth claim
This commit is contained in:
@@ -310,20 +310,20 @@ cell adds it. This package's figure is the current source's.
|
||||
| `@larvit/adf-codec` | both ways | the same document | kept | markdown: lossless, portable; CommonMark in; HTML out; its own HTML in | 0 | 71 kB |
|
||||
| `@atlaskit/editor-markdown-transformer` 6.3.1 | markdown to ADF, through `@atlaskit/editor-json-transformer` 10.0.0; ADF to markdown throws "This is not implemented yet" | – | – | markdown | 5 | 177 kB, or 211 kB with `@atlaskit/editor-json-transformer` |
|
||||
| `@faulander/md2adf` 1.0.0 | both ways | a different document: the status is gone, the mention's `id` becomes its text and the panel a quote | dropped with its text | markdown | 2 | 99 kB |
|
||||
| `@nthings.dev/adf4j-wasm` 1.0.2 | ADF to markdown | – | replaced by the text `[Unsupported: futureThing]` | GitHub Flavored Markdown, from WebAssembly | 0 | 0.8 kB, and a WebAssembly module of 6.9 MB gzipped |
|
||||
| `@nthings.dev/adf4j-wasm` 1.0.2 | ADF to markdown | – | replaced by the text `[Unsupported: futureThing]` | GitHub Flavored Markdown, from WebAssembly | 0 | 0.9 kB, plus 7.5 kB of JavaScript it loads and a WebAssembly module of 6.9 MB |
|
||||
| `@wrtnlabs/markdown-to-adf` 1.0.2 | markdown to a list of blocks, not a document; fails ordinary input: `***bold italic***` comes out as italic text holding asterisks, and a paragraph holding a hard break stands between blocks | – | – | markdown | 2 | 21 kB |
|
||||
| `adf-converter` 0.1.0 | ADF to markdown; writes a mention as `@@Ann` | – | its text kept, with a console message | markdown | 0 | 1.8 kB |
|
||||
| `adf-md` 0.2.0 | both ways | a different document: the status without its `localId`, the marks in the other order | dropped with its text | markdown with MDX tags for panels, mentions and statuses | 6 | 137 kB |
|
||||
| `adf-to-markdown` 1.0.1 | ADF to markdown | – | dropped with its text | markdown | 0 | 2.4 kB |
|
||||
| `adf-to-md` 1.2.1 | ADF to markdown | – | dropped with its text, as are mentions, statuses and panels | markdown | 1 | 1.2 kB |
|
||||
| `adf2markdown` 1.2.0 | ADF to markdown | – | its text kept | markdown | 0 | 1.1 kB |
|
||||
| `adf-to-md` 1.2.1 | ADF to markdown | – | dropped with its text, as are mentions, statuses and panels | markdown | 1 | 1.1 kB |
|
||||
| `adf2markdown` 1.2.0 | ADF to markdown | – | its text kept | markdown | 0 | 1.2 kB |
|
||||
| `extended-markdown-adf-parser` 2.4.0 | both ways | a different document: the mention comes back as linked text, the status without its `localId` | written as JSON, read back as a paragraph of that JSON's text | markdown | 9 | 131 kB |
|
||||
| `github-markdown-adf` 1.3.0 | both ways | a different document: the mention comes back as text, the status as inline code, the marks in the other order | dropped with its text | markdown | 3 | 40 kB |
|
||||
| `markdown-to-adf` 0.2.20 | markdown to ADF; fails ordinary input: a quote is written as the node type `blockQuote`, which ADF spells `blockquote` | – | – | markdown | 3 | 58 kB |
|
||||
| `marklassian` 1.2.1 | markdown to ADF | – | – | markdown | 1 | 13 kB |
|
||||
| `md-adf` 0.2.2 | both ways, with a warning for each fallback | a different document: the mention and the status come back as text, the marks in the other order, the panel as a quote | dropped with its text, with a warning | markdown | 5 | 54 kB |
|
||||
| `md-to-adf` 0.6.4 | markdown to ADF; fails ordinary input: each list item is written as a list of its own | – | – | markdown | 2 | 6.8 kB |
|
||||
| `mdast-util-from-adf` 2.3.0 | ADF to an mdast tree, which `mdast-util-to-markdown` 2.2.2 writes as markdown; throws on a status | – | throws | markdown | 3 | 1.3 kB, or 24 kB with `mdast-util-to-markdown` |
|
||||
| `mdast-util-from-adf` 2.3.0 | ADF to an mdast tree, which `mdast-util-to-markdown` 2.2.2 writes as markdown; throws on a status | – | throws | markdown | 3 | 1.4 kB, or 24 kB with `mdast-util-to-markdown` |
|
||||
|
||||
The next table lists converters this comparison does not run: other ecosystems' libraries,
|
||||
Atlassian's own paths, and one npm package that needs a browser. Each row is what the project's
|
||||
|
||||
@@ -4,6 +4,7 @@ import { gzipSync } from "node:zlib";
|
||||
|
||||
const bytesPerKilobyte = 1000;
|
||||
|
||||
// A namespace export keeps default exports and same-named exports, which a star re-export drops.
|
||||
// What a consumer's bundler ships for the whole of the packages: their code and dependencies, minified, gzipped.
|
||||
export const minifiedGzippedBytes = async (resolveDir, specifiers) => {
|
||||
const { outputFiles } = await build({
|
||||
@@ -12,7 +13,7 @@ export const minifiedGzippedBytes = async (resolveDir, specifiers) => {
|
||||
logLevel: "silent",
|
||||
minify: true,
|
||||
platform: "node",
|
||||
stdin: { contents: specifiers.map((specifier) => `export * from ${JSON.stringify(specifier)};`).join("\n"), resolveDir },
|
||||
stdin: { contents: specifiers.map((specifier, i) => `import * as m${i} from ${JSON.stringify(specifier)}; export { m${i} };`).join("\n"), resolveDir },
|
||||
write: false,
|
||||
});
|
||||
return gzipSync(outputFiles[0].contents, { level: 9 }).length;
|
||||
|
||||
@@ -34,6 +34,17 @@ test("minified size counts every package it is given", async () => {
|
||||
assert.ok(await minifiedGzippedBytes(dir, ["./one.js", "./two.js"]) > await minifiedGzippedBytes(dir, ["./one.js"]) + 500);
|
||||
});
|
||||
|
||||
test("minified size counts a default export and exports two packages share by name", async () => {
|
||||
const dir = fixture({
|
||||
"first.js": `export const same = ${JSON.stringify(Array.from({ length: 200 }, (_, i) => (i * 2654435761 % 4294967296).toString(36)))};`,
|
||||
"second.js": `export const same = ${JSON.stringify(Array.from({ length: 200 }, (_, i) => (i * 40503 % 4294967296 * 65537).toString(36)))};`,
|
||||
"only-default.js": `export default ${JSON.stringify(Array.from({ length: 200 }, (_, i) => (i * 69069 % 4294967296 * 97).toString(36)))};`,
|
||||
});
|
||||
const first = await minifiedGzippedBytes(dir, ["./first.js"]);
|
||||
assert.ok(await minifiedGzippedBytes(dir, ["./first.js", "./second.js"]) > first + 500);
|
||||
assert.ok(await minifiedGzippedBytes(dir, ["./only-default.js"]) > 500);
|
||||
});
|
||||
|
||||
test("minified size counts the dependencies a bundler pulls in", async () => {
|
||||
const alone = fixture({ "entry.js": "export const a = 1;" });
|
||||
const withDependency = fixture({
|
||||
|
||||
@@ -111,7 +111,10 @@ const companions = {
|
||||
"minified and gzipped bytes with @atlaskit/editor-json-transformer": () => minifiedGzippedBytes(process.cwd(), ["@atlaskit/editor-markdown-transformer", "@atlaskit/editor-json-transformer"]),
|
||||
},
|
||||
"@nthings.dev/adf4j-wasm": {
|
||||
"WebAssembly module gzipped bytes": () => gzipSync(readFileSync("node_modules/@nthings.dev/adf4j-wasm/adf4j-wasm.js.wasm"), { level: 9 }).length,
|
||||
"bytes of its loaded JavaScript, minified and gzipped, and of its WebAssembly module, gzipped": async () => [
|
||||
await minifiedGzippedBytes(process.cwd(), ["./node_modules/@nthings.dev/adf4j-wasm/adf4j-wasm.js"]),
|
||||
gzipSync(readFileSync("node_modules/@nthings.dev/adf4j-wasm/adf4j-wasm.js.wasm"), { level: 9 }).length,
|
||||
].join(" and "),
|
||||
},
|
||||
"mdast-util-from-adf": {
|
||||
"minified and gzipped bytes with mdast-util-to-markdown": () => minifiedGzippedBytes(process.cwd(), ["mdast-util-from-adf", "mdast-util-to-markdown"]),
|
||||
|
||||
+3
-3
@@ -937,9 +937,9 @@ package with the same function. The README also states the tarball and the unpac
|
||||
|
||||
The build stays tsc's unminified output: a consumer has to add no step to read a stack trace or step
|
||||
through the package in a debugger, and the build takes no minifier. The gate fails where a stated figure
|
||||
for this package is more than a tenth off the measure. A tighter bound fails most pull requests, while a
|
||||
tenth still fails a release in which the package has grown by a tenth since its figure was last stated.
|
||||
The release job needs the gate, so a stale figure stops a release.
|
||||
for this package is more than a tenth off the measure. A tighter bound fails most pull requests, and a
|
||||
looser one lets a stated figure drift far from the build. The release job needs the gate, so a stale
|
||||
figure stops a release.
|
||||
|
||||
## Properties on a fixed seed
|
||||
|
||||
|
||||
Reference in New Issue
Block a user