From 5b2b4cc148c69c8dda95de4744f5ec109c2bfc38 Mon Sep 17 00:00:00 2001 From: Mason Mark Date: Sun, 16 Jun 2024 16:09:24 +0900 Subject: [PATCH] =?UTF-8?q?3=EF=B8=8F=E2=83=A3=20Make=20third=20lib=20depe?= =?UTF-8?q?nd=20on=20'left-pad'=20from=20NPM,=20and=20'@libs/logger'=20fro?= =?UTF-8?q?m=20JSR.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/settings.json | 7 ++ README.md | 65 ++++++++++++++++++ bun.lockb | Bin 4530 -> 5263 bytes bunfig.toml | 2 + deno.lock | 67 ++++++++++++++++++- libs/ts/detect-runtime/Loginator.ts | 5 ++ libs/ts/detect-runtime/index.ts | 10 +++ libs/ts/detect-runtime/leftPadRuntimeName.ts | 10 +++ package.json | 4 +- tsconfig.json | 4 ++ 10 files changed, 171 insertions(+), 3 deletions(-) create mode 100644 .vscode/settings.json create mode 100644 bunfig.toml create mode 100644 libs/ts/detect-runtime/Loginator.ts create mode 100644 libs/ts/detect-runtime/leftPadRuntimeName.ts diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..3015315 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "deno.enable": true, + "deno.disablePaths": [ + "**/bun.spec.ts", + "./libs/ts/detect-runtimwwwe" + ] +} \ No newline at end of file diff --git a/README.md b/README.md index bd940de..4b5dbcd 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,71 @@ Can we construct a megarepo that contains multiple, interdependent TypeScript li ## Change log +### 3️⃣ lib 3: `@axhxrx/detect-runtime` + +Next, add a junk lib that imports the first two. This one will also import `left-pad`, of NPM fame. 😉 That's my test for "can use old NPM package". + +```text +➜ detect-runtime git:(main) ✗ bun add left-pad +bun add v1.1.13 (bd6a6051) + +installed left-pad@1.3.0 + +1 package installed [559.00ms] +➜ detect-runtime git:(main) ✗ +``` + +~~**PROBLEM:** This makes Deno's language server start freaking out.~~ Oh wait, it doesn't. It actually works fine, I just had a typo. Wow! Cool. + +OK and now we have a third lib, which imports the other two from the monorepo, **and** [left-pad](https://www.npmjs.com/package/left-pad) from NPM. + +Cool let's add a dependency on a JSR package, too, although we will have to use the Nody way (but we're using Bun so I will use `bunx` and not `npx`): + +```text +➜ detect-runtime git:(main) ✗ bunx jsr add @libs/logger + +Installing @libs/logger... +$ bun add @libs/logger@npm:@jsr/libs__logger +bun add v1.1.13 (bd6a6051) + +installed @libs/logger@1.1.2 + +1 package installed [655.00ms] + +Completed in 682ms +➜ detect-runtime git:(main) ✗ bun run index.ts +``` +Hmm it works in Bun, but not Deno: + +```text +➜ detect-runtime git:(main) ✗ bun run index.ts + + Hello via Bun! + The date is: 2024-06-16 16:04:56 + (via @axhxrx/date) + +{ + name: "Bun", + version: "1.1.13", + isDeno: false, + isBun: true, + isNode: false, + isUnknown: false, +} +-------------------- + Bun +-------------------- + INFO │ +0.011 Loginator message { + name: "zfx", +} +➜ detect-runtime git:(main) ✗ deno run index.ts +error: npm package '@jsr/libs__logger' does not exist. +➜ detect-runtime git:(main) ✗ deno run index.ts +``` + +I think this might be some unrelated bug in Deno/JSR though. I'll tackle that separately. + + ### 2️⃣ lib 2: `axhxrx/date` Since Deno doesn't use `package.json` and all that `node_modules` mess, but we need to have that, use Bun to generate an empty library: diff --git a/bun.lockb b/bun.lockb index c5d5904ac7f50f1752a91c6022c957920f0dee8b..13d7c38886381eee64796f892ceefc9e555a34c3 100755 GIT binary patch delta 1291 zcmcIkZ){Ul6o2==wSC?C+Rkle6bTN@a9j3XUu$tIbS)ALWCMvr8YT>jl&!GYr7g`$ z%vcEqlz*E?WP}8k;P_``>VOU7pG`Ddzz;@0@Ig%$oy5f%jL94l?Kr1v`Lcv>p5(mW zJ?EbDyYIYn&--}sv9eC3tnjg=zrAv&r)2D_|9WSxCC+^Li{sGo(*AF!95)(%zCGZX zDG<^kclj6Y-6YQ%g0MXh3(~qdxFc5C8rZ%w8cAP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..57ee6a3 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,8 @@ "typescript": "^5.4.5" }, "dependencies": { - "jsr": "^0.12.4" + "@libs/logger": "npm:@jsr/libs__logger", + "jsr": "^0.12.4", + "left-pad": "^1.3.0" } } \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 1ba9cec..7b398d4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,6 +13,10 @@ }, "rootDir": ".", "baseUrl": ".", + + // @masonmark 2024-06-16: Had to enable this to use ancient NPM dep + "esModuleInterop": true, + // Enable latest features "lib": ["ESNext", "DOM"], "target": "ESNext",