Skip to content

Rename the entries to index.js and index.mjs, and generate index.mjs from the addon - #1342

Merged
uNetworkingAB merged 1 commit into
uNetworking:masterfrom
nigrosimone:esm-index
Oct 1, 2026
Merged

uNetworkingAB merged 1 commit into
uNetworking:masterfrom
nigrosimone:esm-index

Conversation

@nigrosimone

@nigrosimone nigrosimone commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

For #1314. src/uws.js becomes src/index.js, and build.c writes dist/index.mjs with src/esm.js from what dist/index.js exports, so the ESM entry cannot go out of date. The build workflow copies both to binaries and adds them there (commit -a skips new files).

Examples import ../dist/index.mjs, tests require ../dist/index.js. The benchmark still loads uws.js when the base is from before the rename.

Test: tests/esm.mjs, in the build workflow, checks that the ESM default is the CommonJS module, that the named exports are the CommonJS keys with the same values, and that a server started from require and one from import both answer. It fails without index.mjs and with a wrapper that misses an export.

If you merge this, please merge also #1343: it points package.json on binaries to the new files. Until then binaries keeps the old uws.js and ESM_wrapper.mjs, which still work but are not updated any more.

@nigrosimone
nigrosimone marked this pull request as ready for review October 1, 2026 05:16
@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown

Benchmark: 0b62c33 against 4d51bb4

Scenario Base req/s Head req/s Head / base Rounds Noise Busy CPU per request
http/hello-world 140783 141692 1.003x (+0.3%) 1.00 to 1.01 ±1.2% 100% / 100% 7.10 / 7.05 us (0.997x)
http/headers 120532 120622 0.999x (-0.1%) 0.99 to 1.00 ±0.8% 100% / 100% 8.29 / 8.28 us (1.001x)
http/json-post 110658 110394 1.001x (+0.1%) 0.99 to 1.01 ±2.4% 100% / 100% 9.03 / 9.05 us (0.999x)
http/cached 157713 157871 1.005x (+0.5%) 1.00 to 1.01 ±1.4% 100% / 100% 6.34 / 6.33 us (0.995x)
ws/echo-20b 147093 149066 1.014x (+1.4%) 1.00 to 1.02 ±1.2% 100% / 100% 6.79 / 6.70 us (0.987x)
ws/echo-4kb 129536 128879 0.995x (-0.5%) 0.97 to 1.03 ±2.7% 100% / 100% 7.71 / 7.75 us (1.005x)

4 rounds of 3s per scenario, each round loading base, head and a second process of each one, from a copy of its build, after the other, in an order that changes every round. "Head / base" is the median of the per-round ratios of req/s and "Rounds" their range. "Noise" is how far base/base and head/head, the same code on both sides, got from 1 in this same run: that is what the machine did, so a row is marked only when the median moved further than that, at least 2%, and every round moved the same way: 👀 slower, 🏆 faster. "Busy" is the cpu time of the server process over the round and "CPU per request" that time divided by the requests it answered, with the head/base ratio judged against its own same-code band and bold when it cleared it. When busy is well under 100% the load generator set the pace, the req/s are its and the cpu per request is the column to read. Only the ratios are comparable across runs, the absolute figures depend on the runner.

Node v26.10.0, AMD EPYC 9V74 80-Core Processor, 4 cores (server on cpu 0, load on 2,3), http_load_test and load_test with 100 connections.

@uNetworkingAB
uNetworkingAB merged commit b485c49 into uNetworking:master Oct 1, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants