ManuelDeLeon / viewmodel

MVVM for Meteor
https://viewmodel.org
MIT License
205 stars 23 forks source link

Convert ViewModel to modern JavaScript #297

Open arggh opened 7 years ago

arggh commented 7 years ago

Would be awesome, if ViewModel was just JavaScript instead of CoffeeScript.

Depending on the targeted browsers, this might even have nice performance benefits in both execution and weight.

The most important benefit would be more contributors and increased confidence on using the library (it's just JavaScript vs. I need to learn CoffeeScript to fix this simple bug).

I already tried to achieve this using Decaffeinate and Prettier, but gave up for now.

juho commented 7 years ago

We can offer a small bounty of say $200 for this for anyone who wants to tackle this and performance improvements. Goal would be to have a drop-in replacement that performs better than the current version, but priority is in performance improvements first. We have a complex app that is mostly on Blaze VM that can be used as a test bed.

juho commented 7 years ago

@ManuelDeLeon We're also fine tossing some cash your way if you want to take a weekend to look at any performance improvements you can think of for the current version. I know Blaze VM isn't your priority right now, but it would be really helpful for us in the coming months - we might transition over to React as well next year but getting stuff to perform better for now is also a nice thing. :)

ManuelDeLeon commented 7 years ago

I'll create a new GitHub repo for ViewModel projects and put in the effort of making it easier for people to contribute. That means converting VM-Blaze to JS and make tests for VM-React accessible to anyone. Part of the work would involve creating detailed instructions on how to download, modify, and test the project, submit a PR, etc. I don't use VM-Blaze anymore so I don't have the motivation to work on it (sorry, it's sad but true) but I can definitely help and guide anyone who wants to contribute to it.

Right now I'm in the process of rewriting VM-React with performance in mind. See this thread for more info.

As for money, Once I get the ball rolling with the contributor friendly setup, I'll probably use CodeSponsor or maybe even Patreon.

arggh commented 6 years ago

Hey @ManuelDeLeon, any updates on getting the ball rolling with this one? Is there something you could use help with?

arggh commented 6 years ago

I'm soon trying to find the time to study the codebase, convert ViewModel from CoffeeScript to JavaScript and get started with fixing the bugs. @ManuelDeLeon , if you had any work done on this conversion, please do share as it would make life a lot easier :)

ManuelDeLeon commented 6 years ago

Check out the react version for inspiration since it's done in JS and many cases you'll be able to find the methods or functionality of one in the other.

https://github.com/ManuelDeLeon/viewmodel-react

arggh commented 6 years ago

I noticed ReactiveArray recently lost some weight in the form of coffeescript dependency, are you by any chance planning on still giving ViewModel the same treatment?

ManuelDeLeon commented 6 years ago

Not really. With the Coffeescript changes I don't even know how to run the tests anymore (I used mocha).

On Mon, Jun 4, 2018, 12:10 AM arggh notifications@github.com wrote:

I noticed ReactiveArray recently lost some weight in the form of coffeescript dependency, are you by any chance planning on still giving ViewModel the same treatment?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ManuelDeLeon/viewmodel/issues/297#issuecomment-394244391, or mute the thread https://github.com/notifications/unsubscribe-auth/AED31kpYqt9P40ZJwZaQbJ0pNKqzLNuSks5t5M9DgaJpZM4PzbaG .

arggh commented 6 years ago

I believe diaconutheodor, whom was just speaking at Meteor night, has published a compatible version at https://github.com/cult-of-coders/meteor-mocha. At least I got ViewModel tests running with that.

ManuelDeLeon commented 6 years ago

I'll give it another try then.

On Mon, Jun 4, 2018, 1:48 AM arggh notifications@github.com wrote:

I believe diaconutheodor, whom was just speaking at Meteor night, has published a compatible version at https://github.com/cult-of-coders/meteor-mocha. At least I got ViewModel tests running with that.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ManuelDeLeon/viewmodel/issues/297#issuecomment-394264599, or mute the thread https://github.com/notifications/unsubscribe-auth/AED31oK3mciwcavwPg7uVTe-AvIJxnoPks5t5OZpgaJpZM4PzbaG .

arggh commented 6 years ago

I was trying to convert ViewModel to JS myself, but it turned out to be a bit more difficult than I expected, since I don't really know Coffeescript and I certainly don't know ViewModel and Blaze.

So I've been (not so) secretly wishing that you would find it worthy of your time to finish the goal stated earlier in this issue, and my hope for that to happen got some spark when I noticed ReactiveArray was now JS :)

ManuelDeLeon commented 6 years ago

Can you make a repo that's able to run the viewmodel tests? I keep getting coffeescript errors even with cult-of-coders' mocha =(

arggh commented 6 years ago

I just checked out a fresh copy of ViewModel, changed package.js to switch the mocha-library like so:

Package.onTest(function(api) {
  api.use(
    [
      "coffeescript",
      "ecmascript",
      "blaze",
      "templating",
      "jquery",
      "underscore",
      "tracker",
      "reload",
      "sha",
      "reactive-dict",
      "manuel:reactivearray",
      "cultofcoders:mocha",
      "practicalmeteor:sinon",
      "practicalmeteor:chai",
      "manuel:isdev"
    ],
    CLIENT
  );

and...

$ ~/Development/viewmodel$ meteor test-packages ./ --driver-package cultofcoders:mocha --port 4000
[[[[[ Tests ]]]]]                             

=> Started proxy.                             
=> Started your app.                          

=> App running at: http://localhost:4000/
I20180606-20:13:31.747(3)? MochaRunner.runServerTests: Starting server side tests with run id knRYRTjMh9ygKMo5v
W20180606-20:13:31.845(3)? (STDERR) MochaRunner.runServerTests: failures: 0

test

arggh commented 6 years ago

I didn't remember I had switched to a commit somewhere around 6.3.3, but it also seems to work with 6.3.7.

Running tests with 6.3.7 ```bash ~/Development/viewmodel$ cat package.js; meteor test-packages ./ --driver-package cultofcoders:mocha --port 4000 Package.describe({ name: "manuel:viewmodel", summary: "MVVM, two-way data binding, and components for Meteor. Similar to Angular and Knockout.", version: "6.3.7", git: "https://github.com/ManuelDeLeon/viewmodel" }); var CLIENT = "client"; Package.onUse(function(api) { api.use( [ "coffeescript@2.0.3_4", "ecmascript@0.1.6", "blaze@2.1.2", "templating@1.1.1", "jquery@1.11.3_2", "underscore@1.0.3", "tracker@1.0.7", "reload@1.1.3", "sha@1.0.3", "reactive-dict@1.1.0", "manuel:isdev@1.0.0", "manuel:reactivearray@1.0.9", "manuel:viewmodel-debug@2.7.2" ], CLIENT ); api.addFiles( [ "lib/viewmodel.coffee", "lib/viewmodel-parseBind.coffee", "lib/bindings.coffee", "lib/template.coffee", "lib/migration.coffee", "lib/viewmodel-onUrl.coffee", "lib/viewmodel-property.js", "lib/lzstring.js" ], CLIENT ); api.export(["ViewModel"], CLIENT); }); Package.onTest(function(api) { api.use( [ "coffeescript", "ecmascript", "blaze", "templating", "jquery", "underscore", "tracker", "reload", "sha", "reactive-dict", "cultofcoders:mocha", "practicalmeteor:sinon", "practicalmeteor:chai", "manuel:reactivearray", "manuel:isdev" ], CLIENT ); api.addFiles( [ "lib/viewmodel.coffee", "lib/viewmodel-parseBind.coffee", "lib/viewmodel-property.js", "lib/bindings.coffee", "lib/template.coffee", "lib/migration.coffee", "tests/jquery-patch.js", "tests/sinon-restore.js", "tests/bindings.coffee", "tests/viewmodel.coffee", "tests/viewmodel-instance.coffee", "tests/viewmodel-check.coffee", "tests/viewmodel-parseBind.coffee", "tests/viewmodel-property.coffee", "tests/template.coffee" ], CLIENT ); api.export(["ViewModel"], CLIENT); }); [[[[[ Tests ]]]]] => Started proxy. => Started your app. => App running at: http://localhost:4000/ I20180606-20:33:47.597(3)? MochaRunner.runServerTests: Starting server side tests with run id 2ZfcryYMCKYerxWt7 W20180606-20:33:47.706(3)? (STDERR) MochaRunner.runServerTests: failures: 0 ```
ManuelDeLeon commented 6 years ago

Cool. It works for me now =)

arggh commented 6 years ago

I'll give it another try then.

I haven't given up on you!