Coder Social home page Coder Social logo

Comments (17)

thibaultdalban avatar thibaultdalban commented on May 26, 2024 3

Thank you for the explanation and the links. I will take the time to read the discussion and test the different workarounds.
I very appreciated your help ⛑️ and your reactivity!
A big THANK YOU for all your contributions to the open-source community 👍

from auth-app.js.

apmitchell avatar apmitchell commented on May 26, 2024 3

Thank you for the explanation and the links. I will take the time to read the discussion and test the different workarounds.
I very appreciated your help ⛑️ and your reactivity!
A big THANK YOU for all your contributions to the open-source community 👍

Did you ever find a workaround for this?

from auth-app.js.

thibaultdalban avatar thibaultdalban commented on May 26, 2024 1

This issue webpack/webpack#5756 could explain why my app is using the code under dist-web and not dist-node.

I tested this webpack/webpack#5756 (comment) and it loads the correct code, but it's not an option because it introduces potential side effects 😕

I tried to downgrade to "@octokit/auth-app": "^2.0.1" (so before introducing the browser compatibility) and I can execute the code without issue.

from auth-app.js.

thibaultdalban avatar thibaultdalban commented on May 26, 2024 1

@gr2m yes I think we can close it. Also in recent nodejs release (v16) atob is expose as global nodejs/node#37786 so it probably fixes (in a way) the issue.

from auth-app.js.

gr2m avatar gr2m commented on May 26, 2024

In what environment are you running your app? Server or browser?

from auth-app.js.

gr2m avatar gr2m commented on May 26, 2024

I wonder where universal-github-app-jwt is coming from, it's not a dependency of @octokit/auth-app.js?

from auth-app.js.

thibaultdalban avatar thibaultdalban commented on May 26, 2024

Hi @gr2m,

Thank you for your quick reply!

In what environment are you running your app? Server or browser?

My app is an AWS serverless Lambda running Node V12.16.1

I wonder where universal-github-app-jwt is coming from, it's not a dependency of @octokit/auth-app.js?

I'm not sure to understand the question, but universal-github-app-jwt has been introduced in @octokit/auth-app.js by #19

from auth-app.js.

thibaultdalban avatar thibaultdalban commented on May 26, 2024

It's strange; my app seems to be detected as running in a browser because before hitting this error, I've been requested to convert my private key using:

openssl pkcs8 -topk8 -inform PEM -outform PEM -nocrypt -in private-key.pem -out private-key-pkcs8.key

but the README indicates, Node handles both:

No conversation is needed in Node, both PKCS#1 and PKCS#8 format will work.

from auth-app.js.

gr2m avatar gr2m commented on May 26, 2024

I'm not sure to understand the question, but universal-github-app-jwt has been introduced in @octokit/auth-app.js by #19

Sorry, I mixed up what repository I was in 🤦‍♂ please ignore my comment.

This is all a problem with creating universal libraries (and build tools), it's really a pain. There is no standard that everyone agrees on. We have a lengthy discussion here about a similar problem: gr2m/universal-user-agent#23 I hope that you find a workaround workaround there for you?

I hope that build tools add support for conditional exports, recently introduced to Node.js: https://nodejs.org/api/esm.html#esm_conditional_exports. This will be the right tool for the job, but until webpack and friends support it, it's going to be frustrating to all of us, I'm very sorry :(

from auth-app.js.

brunopenso avatar brunopenso commented on May 26, 2024

HI, I have the same error here with AWS lambda and node 12.x and serverless framework.

package.json:
"@octokit/auth-app": "^2.4.15", "@octokit/core": "^3.1.2",
I solve the problem by commenting the line below from the serverless.yml

plugins:
  - serverless-offline
  - serverless-prune-plugin
#  - serverless-webpack
custom:
  prune:
    automatic: true
    number: 3

from auth-app.js.

gr2m avatar gr2m commented on May 26, 2024

can we close the issue? The proper solution to this will be to implement the @octokit modules as native ES Modules and take advantage of conditional exports which are support by webpack, rollup, and esbuild now. But this is going to be a bigger project, there is nothing we can do in the meanwhile on our side to address the original problem of this issue. Use the suggested workarounds instead

from auth-app.js.

joscha avatar joscha commented on May 26, 2024

For anyone else coming across this, the @octokit/auth-app package defines:
package_json

Now @rollup/node-resolve uses this default:

plugins_packages_node-resolve_at_master_·_rollup_plugins

which means that even when building for node it will pull dist-web/index.js.

You can fix it by teaching your rollup in the config to resolve to the main field first:

nodeResolve({
  mainFields: ['main', 'module']
}),

however this is a global setting, so you will change precedence for other modules as well.

@gr2m would it make sense to move the web dist to the browser field? E.g.:

  "source": "dist-src/index.js",
  "types": "dist-types/index.d.ts",
  "main": "dist-node/index.js",
  "module": "dist-node/index.js",
  "browser": "dist-web/index.js"

I think semantically it makes more sense?

from auth-app.js.

gr2m avatar gr2m commented on May 26, 2024

I think semantically it makes more sense?

yes, unfortunately it's not that easy. The @pika/pack package we use is no longer maintained, we are looking into creating up our own build setup, which will export a proper ESM build, with conditional exports for Node, browsers, and deno, where necessary.

Eventually we will probably get rid of the build step altogether and just build native ES Modules, and move TypeScript definitions to .d.ts files. But will take a while

from auth-app.js.

joscha avatar joscha commented on May 26, 2024

from auth-app.js.

gr2m avatar gr2m commented on May 26, 2024

It’s not that easy. The browser build is the esm build. I don’t want to patch the setup we have with post build changes, I want to replace the whole build setup, it’s not an easy fix, unfortunately

from auth-app.js.

joscha avatar joscha commented on May 26, 2024

from auth-app.js.

ScottChapman avatar ScottChapman commented on May 26, 2024

I'm stuck on Node v12 and am running into this building with webpack so I can deploy to IBM Cloud functions. My config is simple:

module.exports = {
  entry: {
    webhook: './actions/Webhook.js',
    probot: './actions/Probot.js',
  },
  target: 'node',
  output: {
    filename: '[name].js',
    path: path.resolve(__dirname, 'dist'),
  },
  optimization: {
    minimize: false
  }
};

Not sure what my options are?

from auth-app.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.