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

[BUG]: createNodeMiddleware is not exported (via esm.sh) #424

Closed
1 task done
denizdogan opened this issue Jun 12, 2023 · 13 comments
Closed
1 task done

[BUG]: createNodeMiddleware is not exported (via esm.sh) #424

denizdogan opened this issue Jun 12, 2023 · 13 comments
Labels
Type: Bug Something isn't working as documented

Comments

@denizdogan
Copy link

What happened?

Originally commented here: octokit/octokit.js#2450 (comment)

Importing https://esm.sh/octokit fails, at least in Deno 1.34.2, because it cannot see the createNodeMiddleware export. I think this is due to something in #416 because overriding the dependency to use 4.2.1 works fine.

cat foobar.ts
import { App } from "https://esm.sh/octokit"; console.log(App);deno run --unstable -A --no-lock --reload foobar.ts
error: Uncaught SyntaxError: The requested module '/v125/@octokit/[email protected]/denonext/oauth-app.mjs' does not provide an export named 'createNodeMiddleware'
    at <anonymous> (https://esm.sh/v125/@octokit/[email protected]/denonext/app.mjs:2:842)

Versions

Failing version: https://esm.sh/[email protected]

Working version: https://esm.sh/[email protected]?dts&target=deno&deps=@octokit/[email protected]

❯ deno --version
deno 1.34.2 (release, aarch64-apple-darwin)
v8 11.5.150.2
typescript 5.0.4

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@denizdogan denizdogan added Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented labels Jun 12, 2023
@wolfy1339
Copy link
Member

export { createNodeMiddleware } from "./middleware/node/index";

It is exported in index.ts

And it is exported in dist-src/index.js: https://unpkg.com/browse/@octokit/[email protected]/dist-src/index.js#L112

It is exported in dist-node/index.js: https://unpkg.com/browse/@octokit/[email protected]/dist-node/index.js#L36

The function is defined in dist-node/index.js:
https://unpkg.com/browse/@octokit/[email protected]/dist-node/index.js#L653

  • I don't understand how you are getting undefined

@wolfy1339
Copy link
Member

wolfy1339 commented Jun 12, 2023

I don't think this is something on our side. It looks to be a bug with esm.sh

@denizdogan
Copy link
Author

It might be esm.sh. I haven't been able to debug it very thoroughly, as I'm still a bit unfamiliar with the Octokit codebase. Another interesting thing I found was in these files:

https://esm.sh/v125/[email protected]/X-ZC9Ab2N0b2tpdC9vYXV0aC1hcHBANC4yLjE/dist-types/app.d.ts

https://esm.sh/v125/[email protected]/X-ZC9Ab2N0b2tpdC9vYXV0aC1hcHBANC4yLjE/dist-types/octokit.d.ts

Note where it says types.d~.d.ts... I have no idea where that came from. Just esm.sh being wonky again? It seems so random.

@wolfy1339
Copy link
Member

That is indeed a weird bug. However, it doesn't seem related to your issue though

@wolfy1339 wolfy1339 moved this from 🆕 Triage to 🔥 Backlog in 🧰 Octokit Active Jun 14, 2023
@wolfy1339 wolfy1339 added Priority: High and removed Status: Triage This is being looked at and prioritized labels Jun 14, 2023
@wolfy1339
Copy link
Member

Can you test if using the ESM source build works, you can load it from here: https://unpkg.com/[email protected]/dist-src/index.js

@denizdogan
Copy link
Author

@wolfy1339 Unfortunately it did not work, but nice try :)

When Deno tries to load the URL, we get this:

❯ deno run --allow-net octokit-deno-testing.ts
error: Relative import path "@octokit/plugin-throttling" not prefixed with / or ./ or ../ and not in import map from "https://unpkg.com/[email protected]/dist-src/octokit.js"
    at https://unpkg.com/[email protected]/dist-src/octokit.js:5:28

❯ cat octokit-deno-testing.ts
import * as octokit from "https://unpkg.com/[email protected]/dist-src/index.js";

@wolfy1339
Copy link
Member

I wonder if this is just a deno problem.

Can you try downloading the contents of the dist-src folder and import it locally: https://unpkg.com/browse/@octokit/[email protected]/dist-src/

In the mean time, I have filed esm-dev/esm.sh#659

@ije
Copy link

ije commented Jun 15, 2023

this is a bug of esm.sh about cjs lexer

@ije
Copy link

ije commented Jun 15, 2023

will fix ASAP

@wolfy1339
Copy link
Member

@denizdogan Can you try again? This should be fixed in ESM.sh now

@denizdogan
Copy link
Author

@wolfy1339 That works! Thanks.

But I will add there's still this one weird little URL which is pointed at by https://esm.sh/v126/[email protected]/dist-types/app.d.ts:

Any ideas about that one? The code still runs, but some type information goes missing.

@ije
Copy link

ije commented Jun 15, 2023

@wolfy1339 That works! Thanks.

But I will add there's still this one weird little URL which is pointed at by https://esm.sh/v126/[email protected]/dist-types/app.d.ts:

Any ideas about that one? The code still runs, but some type information goes missing.

i just file an issue, will fix soon esm-dev/esm.sh#660

@wolfy1339
Copy link
Member

Closing as the issue is fixed, and the subsequent problem with paths has an issue filed with esm.sh

@github-project-automation github-project-automation bot moved this from 🔥 Backlog to ✅ Done in 🧰 Octokit Active Jun 20, 2023
wuhuizuo added a commit to PingCAP-QE/ci that referenced this issue Aug 25, 2023
wuhuizuo added a commit to PingCAP-QE/ci that referenced this issue Aug 25, 2023
ti-chi-bot bot pushed a commit to PingCAP-QE/ci that referenced this issue Aug 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something isn't working as documented
Projects
Archived in project
Development

No branches or pull requests

3 participants