Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions docs/docs/features/module-resolution.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,20 @@ If you want to bundle (and transpile) any import URL, prefix it with `bundle:` (

:::

## pkg.pr.new

Unpublished npm packages can be imported while still under development using the [pkg.pr.new](https://pkg.pr.new/) service.

Use the prefix `pr:` or `pkg.pr.new:`.

Example:

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

## CDN Providers

By default, npm modules are imported from [esm.sh](https://esm.sh/). You may choose another provider by using a CDN prefix. These are examples of importing the library `uuid`:
Expand Down Expand Up @@ -165,6 +179,10 @@ By default, npm modules are imported from [esm.sh](https://esm.sh/). You may cho

`jsr:@std/uuid` → https://esm.sh/jsr/@std/uuid ([info](https://esm.sh))

`pr:tinybench@a832a55` → https://esm.sh/pr/tinybench@a832a55 ([info](https://esm.sh))

`pkg.pr.new:tinybench@a832a55` → https://esm.sh/pkg.pr.new/tinybench@a832a55 ([info](https://esm.sh))

`jspm:uuid` → https://jspm.dev/uuid ([info](https://jspm.org) - [DEPRECATED](https://jspm.org/jspm-dev-deprecation))

Example:
Expand Down
6 changes: 6 additions & 0 deletions src/livecodes/services/__tests__/modulesService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ describe('modulesService', () => {

expect(url('esm.sh:uuid')).toEqual('https://esm.sh/uuid');

expect(url('jsr:uuid')).toEqual('https://esm.sh/jsr/uuid');

expect(url('pr:uuid@10')).toEqual('https://esm.sh/pr/uuid@10');

expect(url('pkg.pr.new:uuid@10')).toEqual('https://esm.sh/pkg.pr.new/uuid@10');

expect(url('unpkg:uuid')).toEqual('https://unpkg.com/uuid?module');

expect(url('bundlejs:uuid')).toEqual('https://deno.bundlejs.com/?file&q=uuid');
Expand Down
4 changes: 4 additions & 0 deletions src/livecodes/services/modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ const TEMPLATES: Array<[RegExp, string]> = [

[/^(jsr:)(.+)/i, 'https://esm.sh/jsr/$2'],

[/^(pr:)(.+)/i, 'https://esm.sh/pr/$2'],

[/^(pkg\.pr\.new:)(.+)/i, 'https://esm.sh/pkg.pr.new/$2'],

[/^(skypack:)(.+)/i, 'https://cdn.skypack.dev/$2'],

[/^(jsdelivr:)(.+)/i, 'https://cdn.jsdelivr.net/npm/$2'],
Expand Down