ctrlplusb / react-universally

A starter kit for universal react applications.
MIT License
1.7k stars 244 forks source link

error with vendor DLL if I use classnames #491

Closed mschipperheyn closed 7 years ago

mschipperheyn commented 7 years ago

If I use classnames inside my vendor config, I get a fatal error. Could it be that the vendor dll array is sorted by name and that classnames is loaded before React?

   devVendorDLL: {
    // Enabled?
    enabled: true,

    // Specify any dependencies that you would like to include in the
    // Vendor DLL.
    //
    // NOTE: It is also possible that some modules require specific
    // webpack loaders in order to be processed (e.g. CSS/SASS etc).
    // For these cases you don't want to include them in the Vendor DLL.
    include: [
      'react-async-component',
      'react',
      'react-dom',
      'react-helmet',
      'react-router-dom',
      'classnames',
      'redux',
      'react-redux',
      'redux-form',
      'redux-thunk',
    ],
strues commented 7 years ago

Hi @mschipperheyn, the order by which the dependencies are included in the vendors array does not matter. Webpack references DLLs and accesses the vendor files based on that.

For example, here's classnames:

"./node_modules/classnames/index.js": { "id": 104, "meta": {} },

Here's a portion from react router:

    "./node_modules/react-router-dom/es/Router.js": {
      "id": 241,
      "meta": { "harmonyModule": true },
      "exports": ["default"]
    },

It's essentially a reference to the location of the file as well as information regarding the export.

I use classnames in most of my projects and never encountered this. For the sake of being thorough, I pulled down a fresh master, and installed classnames. I wasn't able to reproduce.

Try this... I'm not sure if you're using yarn or npm, but delete the yarn.lock or package-lock.json for the package manager you arent using. Afterwards, run npm install or yarn again. See if this corrects the problem for you.