-
Notifications
You must be signed in to change notification settings - Fork 51
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
atob is not defined when building with target: Node using webpack #59
Comments
In what environment are you running your app? Server or browser? |
I wonder where |
Hi @gr2m, Thank you for your quick reply!
My app is an AWS serverless Lambda running Node V12.16.1
I'm not sure to understand the question, but |
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:
but the README indicates, Node handles both:
|
This issue webpack/webpack#5756 could explain why my app is using the code under 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. |
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 :( |
Thank you for the explanation and the links. I will take the time to read the discussion and test the different workarounds. |
HI, I have the same error here with AWS lambda and node 12.x and serverless framework. package.json:
|
Did you ever find a workaround for this? |
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 |
@gr2m yes I think we can close it. Also in recent nodejs release (v16) |
For anyone else coming across this, the Now @rollup/node-resolve uses this default: which means that even when building for node it will pull You can fix it by teaching your rollup in the config to resolve to the main field first:
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 "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? |
yes, unfortunately it's not that easy. The Eventually we will probably get rid of the build step altogether and just build native ES Modules, and move TypeScript definitions to |
Can we patch the produced package.json after it's produced before packaging
and releasing?
|
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 |
I understand, I am merely suggesting a patch fix for the main/browser
fields in the package.json post-build as an intermediate fix until the
build is changed long-term.
Cheers,
Joscha
…On Sat, 8 May 2021, 14:10 Gregor Martynus, ***@***.***> wrote:
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
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#59 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABN5BSUYDKISKRE7TXE5HDTMS2RVANCNFSM4L2W3AYQ>
.
|
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? |
Hello,
I'm facing this error when I try to request the API. My project uses the following packages:
"@octokit/auth-app": "^2.4.4"
"@octokit/rest": "^17.1.4"
"typescript": "^3.8.2"
I tried to install the package
atob-lite
cause it was a dependency in the past https://github.com/octokit/rest.js/pull/1302, but it doesn't fix the issue.The text was updated successfully, but these errors were encountered: