jspm / registry

The jspm registry and package.json override service
https://jspm.io
229 stars 256 forks source link

Remove @node directive from mocha #1022

Closed ghempton closed 6 years ago

ghempton commented 7 years ago

Currently, 3rd party UIs do not seem to work when using JSPM in the browser.

This is because the recommended way to build them involves require('mocha/lib/interfaces/common') which includes bringing in events and some other node modules. The overrides in the registry are causing the browser to reference node modules and everything breaks.

I assume the code deleted in the PR is there for a reason. Is there an approach to this that can allow mocha to work in both environments with a custom interface?

guybedford commented 7 years ago

I believe the only reason for this code was to ensure that Mocha didn't pull in too many dependencies on install. It was nice to keep it as a simple dependency.

Perhaps try something like:

"path": { "node": "@node/path", "browser": "path" }
"fs": { "node": "@node/fs", "browser": "fs" }
"util": { "node": "@node/util", "browser": "util" }
"events": { "node": "@node/events", "browser": "events" }
"tty": { "node": "@node/tty", "browser": "tty" }

So that it uses the browser versions without them having to be installed?

Although I must admit I'm not sure if that will work.