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

CSS module composes triggers Got unexpected null in ScopeHoistingPackager #9071

Open
mischnic opened this issue Jun 4, 2023 · 5 comments
Open
Labels
🐛 Bug CSS Preprocessing All the PostCSS, Less, SASS, etc issues 🌳 Scope Hoisting

Comments

@mischnic
Copy link
Member

mischnic commented Jun 4, 2023

🐛 bug report

CSS module with composes triggers Got unexpected null

🤔 Expected Behavior

Works

😯 Current Behavior

  Error: Got unexpected null
      at nullthrows (parcel/node_modules/nullthrows/nullthrows.js:7:15)
      at every (parcel/packages/packagers/js/src/ScopeHoistingPackager.js:1081:35)
      at Array.every (<anonymous>)
      at filter (parcel/packages/packagers/js/src/ScopeHoistingPackager.js:1080:35)
      at Array.filter (<anonymous>)
      at ScopeHoistingPackager.buildAssetPrelude (parcel/packages/packagers/js/src/ScopeHoistingPackager.js:1069:60)
      at ScopeHoistingPackager.buildAsset (parcel/packages/packagers/js/src/ScopeHoistingPackager.js:448:48)
      at ScopeHoistingPackager.visitAsset (parcel/packages/packagers/js/src/ScopeHoistingPackager.js:383:17)
      at processAsset (parcel/packages/packagers/js/src/ScopeHoistingPackager.js:143:40)
      at visit (parcel/packages/packagers/js/src/ScopeHoistingPackager.js:170:7)
      at visit (parcel/packages/core/graph/src/Graph.js:504:16)
      at visit (parcel/packages/core/graph/src/Graph.js:504:16)
      at enter (parcel/packages/core/graph/src/Graph.js:504:16)
      at walk (parcel/packages/core/graph/src/Graph.js:346:26)
      at walk (parcel/packages/core/graph/src/Graph.js:367:22)
      at ContentGraph.dfs (parcel/packages/core/graph/src/Graph.js:395:12)
      at BundleGraph.traverseBundle (parcel/packages/core/core/src/BundleGraph.js:1321:24)
      at BundleGraph.traverseAssets (parcel/packages/core/core/src/BundleGraph.js:1117:17)
      at NamedBundle.traverseAssets (parcel/packages/core/core/src/public/Bundle.js:193:30)
      at ScopeHoistingPackager.package (parcel/packages/packagers/js/src/ScopeHoistingPackager.js:164:17)
      at processTicksAndRejections (node:internal/process/task_queues:95:5)
      at Object.package (parcel/packages/packagers/js/src/index.js:62:26)

💁 Possible Solution

Something about the JS generated for the CSS module has to trigger this?

🔦 Context

#9058

💻 Code Sample

src.zip

🌍 Your Environment

Software Version(s)
Parcel 0645f64
@mischnic mischnic added 🐛 Bug CSS Preprocessing All the PostCSS, Less, SASS, etc issues 🌳 Scope Hoisting labels Jun 4, 2023
@AndrewKvalheim
Copy link
Contributor

A reproduction trimmed down from my codebase:

$ echo 'export const c = "c"; export default "a";' > a.js
$ echo 'import { c } from "./a"; console.log(c);' > b.js
$ echo '<script type=module src='{a,b}'.js></script>' > index.html
$ yarn add parcel@2.8.3 && parcel build index.html
✨ Built in 722ms
$ yarn add parcel@2.9.2 && parcel build index.html
🚨 Build failed.

@parcel/packager-js: Got unexpected null

  Error: Got unexpected null
      at nullthrows (node_modules/nullthrows/nullthrows.js:7:15)
      at node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:813:51
      at Array.every (<anonymous>)
      at node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:812:35
      at Array.filter (<anonymous>)
      at ScopeHoistingPackager.buildAssetPrelude
  (node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:802:60)
      at ScopeHoistingPackager.buildAsset
  (node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:367:48)
      at ScopeHoistingPackager.visitAsset
  (node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:322:17)
      at processAsset (node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:126:40)
      at ScopeHoistingPackager.package
  (node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:140:9)

@colorgold
Copy link

I was having this same issue, but I solved it by running parcel build public/index.html --no-scope-hoist.
Adding the --no-scope-hoist is what did it for me. I don't know exactly what was preventing Parcel from "scope hoisting", so in the meantime I will go without it.

@DimaPFf
Copy link

DimaPFf commented Aug 3, 2023

Thank you! It works for me too!

@ajyoon
Copy link

ajyoon commented Oct 6, 2023

I'm running into this issue as well, coming from the same line in ScopeHoistingPackager.

fregante added a commit to pixiebrix/webext-messenger that referenced this issue Jan 21, 2024
Krzysztof-GoIT added a commit to Krzysztof-GoIT/goit-projekt-filmoteka that referenced this issue Mar 7, 2024
@github-actions github-actions bot added the Stale Inactive issues label Apr 4, 2024
@shepmaster
Copy link

Continues to happen in 2.12

🚨 Build failed.

@parcel/packager-js: Got unexpected null

  Error: Got unexpected null
      at nullthrows
  (<project>/node_modules/.pnpm/nullthrows@1.1.1/node_modules/nullthrows/nullthrows.js:7:15)
      at
  <project>/node_modules/.pnpm/@parcel+packager-js@2.12.0_@parcel+core@2.12.0/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:864:51
      at Array.every (<anonymous>)
      at
  <project>/node_modules/.pnpm/@parcel+packager-js@2.12.0_@parcel+core@2.12.0/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:863:35
      at Array.filter (<anonymous>)
      at ScopeHoistingPackager.buildAssetPrelude
  (<project>/node_modules/.pnpm/@parcel+packager-js@2.12.0_@parcel+core@2.12.0/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:853:60)
      at ScopeHoistingPackager.buildAsset
  (<project>/node_modules/.pnpm/@parcel+packager-js@2.12.0_@parcel+core@2.12.0/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:404:48)
      at ScopeHoistingPackager.visitAsset
  (<project>/node_modules/.pnpm/@parcel+packager-js@2.12.0_@parcel+core@2.12.0/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:359:17)
      at processAsset
  (<project>/node_modules/.pnpm/@parcel+packager-js@2.12.0_@parcel+core@2.12.0/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:142:40)
      at
  <project>/node_modules/.pnpm/@parcel+packager-js@2.12.0_@parcel+core@2.12.0/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:167:7

@github-actions github-actions bot removed the Stale Inactive issues label Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug CSS Preprocessing All the PostCSS, Less, SASS, etc issues 🌳 Scope Hoisting
Projects
None yet
Development

No branches or pull requests

6 participants