darksingeD
Deno5mo ago
6 replies
darksinge

Deno compatibility with local Node/NPM package

Hey everyone, I'm hoping to get some configuration advice for a tricky scenario involving Deno compatibility with a local package that targets the npm ecosystem.

I’m using a framework called SST, which generates a sidecar package inside an
.sst/
directory within my project. The
.sst/
directory contains SST’s internal tooling, including its own
package.json
and
node_modules
.

My Deno code needs to import types from this generated directory. The problem seems rooted in
.sst/
targetting the npm ecosystem, but Deno treats
.sst/
like any other source code in the project, e.g., expects
import foo from 'npm:bar'
instead of
… from ‘bar’
, or
import { add } from ‘./calc.ts’
instead of
… from ‘./calc’
.

How do I make Deno treat the sidecar package generated by SST as an npm module?

Things I’ve tried:
- Configuring the
patch
field in
deno.json
. Per the docs,
patch
is currently limited to JSR packages.
- I got type hints working by adding
"unstable": ["sloppy-imports"]
to
deno.json
. But,
deno check
fails with errors like:
error: Relative import path "@pulumi/pulumi" not prefixed with / or ./ or ../ and not in import map from "file:///path/to/project/.sst/platform/src/components/aws/analog.ts"
  hint: If you want to use a JSR or npm package, try running 'deno add jsr:@pulumi/pulumi' or 'deno add npm:@pulumi/pulumi'

The error message and hint are noted, but as explained above, I don’t believe it’s applicable here because I need Deno to treat
.sst/
as an npm module.

Note sure if this is relevant, but SST uses Bun as their runtime — not sure if there's an extra compatibility layer to worry about there or not.

For a minimal repro, you can run these commands:

deno init sst-deno
cd sst-deno
deno add npm:sst
deno sst init --yes
deno check sst.config.ts


Thanks for any help you can provide!
Was this page helpful?