Skip to content

import unpublished modules from pkg.pr.new#868

Merged
hatemhosny merged 2 commits intodevelopfrom
import-from-pkg.pr.new
Sep 8, 2025
Merged

import unpublished modules from pkg.pr.new#868
hatemhosny merged 2 commits intodevelopfrom
import-from-pkg.pr.new

Conversation

@hatemhosny
Copy link
Collaborator

@hatemhosny hatemhosny commented Sep 7, 2025

import { Bench } from 'pr:tinybench@a832a55';
// or
// import { Bench } from 'pr:tinylibs/tinybench/tinybench@a832a55';

Summary by CodeRabbit

  • New Features

    • Support for importing unpublished packages via pr: and pkg.pr.new: prefixes, resolved through the CDN.
  • Documentation

    • New section explaining pr: and pkg.pr.new: usage with examples and CDN alias mappings.
    • Note: CDN alias mappings were added in two places (duplicate entries present).
  • Tests

    • Added tests covering pr:, pkg.pr.new:, and jsr: module resolution.

@netlify
Copy link

netlify bot commented Sep 7, 2025

Deploy Preview for livecodes ready!

Name Link
🔨 Latest commit eee9b67
🔍 Latest deploy log https://app.netlify.com/projects/livecodes/deploys/68be16ab3a07ca0008cee55a
😎 Deploy Preview https://deploy-preview-868--livecodes.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link

coderabbitai bot commented Sep 7, 2025

Walkthrough

Added documentation and tests to support two new module specifier prefixes (pr: and pkg.pr.new:) resolved to esm.sh; module resolver templates updated to map these prefixes. Also added a jsr: test mapping. No public API or runtime behavior changes beyond URL mapping.

Changes

Cohort / File(s) Summary
Docs: Module Resolution
docs/docs/features/module-resolution.mdx
Added documentation for importing unpublished packages with pr: and pkg.pr.new: prefixes, including examples; expanded CDN Providers table with esm.sh mappings (duplicate entries introduced).
Service: Module URL Templates
src/livecodes/services/modules.ts
Added template mappings: pr:https://esm.sh/pr/$2 and pkg.pr.new:https://esm.sh/pkg.pr.new/$2. No other logic changes.
Tests: Module Service
src/livecodes/services/__tests__/modulesService.spec.ts
Added tests validating resolution of jsr:uuidhttps://esm.sh/jsr/uuid, pr:uuid@10https://esm.sh/pr/uuid@10, and pkg.pr.new:uuid@10https://esm.sh/pkg.pr.new/uuid@10.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Dev as Developer
  participant Resolver as ModuleResolver
  participant CDN as esm.sh

  Dev->>Resolver: import "jsr:pkg@version"
  activate Resolver
  Note right of Resolver #D6EAF8: Detect prefix: jsr:
  Resolver->>CDN: GET /jsr/pkg@version
  CDN-->>Resolver: 200 OK (module)
  Resolver-->>Dev: Resolved URL
  deactivate Resolver

  Dev->>Resolver: import "pr:pkg@version"
  activate Resolver
  Note right of Resolver #FDEBD0: Detect prefix: pr:
  Resolver->>CDN: GET /pr/pkg@version
  CDN-->>Resolver: 200 OK (module)
  Resolver-->>Dev: Resolved URL
  deactivate Resolver

  Dev->>Resolver: import "pkg.pr.new:pkg@version"
  activate Resolver
  Note right of Resolver #E8F8F5: Detect prefix: pkg.pr.new:
  Resolver->>CDN: GET /pkg.pr.new/pkg@version
  CDN-->>Resolver: 200 OK (module)
  Resolver-->>Dev: Resolved URL
  deactivate Resolver
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I hop on the net with a quick little grin,
pr: and pkg.pr.new: let new modules begin.
esm.sh fields open where versions now play,
Tests sniff the trails so imports behave.
A burrow of docs and a rabbit-made spin. 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2cd50ea and eee9b67.

📒 Files selected for processing (1)
  • src/livecodes/services/modules.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/livecodes/services/modules.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (14)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Redirect rules - livecodes
  • GitHub Check: Header rules - livecodes
  • GitHub Check: Pages changed - livecodes
  • GitHub Check: type-check (18.x)
  • GitHub Check: tests (18.x, 4)
  • GitHub Check: tests (18.x, 5)
  • GitHub Check: tests (18.x, 3)
  • GitHub Check: tests (18.x, 1)
  • GitHub Check: tests (18.x, 2)
  • GitHub Check: build (18.x)
  • GitHub Check: Cloudflare Pages
  • GitHub Check: build (18.x)
  • GitHub Check: type-check (18.x)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch import-from-pkg.pr.new

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 7, 2025

Size Change: +1.43 kB (+0.15%)

Total Size: 949 kB

ℹ️ View Unchanged
Filename Size Change
./build/404.html 1 kB 0 B
./build/app.html 250 B 0 B
./build/index.html 2.46 kB 0 B
./build/livecodes/app.js 111 kB -88 B (-0.08%)
./build/livecodes/app.css 22.4 kB 0 B
./build/livecodes/assets.js 8.62 kB +8 B (+0.09%)
./build/livecodes/assets/noop.js 18 B 0 B
./build/livecodes/assets/templates/diagrams-starter.html 2.19 kB 0 B
./build/livecodes/backup.js 3.73 kB +35 B (+0.95%)
./build/livecodes/blockly.js 13.2 kB -6 B (-0.05%)
./build/livecodes/broadcast.js 1.19 kB +2 B (+0.17%)
./build/livecodes/bundle-types.js 4.37 kB +18 B (+0.41%)
./build/livecodes/code-to-image.js 9.11 kB +2 B (+0.02%)
./build/livecodes/codejar.js 17.6 kB +15 B (+0.09%)
./build/livecodes/codemirror.js 6.33 kB +32 B (+0.51%)
./build/livecodes/compile.page.js 2.39 kB +25 B (+1.06%)
./build/livecodes/compile.worker.js 14.1 kB +52 B (+0.37%)
./build/livecodes/compiler-utils.js 3.16 kB +9 B (+0.29%)
./build/livecodes/custom-editor-utils.js 198 B 0 B
./build/livecodes/deploy.js 6.89 kB +31 B (+0.45%)
./build/livecodes/editor-settings.js 17.7 kB +12 B (+0.07%)
./build/livecodes/embed-ui.js 5.55 kB +25 B (+0.45%)
./build/livecodes/embed.js 89 kB -33 B (-0.04%)
./build/livecodes/export.js 3.89 kB +18 B (+0.46%)
./build/livecodes/firebase.js 22.7 kB 0 B
./build/livecodes/format.worker.js 13.3 kB +38 B (+0.29%)
./build/livecodes/google-fonts.js 7.12 kB 0 B
./build/livecodes/headless.js 77.9 kB +107 B (+0.14%)
./build/livecodes/i18n-ar-language-info.json 5.17 kB 0 B
./build/livecodes/i18n-ar-translation.json 9.32 kB 0 B
./build/livecodes/i18n-de-language-info.json 5.21 kB 0 B
./build/livecodes/i18n-de-translation.json 9.43 kB 0 B
./build/livecodes/i18n-en-language-info.json 4.5 kB 0 B
./build/livecodes/i18n-en-translation.json 8.02 kB 0 B
./build/livecodes/i18n-es-language-info.json 4.95 kB 0 B
./build/livecodes/i18n-es-translation.json 9.16 kB 0 B
./build/livecodes/i18n-fa-language-info.json 5.28 kB 0 B
./build/livecodes/i18n-fa-translation.json 9.46 kB 0 B
./build/livecodes/i18n-fr-language-info.json 5.13 kB 0 B
./build/livecodes/i18n-fr-translation.json 9.4 kB 0 B
./build/livecodes/i18n-hi-language-info.json 5.71 kB 0 B
./build/livecodes/i18n-hi-translation.json 9.94 kB 0 B
./build/livecodes/i18n-it-language-info.json 5 kB 0 B
./build/livecodes/i18n-it-translation.json 9.25 kB 0 B
./build/livecodes/i18n-ja-language-info.json 5.51 kB 0 B
./build/livecodes/i18n-ja-translation.json 9.6 kB 0 B
./build/livecodes/i18n-pt-language-info.json 4.99 kB 0 B
./build/livecodes/i18n-pt-translation.json 9.33 kB 0 B
./build/livecodes/i18n-ru-language-info.json 5.52 kB 0 B
./build/livecodes/i18n-ru-translation.json 10.3 kB 0 B
./build/livecodes/i18n-ur-language-info.json 5.73 kB 0 B
./build/livecodes/i18n-ur-translation.json 9.77 kB 0 B
./build/livecodes/i18n-zh-CN-language-info.json 4.87 kB 0 B
./build/livecodes/i18n-zh-CN-translation.json 8.63 kB 0 B
./build/livecodes/i18n.js 20.2 kB -8 B (-0.04%)
./build/livecodes/import-src.js 15.8 kB +1 B (+0.01%)
./build/livecodes/import.js 14.4 kB +52 B (+0.36%)
./build/livecodes/index.js 5.35 kB +21 B (+0.39%)
./build/livecodes/lang-art-template-compiler.js 1.65 kB +22 B (+1.35%)
./build/livecodes/lang-assemblyscript-compiler.js 290 B 0 B
./build/livecodes/lang-assemblyscript-script.js 386 B 0 B
./build/livecodes/lang-astro-compiler.js 2.34 kB +16 B (+0.69%)
./build/livecodes/lang-clio-compiler.js 1.55 kB +23 B (+1.51%)
./build/livecodes/lang-commonlisp-script.js 123 B 0 B
./build/livecodes/lang-cpp-script.js 1.75 kB +21 B (+1.22%)
./build/livecodes/lang-cpp-wasm-script.js 2.84 kB +19 B (+0.67%)
./build/livecodes/lang-csharp-wasm-script.js 2.18 kB +17 B (+0.79%)
./build/livecodes/lang-diagrams-compiler-esm.js 5.1 kB +16 B (+0.31%)
./build/livecodes/lang-dot-compiler.js 1.66 kB +20 B (+1.22%)
./build/livecodes/lang-ejs-compiler.js 1.63 kB +20 B (+1.24%)
./build/livecodes/lang-eta-compiler.js 1.65 kB +21 B (+1.29%)
./build/livecodes/lang-fennel-compiler.js 1.61 kB +19 B (+1.19%)
./build/livecodes/lang-gleam-compiler.js 3.03 kB +26 B (+0.87%)
./build/livecodes/lang-haml-compiler.js 1.65 kB +28 B (+1.73%)
./build/livecodes/lang-handlebars-compiler.js 1.92 kB +13 B (+0.68%)
./build/livecodes/lang-imba-compiler.js 147 B 0 B
./build/livecodes/lang-java-script.js 4.05 kB +22 B (+0.55%)
./build/livecodes/lang-jinja-compiler.js 1.64 kB +11 B (+0.68%)
./build/livecodes/lang-julia-script.js 3.3 kB +34 B (+1.04%)
./build/livecodes/lang-liquid-compiler.js 1.68 kB +31 B (+1.88%)
./build/livecodes/lang-lua-wasm-script.js 205 B 0 B
./build/livecodes/lang-malina-compiler.js 2.94 kB +28 B (+0.96%)
./build/livecodes/lang-mustache-compiler.js 1.65 kB +17 B (+1.04%)
./build/livecodes/lang-nunjucks-compiler.js 1.93 kB +18 B (+0.94%)
./build/livecodes/lang-perl-script.js 268 B 0 B
./build/livecodes/lang-php-wasm-script.js 347 B 0 B
./build/livecodes/lang-postgresql-compiler-esm.js 1.73 kB +21 B (+1.23%)
./build/livecodes/lang-prolog-script.js 204 B 0 B
./build/livecodes/lang-pug-compiler.js 371 B 0 B
./build/livecodes/lang-python-wasm-script.js 1.92 kB +24 B (+1.27%)
./build/livecodes/lang-r-script-esm.js 2.44 kB +26 B (+1.08%)
./build/livecodes/lang-rescript-compiler-esm.js 2.15 kB +25 B (+1.17%)
./build/livecodes/lang-rescript-formatter.js 1.52 kB +25 B (+1.68%)
./build/livecodes/lang-riot-compiler.js 2.79 kB +19 B (+0.69%)
./build/livecodes/lang-ruby-wasm-script.js 1.71 kB +28 B (+1.67%)
./build/livecodes/lang-scss-compiler.js 1.71 kB +18 B (+1.06%)
./build/livecodes/lang-solid-compiler.js 263 B 0 B
./build/livecodes/lang-sql-compiler.js 1.63 kB +14 B (+0.87%)
./build/livecodes/lang-sql-script.js 1.96 kB +30 B (+1.55%)
./build/livecodes/lang-svelte-compiler.js 4.61 kB +55 B (+1.21%)
./build/livecodes/lang-tcl-script.js 1.82 kB +23 B (+1.28%)
./build/livecodes/lang-teal-compiler.js 1.72 kB +22 B (+1.3%)
./build/livecodes/lang-twig-compiler.js 1.64 kB +22 B (+1.36%)
./build/livecodes/lang-vento-compiler.js 1.68 kB +32 B (+1.94%)
./build/livecodes/lang-vue-compiler.js 5.97 kB -13 B (-0.22%)
./build/livecodes/lang-vue2-compiler.js 3.45 kB +21 B (+0.61%)
./build/livecodes/lang-wat-compiler.js 348 B 0 B
./build/livecodes/lang-wat-script.js 1.58 kB +28 B (+1.8%)
./build/livecodes/language-info.js 7.65 kB -18 B (-0.23%)
./build/livecodes/monaco-lang-astro.js 947 B 0 B
./build/livecodes/monaco-lang-clio.js 639 B 0 B
./build/livecodes/monaco-lang-imba.js 7.35 kB 0 B
./build/livecodes/monaco-lang-wat.js 2.46 kB 0 B
./build/livecodes/monaco.js 10.1 kB +36 B (+0.36%)
./build/livecodes/open.js 6.2 kB +25 B (+0.41%)
./build/livecodes/processor-lightningcss-compiler.js 1.88 kB +33 B (+1.79%)
./build/livecodes/processor-postcss-compiler.js 2.02 kB +27 B (+1.35%)
./build/livecodes/processor-tailwindcss-compiler.js 5.05 kB +22 B (+0.44%)
./build/livecodes/processor-unocss-compiler.js 355 B 0 B
./build/livecodes/processor-windicss-compiler.js 450 B 0 B
./build/livecodes/quill.css 697 B 0 B
./build/livecodes/quill.js 5.74 kB +6 B (+0.1%)
./build/livecodes/resources.js 3.43 kB -2 B (-0.06%)
./build/livecodes/result-utils.js 1.17 kB 0 B
./build/livecodes/share.js 3.81 kB +25 B (+0.66%)
./build/livecodes/snippets.js 6.04 kB +26 B (+0.43%)
./build/livecodes/sync-ui.js 3.25 kB +26 B (+0.81%)
./build/livecodes/sync.js 3.52 kB +5 B (+0.14%)
./build/livecodes/sync.worker.js 29.7 kB -1 B (0%)
./build/livecodes/templates.js 24.6 kB -6 B (-0.02%)
./build/sdk/livecodes.js 3.95 kB 0 B
./build/sdk/livecodes.umd.js 4.03 kB 0 B
./build/sdk/package.json 293 B 0 B
./build/sdk/react.js 4.25 kB 0 B
./build/sdk/vue.js 4.34 kB 0 B

compressed-size-action

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Sep 7, 2025

Deploying livecodes with  Cloudflare Pages  Cloudflare Pages

Latest commit: eee9b67
Status: ✅  Deploy successful!
Preview URL: https://0f5ab3b9.livecodes.pages.dev
Branch Preview URL: https://import-from-pkg-pr-new.livecodes.pages.dev

View logs

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (3)
src/livecodes/services/__tests__/modulesService.spec.ts (1)

43-46: Add negative and query-param cases to harden tests.

  • Add a negative test to ensure similar-looking prefixes don’t match:
+    // should NOT match pkg.pr.new template
+    expect(url('pkgXprYnew:uuid@10')).toEqual('https://esm.sh/pkgXprYnew:uuid@10');
  • Verify external query propagation works with esm.sh-backed aliases:
+    expect(url('pr:uuid@10', { external: 'react' })).toEqual('https://esm.sh/pr/uuid@10?external=react');
+    expect(url('pkg.pr.new:uuid@10', { external: 'react' })).toEqual('https://esm.sh/pkg.pr.new/uuid@10?external=react');
docs/docs/features/module-resolution.mdx (2)

138-151: Show a pkg.pr.new: example and clarify it resolves via esm.sh.

Add a concrete example and one-line clarification for where these resolve.

-Use the prefix `pr:` or `pkg.pr.new:`.
+Use the prefix `pr:` or `pkg.pr.new:`. Both resolve via esm.sh.
@@
 ```js
 import { Bench } from 'pr:tinybench@a832a55';
 // or
 // import { Bench } from 'pr:tinylibs/tinybench/tinybench@a832a55';
+// or using pkg.pr.new:
+// import { Bench } from 'pkg.pr.new:tinybench@a832a55';

---

`182-185`: **Consider grouping alias-like prefixes separately from true CDNs.**

`pr:` and `pkg.pr.new:` (like `jsr:`) are aliases routed through esm.sh, not independent CDNs. A short “Aliases” subsection or note would reduce confusion and avoid duplication with the new section above.

</blockquote></details>

</blockquote></details>

<details>
<summary>📜 Review details</summary>

**Configuration used**: CodeRabbit UI

**Review profile**: CHILL

**Plan**: Pro

<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 8d99d68700db0c8b7b47803a0a1ba9fdbc15f9ea and 2cd50eab069acb1eff5e1505a7afbb1233dc7aee.

</details>

<details>
<summary>📒 Files selected for processing (3)</summary>

* `docs/docs/features/module-resolution.mdx` (2 hunks)
* `src/livecodes/services/__tests__/modulesService.spec.ts` (1 hunks)
* `src/livecodes/services/modules.ts` (1 hunks)

</details>

<details>
<summary>⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (14)</summary>

* GitHub Check: Codacy Static Code Analysis
* GitHub Check: Redirect rules - livecodes
* GitHub Check: Header rules - livecodes
* GitHub Check: Pages changed - livecodes
* GitHub Check: build
* GitHub Check: build (18.x)
* GitHub Check: tests (18.x, 2)
* GitHub Check: tests (18.x, 1)
* GitHub Check: tests (18.x, 5)
* GitHub Check: tests (18.x, 4)
* GitHub Check: tests (18.x, 3)
* GitHub Check: type-check (18.x)
* GitHub Check: build (18.x)
* GitHub Check: type-check (18.x)

</details>

<details>
<summary>🔇 Additional comments (2)</summary><blockquote>

<details>
<summary>src/livecodes/services/modules.ts (1)</summary><blockquote>

`123-124`: **Good addition: `pr:` prefix mapped via esm.sh.**

Regex and replacement look consistent with existing patterns and integrate with `external` param logic.

</blockquote></details>
<details>
<summary>src/livecodes/services/__tests__/modulesService.spec.ts (1)</summary><blockquote>

`41-42`: **Coverage for `jsr:` looks good.**

Expectation matches the template behavior.

</blockquote></details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

@hatemhosny hatemhosny changed the title import unpublished modules under development from pkg.pr.new import unpublished modules from pkg.pr.new Sep 7, 2025
@sonarqubecloud
Copy link

sonarqubecloud bot commented Sep 7, 2025

@hatemhosny hatemhosny merged commit e14dcce into develop Sep 8, 2025
22 checks passed
@hatemhosny hatemhosny deleted the import-from-pkg.pr.new branch September 9, 2025 11:39
@coderabbitai coderabbitai bot mentioned this pull request Sep 20, 2025
19 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant