I am confused with how octokit is using imports. How can I use commonJs and not set the module and module resolution to Node16.
If I import the App like:
import {App} from "@octokit/app";
I get an error when deploying the firebase function:
Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/andrewmainella/Desktop/Social-Activity-Functions/functions/node_modules/@octokit/app/dist-node/index.js from /Users/andrewmainella/Desktop/Social-Activity-Functions/functions/lib/index.js not supported. Instead change the require of /Users/andrewmainella/Desktop/Social-Activity-Functions/functions/node_modules/@octokit/app/dist-node/index.js in /Users/andrewmainella/Desktop/Social-Activity-Functions/functions/lib/index.js to a dynamic import() which is available in all CommonJS modules.
If I import the App like:
import {App} from "octokit";
I get multiple errors:
There are types at '/Users/andrewmainella/Desktop/Social-Activity-Functions/functions/node_modules/@octokit/core/dist-types/types.d.ts', but this result could not be resolved under your current 'moduleResolution' setting. Consider updating to 'node16', 'nodenext', or 'bundler'.
Things that I have looked at and am confused about:
https://github.com/octokit/octokit.js?tab=readme-ov-file#usage, shows how to st up octokit. The problem is I am useing firebase functions which use commonjs. Octokit is not happy with this so do these things just not work together?
Trying to import octokit directly and useing dynamic imports all face other errors.
Any help or direction would be appretiated.
I made a rookie mistake. ESM modules should have a package.json with "type": "module"
. Also, the eslint file needs to have a cjs extension in ESM. This as well as making changes to the tsconfig will allow the build to deploy correctly to cloud run!