dnt icon indicating copy to clipboard operation
dnt copied to clipboard

deno.ns doesn't get built on skypack

Open bebraw opened this issue 3 years ago • 1 comments

I moved https://github.com/bebraw/dragjs to use dnt. It seems under the hood, dnt relies on deno.ns. The interesting point is that my library is meant for browsers only and I don't have any direct dependency on Deno itself.

It looks like that despite the lack of dependency, my library packaged with dnt fails to compile deno.ns. You can see the issue at http://cdn.skypack.dev/dragjs.

If I try to consume locally (i.e. import { draggable } from "https://cdn.skypack.dev/[email protected]?min";), then it will show the following error:

Download https://cdn.skypack.dev/[email protected]?min
Download https://cdn.skypack.dev/-/[email protected]/dist=es2019,mode=imports,min/optimized/dragjs.js
Download https://cdn.skypack.dev/new/[email protected]/dist=es2019,mode=imports,min?from=deno.ns
Download https://cdn.skypack.dev/error/build:[email protected]
[Package Error] "[email protected]" could not be built.
[1/5] Verifying package is valid…
[2/5] Installing dependencies from npm…
[3/5] Building package using esinstall…
Running esinstall...
Could not load fs/promises (imported by ..deno.ns/dist/deno/stable/functions/chmod.js): ENOENT: no such file or directory, open 'fs/promises'
Could not load fs/promises (imported by ../tmp/cdn/_3B9Kf0YyXFRaTXt9dfpN/node_modules/deno.ns/dist/deno/stable/functions/chmod.js): ENOENT: no such file or directory, open 'fs/promises'
error: Uncaught Error: [Package Error] "[email protected]" could not be built.
    at https://cdn.skypack.dev/error/build:[email protected]:18:7

Is there a simple way to opt-out of deno.ns during the build? Do you understand why it's applied for this particular case?

bebraw avatar Nov 17 '21 10:11 bebraw

@bebraw you can spot where it does this by looking in the output folder's src directory. In your case, it's injecting it into globalThis.

A temporary workaround is to add a // dnt-shim-ignore comment above those two lines with globalThis.

I've opened these two issues to help improve this:

  • https://github.com/denoland/dnt/issues/38
  • https://github.com/denoland/dnt/issues/37

dsherret avatar Nov 17 '21 15:11 dsherret

Closing this issue because the situation should probably be a lot better now with targeted shimming.

dsherret avatar Jun 08 '23 16:06 dsherret