include basepath of parent filename in package.json paths

In addition to any parent paths specified, make sure to check from the
basepath of the parent path.
fix replacing by using module name in browser field

Browser field allows for the module name to be specified as a key. This
means that instances of requiring that module will cause it to be
replaced with the file specified.