Skip to content
This repository has been archived by the owner on Aug 24, 2018. It is now read-only.

Update code to use a bundler (webpack) and the latest sway #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ponelat
Copy link
Member

@ponelat ponelat commented Feb 22, 2016

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.

@@ -0,0 +1,56 @@
var Sway = require('sway')
Copy link
Collaborator

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?

Copy link
Member Author

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
...

Copy link
Collaborator

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!

Copy link
Member Author

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 😉

Copy link
Collaborator

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!

Copy link
Member Author

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 😛

@ponelat
Copy link
Member Author

ponelat commented Feb 22, 2016

So I added, the most basic of tests (no karma runner yet, but it shouldn't be hard to add).
We can add that as the part of the next step... something I need to explore is passing in options for sway... I'll be back here tomorrow 😄

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

Successfully merging this pull request may close these issues.

2 participants