Update code to use a bundler (webpack) and the latest sway#3
Update code to use a bundler (webpack) and the latest sway#3
Conversation
| @@ -0,0 +1,56 @@ | |||
| var Sway = require('sway') | |||
There was a problem hiding this comment.
Have test it in a worker environment?
There was a problem hiding this comment.
Yeah, I tested it with swagger-editor (does that count?)
webpack has a UMD-like check for Worker environments, something like...
if(typeof window !== 'undefined'){
...
else if (typeof self !== 'undefined') { // Web Worker
...There was a problem hiding this comment.
nice! If it's bringing in entire dependency tree into this file then it should work. This was something I wanted to do for while but never had time. Thanks!
There was a problem hiding this comment.
yeah, webpack is pretty awesome.. the only hiccup was that I needed to add 'json' as a type.
so that require('something.json') works as expected (from somewhere in sway)
I'm going to add an test.html file that tests some very basic functionality of sway, but via a Web Worker, then perhaps you'd consider a merge 😉
There was a problem hiding this comment.
oh if you add karma test runner and two simple test (happy path and errors) it would be golden!
There was a problem hiding this comment.
might not have time for karma (tonight)... but we'll get there 😛
|
So I added, the most basic of tests (no karma runner yet, but it shouldn't be hard to add). |
So the code here uses webpack to bundle sway with the worker code.
@saharj would you mind a review? I've verified it works locally with a version of
swagger-editor, but the way I did (symlinks) doesn't strike me as foolproof.