Skip to content

Usage in Create React App #20

@hughrawlinson

Description

@hughrawlinson

Hi,

I'm a little confused about where to report this issue, but since this package is the top level dependency I'm importing, I'll start here and see where I end up.

I'm having trouble using this library in a Create React App app. When I make a query, you call @octokit/request, which calls is-plain-object. In node, that's fine, but in my web app I'm getting isPlainObject is not a function. In this case, isPlainObject is an object on which the property default is the function. I think this is some confusion about module importing. Since you're not exporting a webpacked copy of @octokit/request, I guess webpack runs on your code too, and since webpack prefers commonjs libraries, it's pulling in the commonjs copy of is-plain-object, which your code doesn't handle.

I'm also using @octokit/rest, but that pulls in const request = require('@octokit/request/lib/request'), rather than const request = require('@octokit/request'), which might avoid the issue somehow.

Maybe also related: @octokit/rest is using "is-plain-object": "^3.0.0" via "@octokit/request": "3.0.2", whereas @octokit/graphql is using
"is-plain-object": "^2.0.4" via "@octokit/request": "^3.0.0", which seems significant given that is-plain-object ships a cjs export in 3.0.0 but not in 2.0.4.

I'm also using @octokit/rest, which works fine, but I'm still on v15, which doesn't use @octokit/request. When I upgrade to @octokit/rest@16, I get the same problem.

Looking forward to hearing if you have any thoughts. More than happy to go to other repos if issues are more relevant there.

Best,

Hugh

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions