Closed bit-app-3000 closed 2 weeks ago
I am not sure how to tackle this - possibly will need to regenerate the nacl library for two targets this way require
won't confuse esbuild....
@caspervonb what do you think?
The other choice is to bump the min runtime up - all this complexity is likely about the differing runtimes....
So not quite sure - perhaps it was an issue - but here it goes:
mkdir p
npm init -y
npm install @nats-io/nats-core
npm install @nats-io/jetstream
Make a program that references nkeys (the dep you are seeing there) - main.cjs
const { wsconnect, nkeys } = require("@nats-io/transport-node");
const { Kvm } = require("@nats-io/kv");
(async () => {
const a = await nkeys.createAccount();
console.log(a.getPublicKey());
const nc = await wsconnect({ servers: "wss://demo.nats.io:8443" });
const kvm = new Kvm(nc);
for await (const s of kvm.list()) {
console.log(s.bucket);
}
await nc.drain();
})();
node main.cjs
node main.cjs
ABSIARRAUVLW6QFRUZ7Q3WJP5NCVUUFH5B7RQD54PYPYL537JMLNQ2D6
DEVICE_BIRTH
H101_fsm_data
H101_fsm_state
HXm5PIMBNnBdYrr5A6SeAG
L9D92j5TQrjXn6WojsFBtC
MY_KV
...
esbuild --platform=node --bundle main.cjs > out.cjs
node out.cjs
node out.cjs
ACJBPAABSJB5DNKMJ7NC2IM2DFNC7Q5YQZWKJ7FBVRYEFYEXA5XGRDYC
DEVICE_BIRTH
H101_fsm_data
H101_fsm_state
HXm5PIMBNnBdYrr5A6SeAG
L9D92j5TQrjXn6WojsFBtC
MY_KV
One
SN_TEST
WHITEBOARD
WhoL8SAl1Qxq1XrLAl8Z3G
X
afanasy
all_cabinets
Works for me but I have been adjusting things in the bundles:
npm ls -a
bundle-t@1.0.0 /private/tmp/bundle-t
├─┬ @nats-io/kv@3.0.0-21
│ ├─┬ @nats-io/jetstream@3.0.0-27
│ │ └── @nats-io/nats-core@3.0.0-40 deduped
│ └─┬ @nats-io/nats-core@3.0.0-40
│ ├── @nats-io/nkeys@1.2.0-7 deduped
│ └── @nats-io/nuid@2.0.1-2 deduped
└─┬ @nats-io/transport-node@3.0.0-26
├── @nats-io/nats-core@3.0.0-40 deduped
├─┬ @nats-io/nkeys@1.2.0-7
│ └── tweetnacl@1.0.3
└── @nats-io/nuid@2.0.1-2
Nope I see it - this happens with the JSR versions of the library. @bit-app-3000 Thank you for finding this.
Observed behavior
esbuild dev bundle
[DEBUG] Indirect calls to "require" will not be bundled [indirect-require]
Expected behavior
nacl-fast.js as ESM module
Server and client version
"@nats-io/nats-core": "^3.0.0-25"
"esbuild": "^0.23.1"
Host environment
No response
Steps to reproduce
No response