parcel: Error: Got unexpected undefined

πŸ› bug report

Trying to migrate a very large repository (private to a company) from webpack to parcel, I’m facing this frequent build error Error: Got unexpected undefined when running parcel watch and the error log doesn’t say much more than that. After adding some manual error logging at the source in parcel core in node module I have some more info. Its getting thrown when running svg,jpg,png files through the compressors in this function in @pracel/core.

We loved parcel in our tests and plan to use parcel in dev mode as of now (with plan to use in production later), but this error blocks us. Tried several fixes suggestion from various issues in the repo already but none seems to fix this particular issue.

Any suggestions/help to get around this is highly appreciated.

example complete error

 console: >> errorrrr {
   filePath: 'packages/application-desktop/dist/assets/apple-app-store-badge_nl.8fed9113.svg',
   err: Error: Got unexpected undefined
       at nullthrows (/Users/chintu.mohandas/Documents/Company/frontend-web/node_modules/nullthrows/nullthrows.js:7:15)
       at Object.run (/Users/chintu.mohandas/Documents/Company/frontend-web/node_modules/@parcel/core/lib/requests/DevDepRequest.js:133:54)
       at RequestTracker.runRequest (/Users/chintu.mohandas/Documents/Company/frontend-web/node_modules/@parcel/core/lib/RequestTracker.js:725:34)
       at Object.runRequest (/Users/chintu.mohandas/Documents/Company/frontend-web/node_modules/@parcel/core/lib/RequestTracker.js:777:23)
       at runDevDepRequest (/Users/chintu.mohandas/Documents/Company/frontend-web/node_modules/@parcel/core/lib/requests/DevDepRequest.js:127:13)
       at runCompressor (/Users/chintu.mohandas/Documents/Company/frontend-web/node_modules/@parcel/core/lib/requests/WriteBundleRequest.js:240:47)
       at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
       at async Promise.all (index 0)
       at async writeFiles (/Users/chintu.mohandas/Documents/Company/frontend-web/node_modules/@parcel/core/lib/requests/WriteBundleRequest.js:207:3)
       at async Object.run (/Users/chintu.mohandas/Documents/Company/frontend-web/node_modules/@parcel/core/lib/requests/WriteBundleRequest.js:179:3) {
     framesToPop: 1
   },
   compressors: [
     {
       plugin: [Object],
       version: '2.7.0',
       resolveFrom: 'node_modules/@parcel/config-default/index.json',
       range: undefined,
       name: '@parcel/compressor-raw',
       keyPath: '/compressors/*/0'
     }
   ]
 }

The error happens when the svg,jpg,png files are run through @parcel/compressor-raw. Is there a way to skip using any compressor at all during dev mode?

.parcelrc

{
  "extends": [
    "@parcel/config-default"
  ],

  "resolveFrom": ".",
}

πŸŽ› Configuration (.babelrc, package.json, cli command)

package.json

"scripts": {
    "client:dev": "parcel watch --target=client",
    "server:dev": "parcel watch --target=server",
    "develop:beta": "concurrently 'yarn client:dev' 'yarn server:dev'"
  },
  "targets": {
    "client": {
      "context": "browser",
      "source": "./src/index.html",
      "distDir": "./dist/assets",
      "publicUrl": "/assets/"
    },
    "server": {
      "context": "node",
      "outputFormat": "esmodule",
      "source": "./src/server-entry.tsx",
      "distDir": "./dist/server",
      "publicUrl": "/assets/",
      "includeNodeModules": false,
      "sourceMap": true
    }
  },

πŸ€” Expected Behavior

No errors in final compression stage

😯 Current Behavior

Described above

πŸ’ Possible Solution

A Way to skip compressors for file globs?

πŸ”¦ Context

We are trying a build a very large server rendered react application with parcel.

πŸ’» Code Sample

Happens in a private repo.

🌍 Your Environment

Software Version(s)
Parcel 2.7.0
Node 16.14.2
npm/Yarn yarn 1.22.19
Operating System macOS Mac M1 Pro

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 2
  • Comments: 21 (5 by maintainers)

Most upvoted comments

Still getting this issue on parcel v2.8.0. Any idea on how to fix?

Still getting this error on 2.10.0