slackapi / deno-slack-hooks

Helper library implementing the contract between the Slack CLI and Slack application SDKs
10 stars 3 forks source link

[QUERY] How to deploy with npm module dependencies? #89

Open oeed opened 1 week ago

oeed commented 1 week ago

Question

I am trying to use an npm module as there is no native Deno equivalent. I am trying to convert GitHub markdown to Slack's custom markdown format (if there's another way to do this please let me know!).

import slackifyMarkdown from "npm:slackify-markdown"

This works perfectly locally with slack run. However, when deploying I get a bunch of errors from deno_esbuild relating to resolving sub-dependencies. For example:

✘ [ERROR] NPM package not found. [plugin deno-loader]
    ../../../../Library/Caches/deno/deno_esbuild/remark-gfm@1.0.0/node_modules/remark-gfm/index.js:3:21:
      3 │ var syntax = require('micromark-extension-gfm')
        ╵                      ~~~~~~~~~~~~~~~~~~~~~~~~~
✘ [ERROR] NPM package not found. [plugin deno-loader]
    ../../../../Library/Caches/deno/deno_esbuild/remark-parse@9.0.0/node_modules/remark-parse/index.js:5:27:
      5 │ var fromMarkdown = require('mdast-util-from-markdown')
✘ [ERROR] Import 'https://./exists.ts' failed: error sending request for url (https://./exists.ts): error trying to connect: invalid dnsname [plugin deno-loader]
    https://deno.land/std@0.67.0/fs/move.ts:2:35:
      2 │ import { exists, existsSync } from "./exists.ts";
        ╵                                    ~~~~~~~~~~~~~
✘ [ERROR] Import 'https://../path/mod.ts' failed: error sending request for url (https://../path/mod.ts): error trying to connect: invalid dnsname [plugin deno-loader]
    https://deno.land/std@0.67.0/fs/ensure_link.ts:2:22:
      2 │ import * as path from "../path/mod.ts";

The strange thing is, it seems to resolve direct dependencies of slackify-markdown such as remark-gfm okay, but not their dependencies. Additionally, all the dependency files are indeed in the Deno cache folder, so I don't know why it's not resolving them. I haven't used Deno before so apologies if this is obvious!

Screenshot 2024-07-01 at 11 18 45

Environment

The deno-slack versions deno_slack_sdk: 2.12.0 deno_slack_api: 2.4.0

Deno runtime version CLI: 2.26.0 deno: 1.44.4 typescript: 5.4.5 v8: 12.6.228.9

OS info

macOS 14.5

Requirements

Please read the Contributing guidelines and Code of Conduct before creating this issue or pull request. By submitting, you are agreeing to those rules.

zimeg commented 4 days ago

Hey @oeed 👋 Thank you for sharing this detailed report, and sorry you're bumping into this! To me it seems like your imports are alright, but this issue is appearing with bundling attempts. Going to move this issue to the slackapi/deno-slack-hooks repo for closer tracking 🔖

The strange thing is, it seems to resolve direct dependencies of slackify-markdown such as remark-gfm okay, but not their dependencies.

It's super interesting that the dependencies of slackify-markdown are appearing in deno_esbuild but aren't being "linked" or found in imports...

Similar issues around bundling strangeness with esbuild have appeared in slackapi/deno-slack-sdk#316 but I think it's worth keeping this open to track progress and continue investigations. At this time I'm not sure of an immediate workaround, but this is an issue we're actively tracking 🙏