-
Notifications
You must be signed in to change notification settings - Fork 609
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
The esm version of @google-cloud/tasks is incorrectly using require
to load a JSON file
#5702
Comments
Issue was opened with an invalid reproduction link. Please make sure the repository is a valid, publicly-accessible github repository, and make sure the url is complete (example: https://github.com/googleapis/google-cloud-node) |
What? I entered the reproduction link, it's a public gist, the issue template says "or gist"! |
@sofisl If Gists aren't allowed as reproduction step, the issue template needs to be updated. It's not a great experience for someone to take the time and prepare an issue description, just for a bot to close it. |
@timoneh thanks for the call-out, noticed a small issue with our regex that I've updated here: #5705. I've confirmed and it would have let your issue come through. That being said, this issue does look like this one, it seems to be an issue with the way Next copies over files. Can you try this workaround? |
Sorry for not seeing the already opened issue #4858, I searched the issues for "cloud_tasks_client_config" and got no results, but I didn't search for "cloud_tasks_client_config.json". 🙄 My bad. I also already tried the I'll be watching #4858 then 🙂 |
@sofisl I've tried the workaround you've linked above with no luck. |
Please make sure you have searched for information in the following guides.
A screenshot that you have tested with "Try this API".
n/a — a code issue with the esm version
Link to the code that reproduces this issue. A link to a public Github Repository or gist with a minimal reproduction.
https://gist.github.com/timomeh/1744248097efe05a3a6671e8c1af1ea8
A step-by-step description of how to reproduce the issue, based on the linked reproduction.
@google-cloud/tasks
next.config.js
next build
(ensure it's using the standalone output)A clear and concise description of what the bug is, and what you expected to happen.
Following the above steps, it should work and enqueue a task, but instead it errors with:
If you compare the contents of the directories
/node_modules/@google-cloud/tasks/build/esm/src/v2/
with.next/standalone/node_modules/@google-cloud/tasks/build/esm/src/v2/
, you can see that the standalone output is missing thecloud_tasks_client_config.json
file.A clear and concise description WHY you expect this behavior, i.e., was it a recent change, there is documentation that points to this behavior, etc. **
The esm package imports the file
json-helper.cjs
, which usesrequire()
to load the filecloud_tasks_client_config.json
. ESM can't userequire()
.Because of this, the standalone build of Next.js won't copy over the
cloud_tasks_client_config.json
file. Without this file, the SDK errors.A quickfix is to not use the esm version, by loading the SDK with
require('@google-cloud/tasks')
instead ofimport
The text was updated successfully, but these errors were encountered: