Semantic-ui-react: Cannot read property call of undefined

Created on 17 Apr 2018  路  6Comments  路  Source: Semantic-Org/Semantic-UI-React

I keep getting this error whenever I build with webpack. It's not saying n console from where it comes from (anonymous).

triage

All 6 comments

This is not a SUIR bug. I'd suggest searching the web for Webpack error messages. Also, check the stack trace for the error and see exactly where it is coming from. Best of luck!

For those debugging this, I'm also having this issue when upgrading to .80 when using Next.js

Try to clear browser history, cookies, everything and restart...it fixed mine.

Having the same issue, it looks like there is some tree shaking problem, maybe caused by the "sideEffects": false in semantic-UI-React.

Did anyone found a way aroun this problem?

@mhgamework

Are you using webpack v4?

If so, the issue might come from Semantic-UI-React trying to import files from ./node_modules/semantic-ui-react/dist/es/lib/, which does not seem to be bundled.

You can see this if you enable

optimization: {
    namedModules: true,
    namedChunks: true
}

I guess you are correct in your assessment that the way this lib is currently bundled does not work with webpack 4 tree-shaking correctly.

Here's a work-around that made it work for me, by manually includig lib files:

// webpack.config.js entry 
entry: {
    vendor: [
        // lots of other vendor libs
            'semantic-ui-react',
    ].concat(
        glob.sync('./node_modules/semantic-ui-react/dist/es/lib/**.js'),
    ),
},

...according to the information I found here.

The important part is the wildcard glob inclusion of semantic-ui-react's lib files. Ofcourse, depending on internal folder structures like this is less than ideal, but it's the only way I could make this work.

@levithomason would you consider this being an issue with how SUIR is bundled? It could very well be a user issue, but I have used countless of npm packages and never encountered this problem before.

We are experiencing the same issue in webpack 4 (issue starting to occurr in webpack 4.3.0 - in webpack 4.2.0 it still works) but the fix from @GGAlanSmithee did not solve it for us. Does anyone know another possible solution?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

devsli picture devsli  路  3Comments

KevinGorjan picture KevinGorjan  路  3Comments

dilizarov picture dilizarov  路  3Comments

Ctesias picture Ctesias  路  3Comments

keeslinp picture keeslinp  路  3Comments