add createWidget function

Add a createWidget function to encourage a consistent structure for widget objects and to provide defaults for the config and jsfile arguments. Also inverts the first two arguments of getDependency so that the second (package) can be inferred from the first (lib).

Note that this PR is branched from the sizing PR so should not be taken until sizing has been merged.