phetsims / sherpa

Third-party libraries and dependencies for PhET Simulations
http://scenerystack.org/
Other
7 stars 8 forks source link

upgrade lodash #58

Closed pixelzoom closed 7 years ago

pixelzoom commented 9 years ago

lodash doc indicates that some functions have been renamed. Eg contains -> includes. Rather than continuing to use the old functions, we should probably upgrade. As of this writing, lodash latest is 3.10.1, PhET is using 2.4.1.

Various useful links:

Project page: https://lodash.com GitHub: https://github.com/lodash/lodash Changelog: https://github.com/lodash/lodash/wiki/Changelog CDN: https://www.jsdelivr.com/projects/lodash API doc: https://lodash.com/docs

samreid commented 7 years ago

This doc shows what to use instead:

https://github.com/lodash/lodash/wiki/Changelog

samreid commented 7 years ago

Replacing with aliases got a few more to pass:

image

samreid commented 7 years ago

I am down to these 4 errors:

image

molarity Uncaught Error: Assertion failed: undefined Error: Assertion failed: undefined at window.assertions.assertFunction (http://localhost/assert/js/assert.js:21:13) at Array. (http://localhost/molarity/js/molarity/view/PrecipitateNode.js?bust=1486156933030:66:17) at Emitter.emit2 (http://localhost/axon/js/Emitter.js?bust=1486156933030:147:49) at DerivedProperty._notifyObservers (http://localhost/axon/js/Property.js?bust=1486156933030:176:29) at DerivedProperty._setAndNotifyObservers (http://localhost/axon/js/Property.js?bust=1486156933030:165:14) at DerivedProperty.set (http://localhost/axon/js/Property.js?bust=1486156933030:133:16) at Array.listener (http://localhost/axon/js/DerivedProperty.js?bust=1486156933030:78:34) at Emitter.emit2 (http://localhost/axon/js/Emitter.js?bust=1486156933030:147:49) at Property._notifyObservers (http://localhost/axon/js/Property.js?bust=1486156933030:176:29) at Property._setAndNotifyObservers (http://localhost/axon/js/Property.js?bust=1486156933030:165:14) at Property.set (http://localhost/axon/js/Property.js?bust=1486156933030:133:16) neuron Uncaught TypeError: Cannot read property 'tick' of undefined TypeError: Cannot read property 'tick' of undefined at http://localhost/neuron/js/neuron/model/NeuronClockModelAdapter.js?bust=1486156935986:139:56 at E (http://localhost/sherpa/lib/lodash-4.17.4.min.js?bust=1486156935986:9:160) at Function.On.times (http://localhost/sherpa/lib/lodash-4.17.4.min.js?bust=1486156935986:124:71) at NeuronClockModelAdapter.stepClockWhilePaused (http://localhost/neuron/js/neuron/model/NeuronClockModelAdapter.js?bust=1486156935986:139:9) at listener (http://localhost/neuron/js/neuron/view/NeuronScreenView.js?bust=1486156935986:219:54) at http://localhost/sun/js/buttons/PushButtonModel.js?bust=1486156935986:139:9 at Array.forEach (native) at PushButtonModel.fire (http://localhost/sun/js/buttons/PushButtonModel.js?bust=1486156935986:138:12) at CallbackTimer.fire (http://localhost/sun/js/CallbackTimer.js?bust=1486156935986:119:27) at CallbackTimer.stop (http://localhost/sun/js/CallbackTimer.js?bust=1486156935986:91:16) reactants-products-and-leftovers Uncaught TypeError: Cannot read property 'height' of undefined TypeError: Cannot read property 'height' of undefined at new QuantitiesNode (http://localhost/reactants-products-and-leftovers/js/common/view/QuantitiesNode.js?bust=1486156938484:216:89) at new BeforeAfterNode (http://localhost/reactants-products-and-leftovers/js/common/view/BeforeAfterNode.js?bust=1486156938484:93:27) at http://localhost/reactants-products-and-leftovers/js/sandwiches/view/SandwichesView.js?bust=1486156938484:55:16 at http://localhost/reactants-products-and-leftovers/js/common/view/RPALScreenView.js?bust=1486156938484:72:31 at Property.link (http://localhost/axon/js/Property.js?bust=1486156938484:218:11) at SandwichesView.RPALScreenView [as constructor] (http://localhost/reactants-products-and-leftovers/js/common/view/RPALScreenView.js?bust=1486156938484:67:28) at new SandwichesView (http://localhost/reactants-products-and-leftovers/js/sandwiches/view/SandwichesView.js?bust=1486156938484:36:20) at SandwichesScreen.createView (http://localhost/reactants-products-and-leftovers/js/sandwiches/SandwichesScreen.js?bust=1486156938484:42:34) at SandwichesScreen.initializeView (http://localhost/joist/js/Screen.js?bust=1486156938484:193:25) at Array. (http://localhost/joist/js/Sim.js?bust=1486156938484:610:18)

Uncaught TypeError: Cannot read property 'show' of undefined TypeError: Cannot read property 'show' of undefined at listener (http://localhost/gene-expression-essentials/build/gene-expression-essentials_en.html?ea&audioVolume=0&testDuration=10000&testConcurrentBuilds=4&fuzzMouse&brand=phet&testSims=gene-expression-essentials,molarity,neuron,reactants-products-and-leftovers&postMessageOnLoad&postMessageOnError:960:22090) at http://localhost/gene-expression-essentials/build/gene-expression-essentials_en.html?ea&audioVolume=0&testDuration=10000&testConcurrentBuilds=4&fuzzMouse&brand=phet&testSims=gene-expression-essentials,molarity,neuron,reactants-products-and-leftovers&postMessageOnLoad&postMessageOnError:950:27423 at Array.forEach (native) at e.fire (http://localhost/gene-expression-essentials/build/gene-expression-essentials_en.html?ea&audioVolume=0&testDuration=10000&testConcurrentBuilds=4&fuzzMouse&brand=phet&testSims=gene-expression-essentials,molarity,neuron,reactants-products-and-leftovers&postMessageOnLoad&postMessageOnError:950:27403) at Array. (http://localhost/gene-expression-essentials/build/gene-expression-essentials_en.html?ea&audioVolume=0&testDuration=10000&testConcurrentBuilds=4&fuzzMouse&brand=phet&testSims=gene-expression-essentials,molarity,neuron,reactants-products-and-leftovers&postMessageOnLoad&postMessageOnError:950:26764) at emit2 (http://localhost/gene-expression-essentials/build/gene-expression-essentials_en.html?ea&audioVolume=0&testDuration=10000&testConcurrentBuilds=4&fuzzMouse&brand=phet&testSims=gene-expression-essentials,molarity,neuron,reactants-products-and-leftovers&postMessageOnLoad&postMessageOnError:931:30086) at e._notifyObservers (http://localhost/gene-expression-essentials/build/gene-expression-essentials_en.html?ea&audioVolume=0&testDuration=10000&testConcurrentBuilds=4&fuzzMouse&brand=phet&testSims=gene-expression-essentials,molarity,neuron,reactants-products-and-leftovers&postMessageOnLoad&postMessageOnError:932:1463) at e._setAndNotifyObservers (http://localhost/gene-expression-essentials/build/gene-expression-essentials_en.html?ea&audioVolume=0&testDuration=10000&testConcurrentBuilds=4&fuzzMouse&brand=phet&testSims=gene-expression-essentials,molarity,neuron,reactants-products-and-leftovers&postMessageOnLoad&postMessageOnError:932:1326) at e.set (http://localhost/gene-expression-essentials/build/gene-expression-essentials_en.html?ea&audioVolume=0&testDuration=10000&testConcurrentBuilds=4&fuzzMouse&brand=phet&testSims=gene-expression-essentials,molarity,neuron,reactants-products-and-leftovers&postMessageOnLoad&postMessageOnError:932:1067) at Object.up (http://localhost/gene-expression-essentials/build/gene-expression-essentials_en.html?ea&audioVolume=0&testDuration=10000&testConcurrentBuilds=4&fuzzMouse&brand=phet&testSims=gene-expression-essentials,molarity,neuron,reactants-products-and-leftovers&postMessageOnLoad&postMessageOnError:952:312)

They do not seem related to lodash, but I will take a closer look.

samreid commented 7 years ago

Also note: this URL has a list of 4.0.0 compatibility warnings: https://github.com/lodash/lodash/wiki/Changelog

samreid commented 7 years ago

I just saw this note in CLB:

  // Would prefer to use _.minBy, but not available in lodash 2.4.1
  var leftMost = _.first( _.sortBy( this.connections, [ function( connection ) {
    return connection.location.x;
  } ] ) );
samreid commented 7 years ago

Thanks to @pixelzoom for helping me see that min and max are broken. I replaced all multi-arg max and min with maxBy and minBy. Now tests are like this:

image

samreid commented 7 years ago

_.times no longer takes 3rd argument

samreid commented 7 years ago

Neuron is good after fixing _.times

samreid commented 7 years ago

RPAL was failing because maxBy() now returns undefined for an empty array.

samreid commented 7 years ago

Current status:

image

samreid commented 7 years ago

A follow-up on the fails didn't seem so bad.

image

samreid commented 7 years ago

Automated fuzz tests are passing. Next steps:

  1. commit my working copy changes to master. This will be a big commit on many repos.
  2. alert each developer to keep an eye out for problems related to the lodash upgrade
  3. make sure QA thoroughly tests new sims out of master which are using the new lodash.
samreid commented 7 years ago

Scenery unit tests (compiled and requirejs) are also OK.

samreid commented 7 years ago

What to do for perennial? What lodash does it use?

samreid commented 7 years ago

package.json says perennial is using 3.10.1 so I'm going to leave it alone.

samreid commented 7 years ago

There is no way to be 100% certain that everything is good-to-go here, and it would be too inefficient to create branches for 60 repos. So I'm going to push what I have an we can continue in master.

pixelzoom commented 7 years ago

package.json says perennial is using 3.10.1 so I'm going to leave it alone.

perennial should probably not be using lodash.

samreid commented 7 years ago

We'll also need to update third-party-licenses.md.

samreid commented 7 years ago

OK brace yourselves.

samreid commented 7 years ago

I pulled before starting, but now I am merging in these repos:

image

samreid commented 7 years ago

Merges automerged.

samreid commented 7 years ago

[2/3/17, 4:01:55 PM] Sam Reid: When you pull, you will be using new lodash. Be alert for trouble!

samreid commented 7 years ago

I emailed the developer list:

In https://github.com/phetsims/sherpa/issues/58 we updated to the latest version of lodash in master. The automated tests are passing, but some of the lodash breaking changes are devious and you should be on the lookout for trouble in your simulations. Also, QA should be on the alert for testing new sims from master in case they are experiencing problems related to the lodash upgrade. Perennial remains at a previous lodash as specified in its package.json.

Best Regards, Sam

samreid commented 7 years ago

Everything seems to be going OK with the new lodash, new issues can be opened elsewhere. Closing.