yaml icon indicating copy to clipboard operation
yaml copied to clipboard

Drop separation between Node.js and browser builds

Open eemeli opened this issue 1 week ago • 3 comments

The dual browser + Node.js build using Rollup is dropped, and replaced by a single Rolldown build producing ES modules.

The most significant change for users is that the default export is dropped, and so the following change may be required to user code:

-import YAML from 'yaml'
+import * as YAML from 'yaml'

The minimum supported Node.js and TypeScript versions are updated to what's needed for require(esm) support, i.e. Node.js 20.19 and TS 5.9; similarly, the library is now tested in Chrome 93 and Firefox 94, though no specific versions of browsers are explicitly supported without transpilation.

Getting the test:dist task to work with Jest was too much hassle, so this also includes a switch from it to Vitest, which effectively "just works". It's also configurable to run (most of) the whole test suite in browsers, so that's now done rather than the minimal smoke test that was used before.

I was not able to figure out how to configure Vitest with the WebdriverIO provider to get it to work with Browserstack, and so switched to Playwright; getting that to then also work from GitHub Actions was yet another hassle.

All of the above also allows dropping the tests from the playground repo, so it doesn't need to be handled as a git submodule any more, and it's only the playground now.

After these changes, the deployed on-disk size of the library is reduced from around 1.2 MB to 0.3 MB, and the compressed size reduces from 107 kB to 71 kB.

eemeli avatar Dec 14 '25 11:12 eemeli

the deployed on-disk size of the library is reduced from around 1.2 MB to 0.3

FYI, according to https://packagephobia.com/result?p=yaml, it's currently at 667 KB, not 1.2MB. The 257 published file count seems quite large, I hope that will be reduced as well.

silverwind avatar Dec 16 '25 23:12 silverwind

FYI, according to https://packagephobia.com/result?p=yaml, it's currently at 667 KB, not 1.2MB. The 257 published file count seems quite large, I hope that will be reduced as well.

I'm not sure how they're measuring file size, but on my MacBook I see this:

$ npm install --no-save yaml
$ du -hs node_modules/yaml
1.2M	node_modules/yaml

eemeli avatar Dec 17 '25 06:12 eemeli

Right, I see similar, 792kB in dist, 452kB in browser:

du -sh node_modules/yaml
1.3M  node_modules/yaml

silverwind avatar Dec 17 '25 10:12 silverwind

Merging in order to work on next steps separately, and not pile them on here.

eemeli avatar Dec 20 '25 08:12 eemeli