size-limit-action icon indicating copy to clipboard operation
size-limit-action copied to clipboard

Error: results.reduce is not a function

Open jonnyelliot opened this issue 4 years ago • 2 comments

GH action:

name: size
on: [pull_request]
jobs:
  size:
    runs-on: ubuntu-latest
    env:
      CI_JOB_NUMBER: 1
    steps:
      - uses: actions/checkout@v1
      - uses: andresz1/size-limit-action@v1
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}

Gives this error:

/usr/local/bin/npx size-limit --json
{
  "error": "WebpackOptionsValidationError: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.\n - configuration.entry['index'] should be an non-empty array.\n   -> A non-empty array of non-empty strings\n    at webpack (/home/runner/work/auth-components/auth-components/node_modules/webpack/lib/webpack.js:31:9)\n    at /home/runner/work/auth-components/auth-components/node_modules/@size-limit/webpack/run-webpack.js:5:20\n    at new Promise (<anonymous>)\n    at runWebpack (/home/runner/work/auth-components/auth-components/node_modules/@size-limit/webpack/run-webpack.js:4:10)\n    at Object.step40 (/home/runner/work/auth-components/auth-components/node_modules/@size-limit/webpack/index.js:86:38)\n    at /home/runner/work/auth-components/auth-components/node_modules/size-limit/calc.js:17:47\n    at Array.map (<anonymous>)\n    at step (/home/runner/work/auth-components/auth-components/node_modules/size-limit/calc.js:16:29)\n    at calc (/home/runner/work/auth-components/auth-components/node_modules/size-limit/calc.js:44:42)\n    at processTicksAndRejections (internal/process/task_queues.js:93:5)"
}
Error parsing size-limit output. The output should be a json.
Error: results.reduce is not a function

jonnyelliot avatar Nov 06 '20 15:11 jonnyelliot

I had this too. For me, I fixed this by removing the size-limit configuration related to files that didn't exist:

   "size-limit": [
-    {
-      "path": "dist/preflight.cjs.production.min.js",
-      "limit": "10 KB"
-    },
     {

This file didn't exist anymore, and was causing webpack to error out.

karlhorky avatar Jan 14 '21 21:01 karlhorky

Also just ran into something similar but not quite the same: a webpack error about Cannot use keyword 'await' outside an async function when using top-level await.

Since this relates to the webpack topLevelAwait experimental option (at least, experimental at the time of writing), one way to fix this would be to specify the "config": "path/to/webpack.config.js" option for size-limit.

However, since webpack wasn't needed for my use case, my solution was to instead set "webpack": false in the size-limit config.

karlhorky avatar Jan 14 '21 21:01 karlhorky