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

Uncaught TypeError: Super expression must either be null or a function #105

Closed
arianitu opened this issue Apr 1, 2020 · 1 comment
Closed

Comments

@arianitu
Copy link

arianitu commented Apr 1, 2020

When I use webpack and do a production build, it breaks in production. Stack points to this library and after I no longer include react-particles-js I do not get this error anymore.

Specifically breaks on }(f.Component);

Does anyone use this with webpack or in production?

            Object.defineProperty(t, "__esModule", {
                value: !0
            });
            var l = s(n(14))
              , f = n(14)
              , d = n(2)
              , p = u(n(37))
              , h = function(e) {
                function t(e) {
                    var n;
                    return function(e, t) {
                        if (!(e instanceof t))
                            throw new TypeError("Cannot call a class as a function")
                    }(this, t),
                    (n = function(e, t) {
                        return !t || "object" !== r(t) && "function" != typeof t ? a(e) : t
                    }(this, c(t).call(this, e))).state = {
                        canvas: void 0,
                        library: void 0
                    },
                    n.loadCanvas = n.loadCanvas.bind(a(n)),
                    n
                }
                var n, s;
                return function(e, t) {
                    throw new TypeError("Super expression must either be null or a function")
                }(),
                n = t,
                (s = [{
                    key: "buildParticlesLibrary",
                    value: function(e) {
                        try {
                            if (void 0 === window)
                                return null
                        } catch (e) {
                            return null
                        }
                        return new d.ParticlesLibrary(e)
                    }
                }, {
                    key: "refresh",
                    value: function(e) {
                        var t = this
                          , n = this.state.canvas;
                        n && (this.destroy(),
                        this.setState({
                            library: this.buildParticlesLibrary(e.params)
                        }, function() {
                            t.loadCanvas(n)
                        }))
                    }
                }, {
                    key: "destroy",
                    value: function() {
                        this.state.library && this.state.library.destroy()
                    }
                }, {
                    key: "loadCanvas",
                    value: function(e) {
                        var t = this;
                        e && this.setState({
                            canvas: e
                        }, function() {
                            var n = t.state.library;
                            n && (n.loadCanvas(e),
                            n.start())
                        })
                    }
                }, {
                    key: "shouldComponentUpdate",
                    value: function(e) {
                        return !p.default(e, this.props)
                    }
                }, {
                    key: "componentDidUpdate",
                    value: function() {
                        this.refresh(this.props)
                    }
                }, {
                    key: "forceUpdate",
                    value: function() {
                        this.refresh(this.props),
                        i(c(t.prototype), "forceUpdate", this).call(this)
                    }
                }, {
                    key: "componentDidMount",
                    value: function() {
                        this.setState({
                            library: this.buildParticlesLibrary(this.props.params)
                        })
                    }
                }, {
                    key: "componentWillUnmount",
                    value: function() {
                        this.destroy(),
                        this.setState({
                            library: void 0
                        })
                    }
                }, {
                    key: "render",
                    value: function() {
                        var e = this.props
                          , t = e.width
                          , n = e.height
                          , r = e.className
                          , o = e.canvasClassName;
                        return l.createElement("div", {
                            className: r
                        }, l.createElement("canvas", {
                            ref: this.loadCanvas,
                            className: o,
                            style: Object.assign(Object.assign({}, this.props.style), {
                                width: t,
                                height: n
                            })
                        }))
                    }
                }]) && o(n.prototype, s),
                t
            }(f.Component);
@arianitu
Copy link
Author

arianitu commented Apr 1, 2020

This was a bug from terser-webpack-plugin version 1.2.3. See terser/terser#308

We fixed it by running npm install terser-webpack-plugin@latest

@arianitu arianitu closed this as completed Apr 1, 2020
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