parcel-bundler / parcel

The zero configuration build tool for the web. 📦🚀
https://parceljs.org
MIT License
43.4k stars 2.26k forks source link

Parcel build error...undefined is not a non-null object #4041

Closed AshotN closed 4 years ago

AshotN commented 4 years ago

🐛 bug report

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

{
    "name": "ampache-client",
    "version": "1.0.0",
    "description": "Client side for Ampache server",
    "repository": "https://github.com/ampache/ampache/tree/react-client",
    "author": "Ashot Nazaryan",
    "license": "AGPL-3.0-only",
    "dependencies": {
        "@babel/runtime": "^7.7.4",
        "@types/wicg-mediasession": "^1.0.3",
        "axios": "^0.19.0",
        "images": "^3.0.2",
        "js-cookie": "^2.2.1",
        "react": "^16.12.0",
        "react-audio-player": "^0.11.1",
        "react-dom": "npm:@hot-loader/react-dom",
        "react-hotkeys-hook": "^1.5.3",
        "react-input-range": "^1.3.0",
        "react-loading": "^2.0.3",
        "react-router-dom": "^5.1.2",
        "react-toastify": "^5.4.1",
        "react-use-context-menu": "^0.1.3"
    },
    "scripts": {
        "start": "parcel start index.html",
        "build": "parcel build index.html",
        "prod": "rm -rf dist && parcel build index.html --no-source-maps",
        "watch": "parcel watch index.html"
    },
    "eslintConfig": {
        "extends": "react-app"
    },
    "default": "dist/index.html",
    "targets": {
        "default": {
            "publicUrl": "/client/dist/"
        }
    },
    "browserslist": {
        "production": [
            "last 1 version",
            "> 1%",
            "not dead"
        ],
        "development": [
            "last 1 chrome version",
            "last 1 firefox version",
            "last 1 safari version"
        ]
    },
    "postcss": {
        "plugins": {
            "autoprefixer": true
        }
    },
    "devDependencies": {
        "@babel/core": "^7.8.3",
        "@babel/plugin-proposal-class-properties": "^7.8.3",
        "@babel/plugin-transform-runtime": "^7.8.3",
        "@babel/preset-env": "^7.8.3",
        "@babel/preset-react": "^7.8.3",
        "@babel/preset-typescript": "^7.8.3",
        "@parcel/resolver-default": "^2.0.0-alpha.3",
        "@types/node": "^12.12.14",
        "@types/react": "^16.9.11",
        "@types/react-dom": "^16.9.4",
        "@types/react-router-dom": "^5.1.2",
        "@typescript-eslint/eslint-plugin": "^2.10.0",
        "@typescript-eslint/parser": "^2.10.0",
        "autoprefixer": "^9.7.4",
        "eslint": "^6.7.2",
        "eslint-plugin-react": "^7.17.0",
        "eslint-plugin-react-hooks": "^2.3.0",
        "parcel": "^2.0.0-alpha.3.2",
        "postcss-modules": "^1.5.0",
        "prettier": "1.19.1",
        "react-hot-loader": "^4.12.16",
        "stylus": "^0.54.7",
        "typescript": "^3.7.2"
    },
    "alias": {
        "components": "./src/components"
    }
}
{
  {
    "presets": [
        "@babel/preset-typescript",
        "@babel/preset-env",
        "@babel/preset-react"
    ],
    "plugins": [
        "react-hot-loader/babel",
        "@babel/plugin-transform-runtime",
        "@babel/plugin-proposal-class-properties"
    ]
}

}

🤔 Expected Behavior

Using yarn build(parcel build index.html) to produce optimized build.

😯 Current Behavior

Parcel successfully bundles everything, but the browser throws an error.

Chromium

Uncaught TypeError: Object.defineProperty called on non-object
    at Function.defineProperty (<anonymous>)

Firefox

TypeError: undefined is not a non-null object

🔦 Context

yarn watch works fine. So perhaps it's something that is unique to parcel build

💻 Code Sample

The repo is on Github

🌍 Your Environment

Software Version(s)
Parcel 2.0.0-alpha.3.2
Yarn 1.19.2
Operating System 18.04.1-Ubuntu
mischnic commented 4 years ago

(Unrelated, but hot reloading should work without any extra packages via https://facebook.github.io/react-native/docs/fast-refresh)

AshotN commented 4 years ago

(Unrelated, but hot reloading should work without any extra packages via https://facebook.github.io/react-native/docs/fast-refresh)

Cool, I'll check that out. I'm willing to take criticism anywhere in the repo :P

mischnic commented 4 years ago

Somehow, an exports variable is used before its initialization:

// ASSET: .../node_modules/autobind-decorator/lib/index.js
Object.defineProperty($b7dd60b1fe7834f360ce428629db247b$exports, '__esModule', {
  value: true
});

// ....

var $b7dd60b1fe7834f360ce428629db247b$exports = $b7dd60b1fe7834f360ce428629db247b$export$default;

Minimum example:

import InputRange from 'react-input-range';

console.log(InputRange)

Testing again with the current version on the v2 branch, this seem to be fixed in the next release already.

mischnic commented 4 years ago

Fixed in the nightly version (yarn add -D parcel@nightly)