Conversation
|
I've created #281 and will release it right now, please check if it works for you. |
|
Just released another version, because the "radius" package import was broken. So far eveerything works now on my side, please let me know if it works for you too |
|
Still doesn't allow me to use it in a Nest project with version 2.1.4
Import is done like this const { RadiusServer } = await import("radius-server");But get's compiled to this using the TypeScript compiler const { RadiusServer } = await Promise.resolve().then(() => __importStar(require("radius-server"))); |
|
Are we talking about nest js? https://github.com/nestjs/nest/releases There are quite newer versions than 2.1.4? |
|
Version 2.1.4 of this repo https://github.com/simllll/node-radius-server/releases/tag/v2.1.4. |
|
How do you transpile it? via tsc? what is your tsconfig? Check if there any tickets regarding this in nestjs.. I'm pretty sure people are using esm modules with nest js or it should at lesat be possible to do so nowadays? |
|
According to StackOverflow there is currently no way to import esm modules in cjs typescript except by using an eval statement https://stackoverflow.com/questions/70545129/compile-a-package-that-depends-on-esm-only-library-into-a-commonjs-package/70546326#70546326 |
|
Can you try this setting in your tsconfig: |
|
That works but requires an unstable typescript version (@next) |
|
The following code works in a nest typescript project. const { RadiusServer } = await (eval(`import("radius-server")`) as Promise<typeof import("radius-server")>); |
|
There is also ts 4.7 coming: https://devblogs.microsoft.com/typescript/announcing-typescript-4-7-beta/ which has then the node12 module :-) |
Motivation:
CJS is still dominant in the Node echosystem and is still the default.
Since there are no benefits to ESM in this project that i can think i don't think it's a good idea to switch to ESM (yet).
ESM makes it difficult (and i belive even impossible) to use this module in CJS projects.
Making this ESM only makes it inpossible (as far as i know) to use this in an NestJS project.