max-mapper / yo-yo

A tiny library for building modular UI components using DOM diffing and ES6 tagged template literals
1.33k stars 65 forks source link

Morphdom is not a function #75

Open isabellachen opened 5 years ago

isabellachen commented 5 years ago

When I try to run a function that calls yo.update I get an uncaught TypeError, morphdom is not a function

I have the latest version of yo-yo: 1.4.1

isabellachen commented 5 years ago

When changed the code in yo-yo's index.js file (ln 14) from morphdom(fromNode, toNode, opts) to morphdom.default(fromNode, toNode, opts) and it works for me now. But this is obviously not the way to do it. I checked and I also have the lastest version of morphdom morphdom@2.5.6 installed in my node_modules.

max-mapper commented 5 years ago

@isabellachen Sounds like you might need to downgrade to an older version of morphdom since they broke something... maybe try version 2.1.0. Or if you need the latest version then your hack would work okay I think

jonathanlb commented 4 years ago

@isabellachen , did you fix your problem? I think I had the same one, which stemmed from some unplanned upgrades in my webpack/babel stack. As best I can tell, there's some disagreement around backwards compatibility/slop of default exports in webpack.

To get yo-yo working after my upgrades, I added to my package.json the dependency @babel/runtime ^7.8.3 and devDependencies

I also prefixed my webpack config entry value with ['babel-polyfill', .... and installed babel-loader in my webpack.config.js rules

   {
       test: /\.js$/,
       loader: 'babel-loader',
       query: {
           presets: [['@babel/env', { modules: 'commonjs' }]],
           plugins: ['add-module-exports']
       }
   }
isabellachen commented 4 years ago

@jonathanlb Thanks for the solution. We actually copied the entire library into our own files an used it this way for awhile before running into other troubles and giving in to using React :/