Closed alanclarke closed 8 years ago
or is there another way of achieving the same
May not be the case.
Please provide a bit more context for your case.
For example, ideally if we put a browser field in https://github.com/nikku/karma-browserify/blob/master/example/package.json
like so:
"main": "lib/a.js",
"browser": { "./lib/a.js": "./lib/b.js" }
i would expect any code running in karma that does require('./lib/a.js') to actually be given module b, and for browserify to only bundle module b
This is useful when creating isomorphic modules. In our case we are creating on a cross platform logger, in the browser we want to use some apis available to chrome but that would error in node, (e.g. window.console), whereas in node we might bundle chalk and other things which are not meant for the browser
Ah so actually this does work beautifully, but for reference my issue is that when using this feature need to be careful with the order in which things are loaded and to not specify the replaced file in karma config files array
Should karma-browserify respect the browser field in a modules' package.json, as per https://github.com/substack/browserify-handbook#browser-field?