parcel-bundler / parcel

The zero configuration build tool for the web. πŸ“¦πŸš€

Home Page:https://parceljs.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

@parcel/core: Error: The expression evaluated to a falsy value

Poky85 opened this issue Β· comments

πŸ› bug report

In some circumstances I get the following error during project build:

🚨 Build failed.

Error: The expression evaluated to a falsy value:

  (0, _assert().default)(internalBundleGraph != null)


  AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:

    (0, _assert().default)(internalBundleGraph != null)

      at BundlerRunner.bundle (/Users/poky85/projects/webapp/node_modules/@parcel/core/lib/requests/BundleGraphRequest.js:318:29)
      at async Object.run (/Users/poky85/projects/webapp/node_modules/@parcel/core/lib/requests/BundleGraphRequest.js:129:17)
      at async RequestTracker.runRequest (/Users/poky85/projects/webapp/node_modules/@parcel/core/lib/RequestTracker.js:673:20)
      at async Object.run (/Users/poky85/projects/webapp/node_modules/@parcel/core/lib/requests/ParcelBuildRequest.js:52:7)
      at async RequestTracker.runRequest (/Users/poky85/projects/webapp/node_modules/@parcel/core/lib/RequestTracker.js:673:20)
      at async Parcel._build (/Users/poky85/projects/webapp/node_modules/@parcel/core/lib/Parcel.js:336:11)
      at async Parcel.run (/Users/poky85/projects/webapp/node_modules/@parcel/core/lib/Parcel.js:205:18)
      at async run (/Users/poky85/projects/webapp/node_modules/parcel/lib/cli.js:305:7)

This is similar to #8716 (comment) But I believe that this is not duplicate.

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

.parcel.rc

{
  "extends": "@parcel/config-default",
  "transformers": {
    "*.{css,pcss}": ["parcel-transformer-ts-css-modules", "..."],
    "*.{woff,woff2}": ["@parcel/transformer-raw"]
  }
}

CLI command

./node_modules/.bin/parcel build src/index.html --no-cache

package.json

{
	"private": true,
	"dependencies": {
		"@apollo/client": "^3.10.3",
		"@aws-sdk/client-cloudwatch-logs": "^3.569.0",
		"@codemirror/autocomplete": "^6.16.0",
		"@codemirror/commands": "^6.5.0",
		"@codemirror/lang-json": "^6.0.1",
		"@codemirror/language": "^6.10.1",
		"@codemirror/lint": "^6.7.0",
		"@codemirror/state": "^6.4.1",
		"@codemirror/view": "^6.26.3",
		"@emotion/react": "^11.11.4",
		"@emotion/styled": "^11.11.5",
		"@formatjs/intl-datetimeformat": "^6.12.3",
		"@formatjs/intl-getcanonicallocales": "^2.3.0",
		"@formatjs/intl-locale": "^3.4.5",
		"@formatjs/intl-numberformat": "^8.10.1",
		"@formatjs/intl-pluralrules": "^5.2.12",
		"@formatjs/intl-relativetimeformat": "^11.2.12",
		"@lezer/highlight": "^1.2.0",
		"@mui/material": "^5.15.16",
		"@mui/x-data-grid": "^7.3.2",
		"@sentry/browser": "^7.113.0",
		"@sentry/cli": "^2.31.2",
		"@sentry/integrations": "^7.113.0",
		"@stripe/react-stripe-js": "^2.7.1",
		"@stripe/stripe-js": "^3.4.0",
		"@tiptap/extension-underline": "^2.3.1",
		"@tiptap/pm": "^2.3.1",
		"@tiptap/react": "^2.3.1",
		"@tiptap/starter-kit": "^2.3.1",
		"@types/js-cookie": "^3.0.6",
		"@types/react-datepicker": "^4.15.0",
		"@types/uuid": "^9.0.8",
		"@ui-schema/kit-codemirror": "^0.1.0-alpha.1",
		"apollo-link-sentry": "^3.3.0",
		"calendar-link": "^2.6.0",
		"chart.js": "^4.2.1",
		"chartjs-adapter-date-fns": "^3.0.0",
		"chartjs-plugin-annotation": "^3.0.1",
		"chartjs-plugin-datalabels": "^2.2.0",
		"classnames": "^2.5.1",
		"date-fns": "^3.6.0",
		"firebase": "^10.11.1",
		"form-data": "^4.0.0",
		"formik": "^2.4.6",
		"formik-mui": "^4.0.0",
		"graphql": "^16.8.1",
		"html-to-text": "^9.0.5",
		"js-cookie": "^3.0.5",
		"libphonenumber-js": "^1.11.1",
		"lightgallery": "2.5.0",
		"lodash": "^4.17.21",
		"path-to-regexp": "^6.2.2",
		"react": "^18.3.1",
		"react-big-calendar": "1.8.2",
		"react-chartjs-2": "^5.2.0",
		"react-datepicker": "^4.17.0",
		"react-dnd": "^16.0.1",
		"react-dnd-html5-backend": "^16.0.1",
		"react-dom": "^18.3.1",
		"react-intl": "^6.6.6",
		"react-markdown": "^8.0.7",
		"react-speech-recognition": "^3.10.0",
		"regenerator-runtime": "^0.14.1",
		"remark-gfm": "^3.0.1",
		"rodnecislo": "^1.6.0",
		"serialize-error": "^11.0.3",
		"tinyduration": "^3.3.0",
		"ts-polyfill": "^3.8.2",
		"typescript": "^5.4.5",
		"wouter": "^2.11.0",
		"yup": "^0.32.11"
	},
	"browserslist": "last 10 Chrome versions, last 10 Firefox versions, last 5 Safari versions, iOS >= 13",
	"devDependencies": {
		"@formatjs/cli": "^6.2.10",
		"@graphql-codegen/add": "^5.0.2",
		"@graphql-codegen/cli": "^5.0.2",
		"@graphql-codegen/fragment-matcher": "^5.0.2",
		"@graphql-codegen/schema-ast": "^4.0.2",
		"@graphql-codegen/typescript": "^4.0.6",
		"@graphql-codegen/typescript-operations": "^4.2.0",
		"@graphql-eslint/eslint-plugin": "^3.20.1",
		"@parcel/config-default": "^2.12.0",
		"@parcel/core": "^2.12.0",
		"@parcel/reporter-bundle-analyzer": "^2.12.0",
		"@parcel/transformer-less": "^2.12.0",
		"@sentry/types": "^7.113.0",
		"@swc/jest": "^0.2.36",
		"@testing-library/jest-dom": "^6.4.5",
		"@testing-library/react": "^15.0.7",
		"@testing-library/user-event": "^14.5.2",
		"@types/aws-lambda": "^8.10.137",
		"@types/firebase": "^3.2.1",
		"@types/html-to-text": "^9.0.4",
		"@types/jest": "^29.5.12",
		"@types/lodash": "^4.17.1",
		"@types/node": "^20.12.11",
		"@types/react": "^18.3.1",
		"@types/react-big-calendar": "^1.8.9",
		"@types/react-dom": "^18.3.0",
		"@types/react-speech-recognition": "^3.9.5",
		"@typescript-eslint/eslint-plugin": "^7.8.0",
		"@typescript-eslint/parser": "^7.8.0",
		"apollo": "^2.34.0",
		"babel-jest": "^29.7.0",
		"babel-plugin-formatjs": "^10.5.14",
		"babel-plugin-transform-import-meta": "^2.2.1",
		"buffer": "^6.0.3",
		"eslint": "^8.57.0",
		"eslint-config-prettier": "^9.1.0",
		"eslint-plugin-formatjs": "^4.13.1",
		"eslint-plugin-import": "^2.29.1",
		"eslint-plugin-prefer-arrow": "^1.2.3",
		"eslint-plugin-react-hooks": "^4.6.2",
		"fetch-mock": "^9.11.0",
		"identity-obj-proxy": "^3.0.0",
		"jest": "^29.7.0",
		"jest-date-mock": "^1.0.10",
		"jest-environment-jsdom": "^29.7.0",
		"less": "^4.2.0",
		"lint-staged": "^15.2.2",
		"parcel": "^2.12.0",
		"parcel-transformer-ts-css-modules": "^1.0.14",
		"pre-commit": "^1.2.2",
		"prettier": "^3.2.5",
		"process": "^0.11.10"
	}
}

babel.config.json

{
  "plugins": [["formatjs", { "ast": true, "idInterpolationPattern": "[sha512:contenthash:base64:10]"}]]
}

πŸ€” Expected Behavior

Build should not fail or give me instructive error. This error contains no module's path, dump of code etc. It's very hard to debug it in the large codebase.

😯 Current Behavior

Development server runs just fine. It fails during build.

πŸ”¦ Context

I'm updating my project from Parcel 2.7 do latest Parcel 2.12. Project build fails in 2.12 while it builds successfully in 2.7. No change in Parcel configuration has been made. I've updated all Parcel related modules (except for parcel-transformer-ts-css-modules transformer which I removed to check that issues is not caused by non-updated transformer).

In project I use:

  • latest Typescript
  • dynamic imports in Typescript
  • LESS and both CSS modules and non-module CSS
  • most of libraries are up-to-date
  • Babel is used only for some i18n transformations (format.js) and in test environment (Jest)

πŸ’» Code Sample

I'm happy to investigate this further and I would appreciate any clues that will help me to create minimal reproduction example. It's really hard to find root of cause in large code base. I've already spent several hours on eliminating issues reported before.

What I've tried so far:

  • Drop all CSS modules and even non-module CSS as there were CSS modules related issue reported in #8716 (comment) I've also dropped all composes: className; LESS rules () – no success.
  • Ensure that dynamic imports occurs after all static import (and exports) as there were hint that this could break the build #8442 (comment)
  • Override any LESS/CSS tranformations by following .parcelrc configuration:
{
  "extends": "@parcel/config-default",
  "transformers": {
    "*.less": ["@parcel/transformer-raw"], 
    "*.css": ["@parcel/transformer-raw"],
  }
}
  • Remove any reporters that I've used before (@parcel/reporter-bundle-analyze, @parcel/reporter-cli)
  • Prune my codebase to narrow code that raises the error. There is certainly work to do here. I was not successful so far.
  • Build using other Parcel versions 2.10, 2.10.3 and 2.11.
  • (I always remove .parcel-cache director before each try)

🌍 Your Environment

Software Version(s)
Parcel 2.12
Node 20.13.0
npm 10.5.2
Operating System macOS 14.4.1 (Apple M2 Max)