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

[bug] "@parcel/packager-js: Got unexpected null" -- related to scope-hoisting #9970

Open
stargazer33 opened this issue Sep 30, 2024 · 0 comments

Comments

@stargazer33
Copy link

🐛 bug report

Build failed with @parcel/packager-js: Got unexpected null

🎛 Configuration ( package.json, cli command)

package.json:

{
  "name": "typesense-front-bs",
  "description": "",
  "version": "1.0.0",
  "private": true,
  "targets": {
    "bs": {
      "source": "src/bs-index.html",
      "distDir": "./dist/bs"
    },
    "ex": {
      "source": [
        "src/ex.html",
        "src/help.html"
      ],
      "distDir": "./dist/ex"
    }
  },
  "@parcel/runtime-js": {
    "splitManifestThreshold": 999999
  },
  "scripts": {
    "build-ex-prod":  "NODE_ENV=prod  parcel build --target ex  --no-autoinstall --no-cache ",
  },
  "dependencies": {
    "@babel/runtime": "7.25.0",
    "@popperjs/core": "2.11.8",
    "bootstrap": "5.3.3",
    "bootstrap-icons": "1.11.3",
    "sass": "1.77.6",
    "typesense": "1.8.2"
  },
  "devDependencies": {
    "@babel/core": "7.25.2",
    "@babel/preset-env": "7.25.4",
    "@parcel/config-default": "2.12.0",
    "@parcel/namer-default": "2.12.0",
    "@parcel/optimizer-svgo": "2.12.0",
    "@parcel/packager-html": "2.12.0",
    "@parcel/packager-raw": "2.12.0",
    "@parcel/reporter-bundle-analyzer": "2.12.0",
    "@parcel/reporter-cli": "2.12.0",
    "@parcel/transformer-raw": "2.12.0",
    "@parcel/transformer-sass": "2.12.0",
    "babel-jest": "29.7.0",
    "dotenv": "16.4.5",
    "jest": "29.7.0",
    "parcel": "2.12.0"
  }

Command line (Ubuntu):

> node --version
v20.16.0
> npm --version
10.8.1
> parcel --version
2.12.0
> parcel build --target ex  --no-autoinstall --no-cache
...
You are trying to configure cleanupIDs which is not part of preset-default.
Try to put it before or after, for example

plugins: [
  {
    name: 'preset-default',
  },
  'cleanupIDs'
]

You are trying to configure cleanupIDs which is not part of preset-default.
Try to put it before or after, for example

plugins: [
  {
    name: 'preset-default',
  },
  'cleanupIDs'
]
🚨 Build failed.

@parcel/packager-js: Got unexpected null

  Error: Got unexpected null
      at nullthrows (<mypath>/node_modules/nullthrows/nullthrows.js:7:15)
      at <mypath>/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:864:51
      at Array.every (<anonymous>)
      at <mypath>/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:863:35
      at Array.filter (<anonymous>)
      at ScopeHoistingPackager.buildAssetPrelude 
  (<mypath>/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:853:60)
      at ScopeHoistingPackager.buildAsset (<mypath>/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:404:48)
      at ScopeHoistingPackager.visitAsset (<mypath>/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:359:17)
      at processAsset (<mypath>/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:142:40)
      at ScopeHoistingPackager.package (<mypath>/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:156:9)

🤔 Expected Behavior

Build works

😯 Current Behavior

Build fails, see "Configuration"

💁 Possible Solution

This is a WORKAROUND, not a solution!
Just added --no-scope-hoist

>parcel build --target ex  --no-autoinstall --no-cache --no-scope-hoist
...
You are trying to configure cleanupIDs which is not part of preset-default.
Try to put it before or after, for example

plugins: [
  {
    name: 'preset-default',
  },
  'cleanupIDs'
]

You are trying to configure cleanupIDs which is not part of preset-default.
Try to put it before or after, for example

plugins: [
  {
    name: 'preset-default',
  },
  'cleanupIDs'
]
✨ Built in 6.39s

dist/ex/ex.html              23.64 KB    531ms
dist/ex/help.html             6.44 KB    419ms
dist/ex/ex.b99290e1.css      158.8 KB    431ms
dist/ex/help.9c4f8225.js    107.97 KB    613ms
dist/ex/ex.c72246c2.js      199.81 KB    1.19s

🔦 Context

Have to use --no-scope-hoist all the time.
Generated .js files are too big because of this.

🌍 Your Environment

Software Version(s)
Parcel 2.12.0
Node v20.16.0
npm/Yarn npm 10.8.1
Operating System Ubuntu 22.04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant