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

@parcel/bundler-default: The expression evaluated to a falsy value (CSS modules and non-modules) #8716

Closed
nartallax opened this issue Dec 26, 2022 · 16 comments
Assignees

Comments

@nartallax
Copy link

🐛 bug report

In particular circumstances I get following error when building my project:

@parcel/bundler-default: The expression evaluated to a falsy value:

  (0, _assert().default)(bundle !== 'root' && bundle != null)

🎛 Configuration (.babelrc, package.json, cli command)

Minimal example is here

Key points: if there is non-module CSS file and more than one module CSS files in project - build will fail.

Build command is

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

🤔 Expected Behavior

Build should not fail. I don't think this CSS structure is wrong or unobvious; at least it should lead to better error than just "assertion failed"

😯 Current Behavior

Build fails with following stack trace:

@parcel/bundler-default: The expression evaluated to a falsy value:

  (0, _assert().default)(bundle !== 'root' && bundle != null)


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

    (0, _assert().default)(bundle !== 'root' && bundle != null)

      at getBundleFromBundleRoot (/Users/MY_USERNAME/parcel_css_bug/node_modules/@parcel/bundler-default/lib/DefaultBundler.js:1018:27)
      at createIdealGraph (/Users/MY_USERNAME/parcel_css_bug/node_modules/@parcel/bundler-default/lib/DefaultBundler.js:692:21)
      at Object.bundle (/Users/MY_USERNAME/parcel_css_bug/node_modules/@parcel/bundler-default/lib/DefaultBundler.js:122:19)
      at BundlerRunner.bundle (/Users/MY_USERNAME/parcel_css_bug/node_modules/@parcel/core/lib/requests/BundleGraphRequest.js:288:23)
      at async Object.run (/Users/MY_USERNAME/parcel_css_bug/node_modules/@parcel/core/lib/requests/BundleGraphRequest.js:156:17)
      at async RequestTracker.runRequest (/Users/MY_USERNAME/parcel_css_bug/node_modules/@parcel/core/lib/RequestTracker.js:756:20)
      at async Object.run (/Users/MY_USERNAME/parcel_css_bug/node_modules/@parcel/core/lib/requests/ParcelBuildRequest.js:56:7)
      at async RequestTracker.runRequest (/Users/MY_USERNAME/parcel_css_bug/node_modules/@parcel/core/lib/RequestTracker.js:756:20)
      at async Parcel._build (/Users/MY_USERNAME/parcel_css_bug/node_modules/@parcel/core/lib/Parcel.js:400:11)
      at async Parcel.run (/Users/MY_USERNAME/parcel_css_bug/node_modules/@parcel/core/lib/Parcel.js:276:18)

🔦 Context

I'm just developing some websites lol

💻 Code Sample

Minimal example is here

🌍 Your Environment

Software Version(s)
Parcel 2.8.2
Node v16.16.0
npm/Yarn 8.11.0
Operating System macOS 13.0.1
@mischnic
Copy link
Member

cc @AGawrys

@oe
Copy link

oe commented Dec 27, 2022

same here with parcel@2.8.2

@JulianGibelli
Copy link

Same here! parcel version 2.8.2
image

@littleLane
Copy link

+1

@devongovett
Copy link
Member

Should be fixed by #8762

@shepmaster
Copy link

shepmaster commented Jan 25, 2023

I see that this is closed and should have been fixed by 2.8.3. However, after upgrading from 2.8.0 to 2.8.3, I still see the same error:

🚨 Build failed.

@parcel/bundler-default: The expression evaluated to a falsy value:

  (0, _assert().default)(bundle !== 'root' && bundle != null)


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

    (0, _assert().default)(bundle !== 'root' && bundle != null)

      at getBundleFromBundleRoot (...project.../node_modules/@parcel/bundler-default/lib/DefaultBundler.js:1033:27)
      at createIdealGraph (...project.../node_modules/@parcel/bundler-default/lib/DefaultBundler.js:698:21)
      at Object.bundle (...project.../node_modules/@parcel/bundler-default/lib/DefaultBundler.js:122:19)
      at BundlerRunner.bundle (...project.../node_modules/@parcel/core/lib/requests/BundleGraphRequest.js:288:23)
      at async Object.run (...project.../node_modules/@parcel/core/lib/requests/BundleGraphRequest.js:156:17)
      at async RequestTracker.runRequest (...project.../node_modules/@parcel/core/lib/RequestTracker.js:756:20)
      at async Object.run (...project.../node_modules/@parcel/core/lib/requests/ParcelBuildRequest.js:56:7)
      at async RequestTracker.runRequest (...project.../node_modules/@parcel/core/lib/RequestTracker.js:756:20)
      at async Parcel._build (...project.../node_modules/@parcel/core/lib/Parcel.js:400:11)
at async Parcel._startNextBuild (...project.../node_modules/@parcel/core/lib/Parcel.js:298:24)

What should I look for in my project to see what might be unique from the cases that were already fixed?

@AGawrys
Copy link
Contributor

AGawrys commented Jan 25, 2023

Might just be the same symptom. Do you have a repro or repo I could look at? @shepmaster

@shepmaster
Copy link

shepmaster commented Jan 25, 2023

Here is a minimized example: repro.zip. Unzip it, run yarn && yarn build to see the error. I'm using Node v19.4.0 on macOS.

My gut tells me that it has to do with using the extends feature of CSS modules, but I've got nothing concrete to back that up. Thanks!

@mischnic mischnic reopened this Feb 6, 2023
@itaylor
Copy link

itaylor commented Mar 7, 2023

I also have this problem, it's definitely caused by css modules composes, which my project makes extensive use of.

It looks like the file referenced in the compose statement is added as an asset dependency, but then doing that messes up the bundleRootGraph somehow in createIdealGraph in DefaultBundler (perhaps only if the composed file is also a css module?).

Using @shepmaster's repro from above and then removing the statement:

             asset.addDependency({
                specifier: ref.specifier,
                specifierType: 'esm',
              });

From the CSSTransformer's handling of composes solves the error in the build, and it still retains the composed css.

It looks like this was added fairly recently to improve css import ordering:
ddae31a#diff-4a76ab5816b5309c818b936e2b32e9beeca804ecf94c2bd18cc22108e02b5274

@devongovett
Copy link
Member

Should be fixed by #8885

@martindavid
Copy link

@devongovett how to get the fixed version for this? Should there be a patch version release for this?

@chrissound
Copy link

I got this error when running parcel with additional html files (with 0 css links/references) in a article/ directory.

Basically parcel webroot/index.html works, while parcel webroot/index.html webroot/article/*.html resulted in this error...

@mischnic
Copy link
Member

There will be a release including the fix very soon

@geremsadaimary
Copy link

why is this closed without being fixed

@anupxroutray
Copy link

anupxroutray commented Feb 21, 2024

+1 @geremsadaimary @mischnic

@sohamshet26
Copy link

I see that this is closed and should have been fixed by 2.8.3. However, after upgrading from 2.8.0 to 2.8.3, I still see the same error:

🚨 Build failed.

@parcel/bundler-default: The expression evaluated to a falsy value:

  (0, _assert().default)(bundle !== 'root' && bundle != null)


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

    (0, _assert().default)(bundle !== 'root' && bundle != null)

      at getBundleFromBundleRoot (...project.../node_modules/@parcel/bundler-default/lib/DefaultBundler.js:1033:27)
      at createIdealGraph (...project.../node_modules/@parcel/bundler-default/lib/DefaultBundler.js:698:21)
      at Object.bundle (...project.../node_modules/@parcel/bundler-default/lib/DefaultBundler.js:122:19)
      at BundlerRunner.bundle (...project.../node_modules/@parcel/core/lib/requests/BundleGraphRequest.js:288:23)
      at async Object.run (...project.../node_modules/@parcel/core/lib/requests/BundleGraphRequest.js:156:17)
      at async RequestTracker.runRequest (...project.../node_modules/@parcel/core/lib/RequestTracker.js:756:20)
      at async Object.run (...project.../node_modules/@parcel/core/lib/requests/ParcelBuildRequest.js:56:7)
      at async RequestTracker.runRequest (...project.../node_modules/@parcel/core/lib/RequestTracker.js:756:20)
      at async Parcel._build (...project.../node_modules/@parcel/core/lib/Parcel.js:400:11)
at async Parcel._startNextBuild (...project.../node_modules/@parcel/core/lib/Parcel.js:298:24)

What should I look for in my project to see what might be unique from the cases that were already fixed?

i have also got this type of error but i just cleared my parcel cashe and the error was resolved

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

No branches or pull requests