dnt
dnt copied to clipboard
deno.ns doesn't get built on skypack
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 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
Closing this issue because the situation should probably be a lot better now with targeted shimming.