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, not undefined #7236

Open
matiasmenker opened this issue Jun 17, 2019 · 12 comments

Comments

@matiasmenker
Copy link

matiasmenker commented Jun 17, 2019

Is this a bug report?

Yes

Did you try recovering your dependencies?

Yes

Which terms did you search for in User Guide?

Yes i do

Environment

System:
OS: macOS 10.14.5
CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
Binaries:
Node: 8.11.3 - /usr/local/bin/node
Yarn: 1.15.2 - /usr/local/bin/yarn
npm: 5.7.1 - /usr/local/bin/npm
Browsers:
Chrome: 74.0.3729.169
Firefox: 64.0.2
Safari: 12.1.1
npmPackages:
react: ^16.8.6 => 16.8.6
react-dom: ^16.8.6 => 16.8.6
react-scripts: 3.0.1 => 3.0.1
npmGlobalPackages:
create-react-app: Not Found

Steps to Reproduce

  1. Create the build for production
  2. Server the build with serve
  3. Enter on the url that serve give for my

Expected Behavior

Server the build with a normal behave ( normal means the same that i have on a development build )

Actual Behavior

Yes, the app give a this error:

Uncaught TypeError: Super expression must either be null or a function, not undefined

Screenshot 2019-06-14 at 11 30 56

Here inside the error:
Screenshot 2019-06-14 at 11 37 21

Reproducible Demo

  1. Create a react app with cra
  2. Install this library https://github.com/dexma/ui-components
  3. Make a build to production
  4. Server the build with serve npm package

COMMENT:

I solved this problem putting keep_fnames: true on the minimizer plugin TerserPlugin options.

If you pass true to keep_fnames you prevent the compressor from discarding function names. Useful for code relying on Function.prototype.name

@mrmckeb
Copy link
Contributor

mrmckeb commented Jun 23, 2019

Thanks for updating this issue @menkermatias. It looks like the library author is minifying their code, which I think contributes to the issue (really, this shouldn't be needed as the client's Webpack config does it).

I'm not sure what to do here, but perhaps we can close the issue and leave it here as a reference for future?

@mrmckeb mrmckeb self-assigned this Jun 23, 2019
@matiasmenker
Copy link
Author

@mrmckeb Thanks! I think it will be nice to have this reference, by the way, do you think it's necessary can create a PR to prevent the compressor from discarding function names?

@mrmckeb
Copy link
Contributor

mrmckeb commented Jun 25, 2019

@menkermatias, I think that this shouldn't be necessary... if Terser is working correctly. I think we first need to understand where it's happening, and then look to fix the root cause.

@jilliankeenan
Copy link

any further updates on this?

@roadev
Copy link

roadev commented Dec 6, 2019

any further updates on this?

+1

@matiasmenker
Copy link
Author

I solved this problem putting keep_fnames: true on the minimizer plugin TerserPlugin options, @jilliankeenan @roadev did you try it?

@roadev
Copy link

roadev commented Nov 25, 2020

I changed the plugin, It was almost one year ago haha

@Ploppz
Copy link

Ploppz commented Jan 14, 2021

@matiasmenker Having this exact problem. However I just learned that in order to change the webpack config, you have to eject? Or is there a way around that?

@jilliankeenan
Copy link

jilliankeenan commented Jan 14, 2021

@Ploppz You can do a config override using react-app-rewired

I added the following code to a file called config-overrides.js in the root directory of our project. This resolved our issue.

const TerserPlugin = require('terser-webpack-plugin');

module.exports = function override(config, env) {
  config.optimization = {
    minimizer: [
      new TerserPlugin({
        terserOptions: { keep_fnames: false }, 
      }),
    ],
  };
  return config;
};

@Ploppz
Copy link

Ploppz commented Jan 14, 2021

Thansk @jilliankeenan . Did you mean keep_fnames: true? I tried either but still have the same problem though

@jilliankeenan
Copy link

Thansk @jilliankeenan . Did you mean keep_fnames: true? I tried either but still have the same problem though

ah yes keep_fnames: true - apologies copy pasta mistake. Possibly check your react-app-rewired is definitely working as that will be required for this override to work. I resolved this issue a while ago so I'm not sure if I can be of much further help. :)

@Ploppz
Copy link

Ploppz commented Jan 15, 2021

Hm, it appears in my case like keep_fnames: true does not help at all: I just ejected, and then changed config/webpack.config.js to set it. I still get the Uncaught TypeError: Super expression must either be null or a function error.

Edit: Fixed my problem; was in react-checkbox-tree: jakezatecky/react-checkbox-tree#210

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants