ChatGPT-CodeReview icon indicating copy to clipboard operation
ChatGPT-CodeReview copied to clipboard

How can I build this repository?

Open superwoou opened this issue 2 years ago • 3 comments

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

> [email protected] 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.

> [email protected] 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?

superwoou avatar Aug 18 '23 10:08 superwoou

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.

anc95 avatar Aug 22 '23 10:08 anc95

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 :(

superwoou avatar Aug 22 '23 23:08 superwoou

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.

anc95 avatar Aug 23 '23 04:08 anc95