knockout.viewmodel icon indicating copy to clipboard operation
knockout.viewmodel copied to clipboard

Add wrapper to use AMD or browser globals to load plugin (plus tests)

Open neverfox opened this issue 11 years ago • 11 comments

I added a wrapper based on UMD to make the plugin support AMD/RequireJS, and I created a separate AMD test suite. All tests pass. I did not bother, in light of #33, to create tests with ko.mapping. I didn't add CommonJS/Node compatibility, but that would be easy enough to add, if desired.

neverfox avatar Jun 10 '13 00:06 neverfox

This is under consideration. Off the top of my head I don't see a problem with the change needed to support this. I need to re-familiarize myself with AMD and RequireJS. I've never used them and it's been a while since I looked at them.

One thing I see as problematic is the necessity to duplicate all of the unit tests. I'm currently revising the unit tests which means I'd have to do the changes twice. And every time I add a test I'd have to add it twice. I'd like to be able to have the tests defined once and used to test both. I'll put some thought into it.

Thanks for the help.

coderenaissance avatar Jun 10 '13 21:06 coderenaissance

I'm a heavy RequireJS user so the change was admittedly self-serving, but I also thought it would make it more consistent with the support offered by Knockout's other official plugins (as well as Knockout itself), as well as fitting into frameworks like Durandal. Thank you for considering it.

I thought you might say that about the tests and I did give it some thought at the time. I made the extra set because it was a faster proof-of-concept than writing a script to automatically build the pure AMD test suite from the regular suite. However, I still think the latter is possible (e.g. someone did just that with the entire Twitter Bootstrap library). It's really nothing more than wrapping each module in the same manner and maintaining the "main" file instead of the html file. I'll put some thought too into automating the build of the AMD suite.

neverfox avatar Jun 10 '13 21:06 neverfox

Thanks.

coderenaissance avatar Jun 10 '13 21:06 coderenaissance

+1

thelinuxlich avatar Jun 14 '13 20:06 thelinuxlich

I would like to see AMD support as well, as this plugin doesn't work out of the box with Knockout and RequireJS (since Knockout then doesn't create a global ko object).

aknuds1 avatar Aug 02 '13 08:08 aknuds1

working on the next release which has some notable changes... will try to get it in this release if it's simple, if not will be small release just after... have been delaying too long on this release already. Thanks for your help.

coderenaissance avatar Aug 11 '13 20:08 coderenaissance

Yes! AMD support please (specifically RequireJS). Haven't been able to get shim config to play nice with this plug-in, so had to modify the library to make it work.

spring1975 avatar Aug 14 '13 17:08 spring1975

+1

jnicolau avatar Feb 18 '14 14:02 jnicolau

+1

bjarneheden avatar Jun 19 '14 08:06 bjarneheden

+1 for AMD support

legacycode avatar Jan 12 '15 08:01 legacycode

+1

jotunskij avatar May 07 '15 11:05 jotunskij