Open sofisl opened 8 months ago
I have the same issue. I tried including the file
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
outputFileTracingIncludes: {
'/': ['./node_modules/@google-cloud/tasks/build/esm/src/**/*.json'],
},
}
};
Link to the code that reproduces this issue
https://github.com/sofisl/debug-tasks-next.js
To Reproduce
projects/PROJECT_ID/locations/LOCATION_ID
Let me know if you need help getting a google cloud project/key, I work on the client libraries there and can help with the right debugging.
Current vs. Expected behavior
There is a server error. If it works, you should get the basic Next.js page (after running the create script), and you should be able to listQueues in google cloud tasks in your terminal.
This is the error:
Provide environment information
Which area(s) are affected? (Select all that apply)
Module resolution (CJS / ESM, module resolving)
Which stage(s) are affected? (Select all that apply)
next build (local), Vercel (Deployed)
Additional context
I work on the Nodejs Client libraries for GCP. We are experimenting with publishing our libraries in dual-format (ESM and CJS), and we just tested this on Cloud Tasks. We got a report that the standalone Next.js build was not working because it was not importing the JSON files: https://github.com/googleapis/google-cloud-node/issues/4858. After reproducing the issue, I thought to fix it by importing the JSON files using require, and wrapping it as a CJS module: https://github.com/googleapis/gapic-generator-typescript/commit/f911ac838d09a1ed0c4e56ea41039a953ed0741c#diff-f90b3a5e1cd374f45c74b508ada7926d1d3daae48c69ff09cac111c349e67d02.
I thought that fixed the issue, but it seems that Next.js still won't copy over our JSON files in the ESM output (however, it will do it in the CJS output), even though both use this
[json-helper.cjs.njk](https://github.com/googleapis/gapic-generator-typescript/commit/f911ac838d09a1ed0c4e56ea41039a953ed0741c#diff-f90b3a5e1cd374f45c74b508ada7926d1d3daae48c69ff09cac111c349e67d02)
method.I see this in your docs:
I will ask people to use the config as a workaround, but in the meantime would like to work to get it working without it! Happy to make changes to the google cloud library as well.