Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert ViewModel to modern JavaScript #297

Open
arggh opened this issue Oct 10, 2017 · 16 comments
Open

Convert ViewModel to modern JavaScript #297

arggh opened this issue Oct 10, 2017 · 16 comments

Comments

@arggh
Copy link

arggh commented Oct 10, 2017

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
Copy link

juho commented Oct 10, 2017

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
Copy link

juho commented Oct 10, 2017

@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
Copy link
Owner

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
Copy link
Author

arggh commented Jan 31, 2018

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

@arggh
Copy link
Author

arggh commented Mar 31, 2018

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
Copy link
Owner

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
Copy link
Author

arggh commented Jun 4, 2018

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
Copy link
Owner

ManuelDeLeon commented Jun 4, 2018 via email

@arggh
Copy link
Author

arggh commented Jun 4, 2018

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
Copy link
Owner

ManuelDeLeon commented Jun 4, 2018 via email

@arggh
Copy link
Author

arggh commented Jun 4, 2018

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
Copy link
Owner

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
Copy link
Author

arggh commented Jun 6, 2018

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
Copy link
Author

arggh commented Jun 6, 2018

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
~/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(
    [
      "[email protected]_4",
      "[email protected]",
      "[email protected]",
      "[email protected]",
      "[email protected]_2",
      "[email protected]",
      "[email protected]",
      "[email protected]",
      "[email protected]",
      "[email protected]",
      "manuel:[email protected]",
      "manuel:[email protected]",
      "manuel:[email protected]"
    ],
    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
Copy link
Owner

Cool. It works for me now =)

@arggh
Copy link
Author

arggh commented Nov 3, 2018

I'll give it another try then.

I haven't given up on you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants