anc95 / ChatGPT-CodeReview

🐥 A code review bot powered by ChatGPT
https://github.com/apps/cr-gpt
ISC License
3.77k stars 360 forks source link

How can I build this repository? #128

Open superwoou opened 10 months ago

superwoou commented 10 months ago

I tried to improve this repository by fork. But I can't build . npm run build is failed with error.

> cr-bot@1.0.0 build
> rm -rf dist && rollup -c rollup.config.ts --configPlugin @rollup/plugin-typescript && ncc build src/github-action.cjs -o action

loaded rollup.config.ts with warnings
(!) Plugin typescript: @rollup/plugin-typescript: Rollup 'sourcemap' option must be set to generate source maps.
[!] RollupError: Rollup transpiled your configuration to an  ES module even though it appears to contain CommonJS elements. To resolve this, you can pass the "--bundleConfigAsCjs" flag to Rollup or change your configuration to only contain valid ESM code.

Original error: exports is not defined in ES module scope
https://rollupjs.org/command-line-interface/#bundleconfigascjs
ReferenceError: exports is not defined in ES module scope

Also, I couldn't run the test code.

> cr-bot@1.0.0 test
> jest

 FAIL  test/index.test.ts
  ● Test suite failed to run

    test/index.test.ts:6:8 - error TS1192: Module '"/Users/yonghoonlee/gitroot/ChatGPT-CodeReview/src/index"' has no default export.

    6 import myProbotApp from "../src";
             ~~~~~~~~~~~

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        1.431 s
Ran all test suites.

How can I build and test?

anc95 commented 10 months ago

Hi, the test code is not runnable. And for the build issue, I guess it's caused by your node version is old and doesn't support esm module, try to upgrade it to new rts version.

superwoou commented 10 months ago

Hi, the test code is not runnable. And for the build issue, I guess it's caused by your node version is old and doesn't support esm module, try to upgrade it to new rts version.

Hi, I'm using LTS(18.17.1) but I can't build with the error :(

anc95 commented 10 months ago

I am using node v20, I tried switching to v18, and still works fine for me.

Make sure that you didn't change any code based on the main branch, and in the package.json, have the right type declaration.

{
  "type": "module"
}

if you did this and still not work, try the suggestion by the console

RollupError: Rollup transpiled your configuration to an  ES module even though it appears to contain CommonJS elements. To resolve this, you can pass the "--bundleConfigAsCjs" flag to Rollup or change your configuration to only contain valid ESM code.