-
Notifications
You must be signed in to change notification settings - Fork 16
Update code to use a bundler (webpack) and the latest sway #3
base: master
Are you sure you want to change the base?
Conversation
@@ -0,0 +1,56 @@ | |||
var Sway = require('sway') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have test it in a worker environment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.