zapatos icon indicating copy to clipboard operation
zapatos copied to clipboard

Anyone tried Zapatos with Deno?

Open shah opened this issue 5 years ago • 13 comments

This is a fantastic idea and excellent library. Any chance that it might work in Deno scripts?

shah avatar Jul 29 '20 13:07 shah

Thanks. I've not really looked at Deno yet, but I'll leave this open for now in case anyone else wants to chime in.

jawj avatar Jul 29 '20 18:07 jawj

Thanks @jawj if you're interested, Denoify is a tool that could make it easier to maintain this package for both NodeJS and Deno at the same time.

shah avatar Jul 30 '20 19:07 shah

@jawj did you get a chance to check out Deno since we chatted? I've found that Pika is a great CDN to use to help auto-convert to Deno:

https://www.skypack.dev/view/zapatos

As you can see, Zapatos already has a high Package Score (86) and just needs one minor change in your package.json to potentially be fully compatible with Deno (see the "fix" button):

image

shah avatar Dec 06 '20 17:12 shah

@jawj if you've had a moment to take a peek at Deno or SkyPack to fix the TypeScript Types warning (see above) we're ready to give this a try in our projects. Thanks!

shah avatar Dec 13 '20 15:12 shah

We use the "exports" key in package.json to export the db and generate submodules separately, and as far as I can see there's not yet any way to explicitly map those to separate type declaration files (there's a suggestion to add a "types" key under each exported name, which looks sensible enough, but doesn't seem to have happened yet).

Happy to consider a PR if you can find a workaround.

jawj avatar Dec 15 '20 10:12 jawj

Thanks for the hint @jawj - that's helpful. Deno does not use package.json and is "pure TypeScript" so I'll see if I can figure out a way around the exports key in package.json.

shah avatar Dec 16 '20 01:12 shah

@shah any luck with this?

jawj avatar Feb 18 '21 11:02 jawj

Thanks for checking in @jawj! Unfortunately because Zapatos is not natively ESM, I had to use Skypack.dev's packager but this is what is generated:

/*
 * [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...
 *   No "exports" main resolved in zapatos/package.json
 *   No "exports" main resolved in /tmp/cdn/_eJ13sZAAmqsToAOlkfmZ/node_modules/zapatos/package.json
 *
 * How to fix:
 *   - If you believe this to be an error in Skypack, file an issue here: https://github.com/skypackjs/skypack-cdn/issues
 *   - If you believe this to be an issue in the package, share this URL with the package authors to help them debug & fix.
 *   - Use https://skypack.dev/ to find a web-friendly alternative to find another package.
 */

console.warn("[Package Error] \"[email protected]\" could not be built. \n[1/5] Verifying package is valid…\n[2/5] Installing dependencies from npm…\n[3/5] Building package using esinstall…\nRunning esinstall...\nNo \"exports\" main resolved in zapatos/package.json\nNo \"exports\" main resolved in /tmp/cdn/_eJ13sZAAmqsToAOlkfmZ/node_modules/zapatos/package.json");
throw new Error("[Package Error] \"[email protected]\" could not be built. ");
export default null;

This is my Deno test file:

import * as zg from "https://cdn.skypack.dev/zapatos/generate";
//import * as z from "https://cdn.skypack.dev/zapatos";

const zapCfg: zg.Config = {
  db: { connectionString: "postgres://localhost/mydb" },
};
await zg.generate(zapCfg);

shah avatar Feb 18 '21 18:02 shah

Hmm. Looks like this is still the issue I mentioned before, about types being found for named exports. There's continuing discussion on the TS issue.

jawj avatar Feb 22 '21 18:02 jawj

Agreed, @jawj - I have been thinking of creating a Deno-native port of Zapatos for that reason. As long as there are no NodeJS-specific APIs being used, it should be straightforward to port.

shah avatar Feb 22 '21 18:02 shah

The referenced TS issue got fixed if I'm not mistaken.

tbo avatar Nov 18 '21 19:11 tbo

@tbo here's what I get when I try it in Deno 1.16 using SkyPack.dev:

❯ deno-run https://cdn.skypack.dev/zapatos
Download https://cdn.skypack.dev/zapatos
Download https://cdn.skypack.dev/-/[email protected]/dist=es2019,mode=raw/zapatos
error: Import 'https://cdn.skypack.dev/-/[email protected]/dist=es2019,mode=raw/zapatos' failed, not found.
    at https://cdn.skypack.dev/zapatos:16:23

❯ deno-run https://cdn.skypack.dev/@pantas-net/zapatos
Download https://cdn.skypack.dev/@pantas-net/zapatos
Download https://cdn.skypack.dev/new/@pantas-net/[email protected]/dist=es2019
Download https://cdn.skypack.dev/-/@pantas-net/[email protected]/dist=es2019,mode=raw/@pantas-net/zapatos
error: Import 'https://cdn.skypack.dev/-/@pantas-net/[email protected]/dist=es2019,mode=raw/@pantas-net/zapatos' failed, not found.

Were you using it from another CDN/source?

shah avatar Nov 18 '21 20:11 shah

@shah I didn't actually try it out. I just noticed that the TS issue mentioned in https://github.com/jawj/zapatos/issues/28#issuecomment-783564539 got closed. I thought I mention it, because @jawj added the "waiting for other project" due to that issue.

tbo avatar Nov 19 '21 14:11 tbo