Closed zfben closed 2 weeks ago
Hi @zfben! Thanks for your interest in ts-blank-space
😀
So far we have been happy with this package being ESM only. Especially with the latest versions of Node now directly supporting require
of ESM (1, 2) we are rapidly heading towards a world where dual publishing CJS+ESM has fewer benefits.
The places within Bloomberg where we have needed to use ts-blank-space
from an older Node project we have been able to use await import("ts-blank-space")
. Perhaps others will be able to do the same?
Thanks @acutmore, but in my case, I need to execute ts-blank-space synchronously. The await import is asynchronous. However, I'm glad to learn that Node.js 23 will resolve this issue, but currently my project is still using an older version of Node.js.
I need to execute ts-blank-space synchronously
Would you be able to go into more details? Perhaps there could be another solution. Module loading tends to only be synchronous for commonJS, but ts-blank-space
doesn't supports TypeScript's CJS syntax (import =
and export =
) (docs).
I'm glad to learn that Node.js 23 will resolve this issue
I believe this will also be back ported to Node 22, which will soon be the active Node version with Node 20 going into maintenance mode: https://nodejs.org/en/about/previous-releases#release-schedule
Adding a CJS build adds complexity to this project. The full set of dev packages to install goes from 4 to 162 because tsup
has a large subtree of packages. We'll also need to add more than just tsup
to the build, running npm pack
and passing the result to https://arethetypeswrong.github.io it says that there are no type declarations for the CJS export.
@acutmore I'm currently using SWC to handle the synchronous transformation issue. Indeed, tsup has too many dependencies, and since the stable version next year will support synchronous imports, I don't think we need to rush to solve this problem now.
Just support for used in CommonJS project.