Closed Hexagon closed 4 days ago
I ran into the same issue with 'bun:ffi'
It is possible to do a dynamic import (at least until the publish analyzer changes).
Its not pretty, it feels hacky, and the deno publish analyzer gives a warning, but it does work for now.
const bunFFISpecifier = "bun:ffi";
const ffi = await import(bunFFISpecifier);
console.log(ffi);
I had to include the bun ffi types from @types/bun into the module with some modifications to to get everything working as desired when developing using the deno vscode extension and typescript.
I tried to use"bun:sqlite". Same problem. In my case, I want to make a package for the usage with "Bun", not for Deno.
@lucacasonato Is this fix live? Still getting an error when trying both deno publish
and npx jsr publish
. I actually seem to get an older version of the error message, missing both node:
and bun:
:
error[invalid-external-import]: invalid import to a 'bun' specifier
--> /home/hexagon/git/test/shims/bun.ts:8:33
|
8 | const { test } = await import("bun:test");
| ^^^^^^^^^^ the specifier
|
= hint: replace this import with one from jsr or npm, or vendor the dependency into your package
info: the import was resolved to 'bun:test'
info: this specifier is not allowed to be imported on jsr
info: jsr only supports importing `jsr:`, `npm:`, and `data:` specifiers
docs: https://jsr.io/go/invalid-external-import
error: Found 1 problem
Using deno 1.45.2 (release, x86_64-unknown-linux-gnu)
Still no go, i think this should be reopened. Is it working for you @bowtiedgnome ?
I think we just have to wait for the change to be integrated into the production version. If they do it conscientiously, then it could take a week or two.
The command line doesn't allow me to publish a package that depends on bun:sqlite
. It direct me to the docs that state:
JSR only allows external imports that are jsr:, npm:, data:, bun:, or node: specifiers.
So either the cli or the online docs should be updated.
@Hexagon I still get errors the following even with npm:@types/bun and bun-types installed :
// @ts-types="bun-types"
import * as ffi from "bun:ffi";
console.log(ffi);
There isn't a file for it to cache, but it does pick up on the types.
Still no go
@Hexagon ➜ /workspaces/test (main) $ deno publish
Checking for slow types in the public API...
error[invalid-external-import]: invalid import to a 'bun' specifier
--> /workspaces/test/shims/bun.ts:8:33
|
8 | const { test } = await import("bun:test");
| ^^^^^^^^^^ the specifier
|
= hint: replace this import with one from jsr or npm, or vendor the dependency into your package
info: the import was resolved to 'bun:test'
info: this specifier is not allowed to be imported on jsr
info: jsr only supports importing `jsr:`, `npm:`, and `data:` specifiers
docs: https://jsr.io/go/invalid-external-import
error: Found 1 problem
@Hexagon ➜ /workspaces/test (main) $ deno --version
deno 1.46.3 (stable, release, x86_64-unknown-linux-gnu)
v8 12.9.202.5-rusty
typescript 5.5.2
@lucacasonato Any news on this? It's currently impossible to publish packages with a bun:
specifier to jsr.
Just checked using Deno 2.0
abc@bc928c21822e:~/workspace/cross-test$ deno publish
Check file:///config/workspace/cross-test/mod.ts
Checking for slow types in the public API...
error[invalid-external-import]: invalid import to a 'bun' specifier
--> /config/workspace/cross-test/shims/bun.ts:1:22
|
1 | import { test } from "bun:test";
| ^^^^^^^^^^ the specifier
|
= hint: replace this import with one from jsr or npm, or vendor the dependency into your package
info: the import was resolved to 'bun:test'
info: this specifier is not allowed to be imported on jsr
info: jsr only supports importing `jsr:`, `npm:`, and `data:` specifiers
docs: https://jsr.io/go/invalid-external-import
error: Found 1 problem
It actually seems like the problem may be in denoland/deno
The outdated error message: https://github.com/denoland/deno/blob/dd8cbf5e29d9949e3adac9b9d8ce5fb73b5b0ad0/cli/tools/registry/diagnostics.rs#L479
The function missing bun:
:
https://github.com/denoland/deno/blob/dd8cbf5e29d9949e3adac9b9d8ce5fb73b5b0ad0/cli/tools/registry/graph.rs#L35
Caused by (and fixed in) Deno
I'm trying to publish @cross/test which does a conditional import of "bun:test" if running bun, but this error pops up - https://jsr.io/docs/troubleshooting#invalidexternalimport
The code is dynamically imported, so it would never execute in Deno
... and the actual problem is in
./shims/bun.ts
(which again is conditionally imported):How to get around this?