Compiled require(node:buffer) does not expose callable atob and btoa

Open
#3,824 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
62/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
csharp, typescript
Domain
backend, compilers

Research direction

Start by reproducing the issue with sharpts --no-tsconfig --noLib repro.js, then compare it with the standalone compile and verify commands in the issue. Trace how require('node:buffer') exposes Buffer, atob, and btoa in compiled output and compare that path with named ESM imports. Done when the standalone output reports all three values as callable functions, matching the interpreter and Node.js.

Written by the indexing model from the issue text.

Description

During #3816 verification I found that the CommonJS node:buffer object exposes unusable values for its Base64 helpers in compiled output.

const buffer = require('node:buffer');
console.log(typeof buffer.Buffer, typeof buffer.atob, typeof buffer.btoa);

Node.js v22.23.2 and the SharpTS interpreter print function function function. SharpTS IL-verified standalone prints function object object. In the same compiled mode, directly calling the helpers from a named ESM import works.

Run as sharpts --no-tsconfig --noLib repro.js. For standalone, run sharpts --no-tsconfig --noLib --compile repro.js --standalone --verify -o repro.dll and dotnet repro.dll.

Dominant language
C#
Stars
156
Forks
4
Avg merge
14h 45m
Merged PRs (30d)
40

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from nickna/SharpTS

All issues in nickna/SharpTS

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.