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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression in 2.9.0: @parcel/bundler-default: Got unexpected undefined for CSS modules #9058

Closed
arty-name opened this issue May 31, 2023 · 7 comments 路 Fixed by #9195
Closed
Assignees

Comments

@arty-name
Copy link
Contributor

arty-name commented May 31, 2023

馃悰 bug report

All of my parcel-using projects started getting this error when trying to upgrade to parcel 2.9.0 (and 2.9.1 as well):

馃帥 Configuration (.babelrc, package.json, cli command)

I think I don鈥檛 set any babel configuration, and the only non-paths configuration is:

{
 "context": "browser"
}

Since the projects are open-source, you can see all the details in their repositories.

馃 Expected Behavior

The bundler should bundle these projects, since the previous version of bundler managed that.

馃槸 Current Behavior

Both parcel watch and parcel build fail with the error "@parcel/bundler-default: Got unexpected undefined". It happens either in DefaultBundler.js:731:72 or in DefaultBundler.js:707:62:

$ parcel
Server running at http://localhost:1234
馃毃 Build failed.

@parcel/bundler-default: Got unexpected undefined

  Error: Got unexpected undefined
      at nullthrows (didsign/node_modules/nullthrows/nullthrows.js:7:15)
      at didsign/node_modules/@parcel/bundler-default/lib/DefaultBundler.js:731:72
      at Array.map (<anonymous>)
      at createIdealGraph (didsign/node_modules/@parcel/bundler-default/lib/DefaultBundler.js:731:37)
      at Object.bundle (didsign/node_modules/@parcel/bundler-default/lib/DefaultBundler.js:105:19)
      at BundlerRunner.bundle (didsign/node_modules/@parcel/core/lib/requests/BundleGraphRequest.js:258:23)
      at async Object.run (didsign/node_modules/@parcel/core/lib/requests/BundleGraphRequest.js:126:17)
      at async RequestTracker.runRequest (didsign/node_modules/@parcel/core/lib/RequestTracker.js:633:20)
      at async Object.run (didsign/node_modules/@parcel/core/lib/requests/ParcelBuildRequest.js:51:7)
      at async RequestTracker.runRequest (didsign/node_modules/@parcel/core/lib/RequestTracker.js:633:20)

People have reported other issues about "Got unexpected undefined" but they affect earlier versions, and they do not originate from the default bundler.

馃敠 Context

The issue seems to be related to me using CSS modules extensively. I was investigating this failure, and it happens here when the reachable only contains two items [Asset(VerifiedFiles.module.css), Asset(FilesEmpty.module.css)] and their id are both absent from bundles.

You might notice that the projects were using parcel@2.7.0 before the attempted upgrade. This is because of parcel bugs in 2.8.0 and 2.8.1 where the build has completed successfully, but the output referred to nonexistent constants.

馃捇 Code Sample

馃實 Your Environment

Software Version(s)
Parcel 2.9.0
Node 18.16.0
npm/Yarn yarn 1.22.19
Operating System GitHub Runner Ubuntu 22.04.2
@mischnic
Copy link
Member

mischnic commented Jun 4, 2023

Minimal reproduction: Archiv.zip

Looks like having two CSS module assets that both have composes: ... from "./something.module.css"; referring to the same file triggers this.

cc @AGawrys

@shepmaster
Copy link

Is there anything the community can do to address this bug?

@AGawrys AGawrys self-assigned this Aug 2, 2023
@keithlayne
Copy link

I think I've run into this issue too - we use a combination of css, scss both with and without modules. We have a shared config that is used to build a bunch of small projects (without package.json) is a directory tree.

I had parcel (and @parcel/*) pinned to 2.8.2 until recently, when I upgraded to 2.9.3. Today I realized some of the subprojects were failing to build with what looks like an identical error to what's mentioned in this issue.

I didn't make the connection until just now that one of the successful builds uses an SCSS file in a style tag, but imports react components that are using (plain) CSS modules. One of the failures has an import using SCSS modules. I know that's not a lot to work off, but maybe it will help.

This was working with 2.8.2. I tried 2.9.0, 2.9.1, and 2.9.2 and got the same errors with those, consistent with the OP.

Since the error is happening (for me) here I just cheated, and used this config as a workaround for now:

  "@parcel/bundler-default": {
    "minBundles": 1000
  }

It's unclear to me why this code would be hit. The entrypoint is an html file with a script tag pointing at a tsx file, and a style tag pointing at an scss file. Code splitting doesn't seem relevant here, but that probably just reflects my ignorance.

@keithlayne
Copy link

keithlayne commented Aug 2, 2023

Looking again, the graph for at least one of my failures looks something like this:

graph TD;
    A.tsx-->C.tsx;
    A.tsx-->B.tsx;
    B.tsx-->C.tsx;
    C.tsx-->C.module.css

Is it possible that multiple unique paths to a CSS module triggers this? Maybe that's similar to the minimal repro above?

EDIT: A very simple reproduction of this pattern worked fine.

@markafitzgerald1
Copy link

I'm seeing something similar to this issue right now on Parcel 2.9.3. I have two separate CSS modules, both of which var reference the same third CSS module (var(--foo from "./bar.module.css")). My situation looks very similar to the above from earlier versions of Parcel.

Here's my parcel serve error stack in case that's helpful:

馃毃 Build failed.

@parcel/bundler-default: Got unexpected undefined

  Error: Got unexpected undefined
      at nullthrows (/...../node_modules/nullthrows/nullthrows.js:7:15)
      at /...../node_modules/@parcel/bundler-default/lib/DefaultBundler.js:731:72
      at Array.map (<anonymous>)
      at createIdealGraph (/...../node_modules/@parcel/bundler-default/lib/DefaultBundler.js:731:37)
      at Object.bundle (/...../node_modules/@parcel/bundler-default/lib/DefaultBundler.js:105:19)
      at BundlerRunner.bundle (/...../node_modules/@parcel/core/lib/requests/BundleGraphRequest.js:258:23)
      at async Object.run (/...../node_modules/@parcel/core/lib/requests/BundleGraphRequest.js:126:17)
      at async RequestTracker.runRequest (/...../node_modules/@parcel/core/lib/RequestTracker.js:633:20)
      at async Object.run (/...../node_modules/@parcel/core/lib/requests/ParcelBuildRequest.js:51:7)
      at async RequestTracker.runRequest (/...../node_modules/@parcel/core/lib/RequestTracker.js:633:20)

@shepmaster
Copy link

@markafitzgerald1 this fix hasn't been released yet

@markafitzgerald1
Copy link

@markafitzgerald1 this fix hasn't been released yet

Ah, that makes sense. Thanks for explaining, @shepmaster. When I saw this issue was Closed I initially figured it would be released. On further inspection (and thought), I now see that the fix PR was merged and this Issue was closed in August 2023, but the last release (2.9.3) was on June 25, 2023. I'll stay tuned for the next release.

Thanks for testing out the PR fix in the nightly builds!

markafitzgerald1 added a commit to markafitzgerald1/cribbage-trainer that referenced this issue Oct 9, 2023
Landscape mode adjusted to show analyses to right of cards, resolving

CSS modules introduced to keep the complexity of application CSS
manageable. Local CSS variables not used due to bug in latest version
of Parcel (parcel-bundler/parcel#9058).
Candidate fix PR has been merged and is awaiting release in a future
version of Parcel.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants