Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
oeed opened this issue Jul 1, 2024 · 5 comments
Open

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

oeed opened this issue Jul 1, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@oeed
Copy link

oeed commented Jul 1, 2024

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/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/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 zimeg added the bug Something isn't working label Jul 3, 2024
@zimeg
Copy link
Member

zimeg commented Jul 3, 2024

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 🙏

@jdppettit
Copy link

Has there been any movement or work arounds for this issue? We are running into a similar problem but with @smithy/util-utf8:

⠦ Packaging app for deployment✘ [ERROR] NPM package not found. [plugin deno-loader]
    ../../Library/Caches/deno/deno_esbuild/@aws-crypto/[email protected]/node_modules/@aws-crypto/util/build/module/convertToBuffer.js:3:44:
      3 │ import { fromUtf8 as fromUtf8Browser } from "@smithy/util-utf8";
        ╵                                             ~~~~~~~~~~~~~~~~~~~
⠧ Packaging app for deploymentError bundling function file "lock" with esbuild
error: Uncaught (in promise) Error: Build failed with 1 error:
../../Library/Caches/deno/deno_esbuild/@aws-crypto/[email protected]/node_modules/@aws-crypto/util/build/module/convertToBuffer.js:3:44: ERROR: [plugin: deno-loader] NPM package not found.
  let error = new Error(text);
              ^
    at failureErrorWithLog (https://deno.land/x/[email protected]/mod.js:1626:15)
    at https://deno.land/x/[email protected]/mod.js:1035:25
    at runOnEndCallbacks (https://deno.land/x/[email protected]/mod.js:1461:45)
    at buildResponseToResult (https://deno.land/x/[email protected]/mod.js:1033:7)
    at https://deno.land/x/[email protected]/mod.js:1062:16
    at responseCallbacks.<computed> (https://deno.land/x/[email protected]/mod.js:679:9)
    at handleIncomingPacket (https://deno.land/x/[email protected]/mod.js:739:9)
    at readFromStdout (https://deno.land/x/[email protected]/mod.js:655:7)
    at https://deno.land/x/[email protected]/mod.js:1924:11
    at eventLoopTick (ext:core/01_core.js:175:7)
Packaging app for deployment

@filmaj
Copy link
Contributor

filmaj commented Nov 13, 2024

Sorry, no update. We are not prioritizing this class of issues at this time. If you have feedback about this, or wish for Slack to prioritize it, please email [email protected] and/or use the /feedback command from the Slack client.

@ThisGuyCodes
Copy link

I am running into this issue trying to use Octokit. I tried using esm.sh instead, but this ran into other issues.

Not being able to build Github integrations is seriously limiting my ability or desire to use this tool.

@ThisGuyCodes
Copy link

I was able to get slack deploy to work with native npm:* dependencies by adding the following to my deno.jsonc:

  "scopes": {
    "https://deno.land/x/[email protected]/": {
      "https://deno.land/x/[email protected]/mod.ts": "jsr:@luca/[email protected]"
    }
  },

Looking at recent commits, it appears a similar update (with more sweeping changes) has been made since the last release. Perhaps this is solved by cutting a new release?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants