Skip to content
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

How can I build this repository? #128

Open
superwoou opened this issue Aug 18, 2023 · 3 comments
Open

How can I build this repository? #128

superwoou opened this issue Aug 18, 2023 · 3 comments

Comments

@superwoou
Copy link

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?

@anc95
Copy link
Owner

anc95 commented Aug 22, 2023

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
Copy link
Author

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
Copy link
Owner

anc95 commented Aug 23, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants