Widdershin / tricycle

Try Cycle.js in your browser, no setup required.
http://widdersh.in/tricycle/
MIT License
26 stars 4 forks source link

Allow importing other drivers #8

Open Widdershin opened 8 years ago

Widdershin commented 8 years ago

All of the drivers under the @cycle namespace.

Frikki commented 8 years ago

Would it be possible to use ES2015 import statements instead of require? The motivation is to be able to test in tricycle and copy paste to development source code that often uses import.

Widdershin commented 8 years ago

Yep, currently can't do it because all of the user code gets wrapped in a try catch, and imports have to be at top level.

After we move to handling errors with Rx's error operators, using import becomes feasible.

Widdershin commented 8 years ago

So it actually might be possible to support importing any npm module using http://brcdn.org/

Frikki commented 8 years ago

Does this also work with scoped packages?

Widdershin commented 8 years ago

Looks like no, not yet!

https://github.com/jfhbrook/wzrd.in/issues/104

Widdershin commented 8 years ago

That wzrd.in issue is fixed now so we can take a crack at this again.

schempy commented 8 years ago

I'd like to give this a try if nobody is working on it.

Is the idea to provide a custom require function in the context object that will be used in vm.runInNewContext? The custom require function will grab the browserified module from http://wzrd.in

Thanks!

Widdershin commented 8 years ago

Great! I've added you as a collaborator and I'll assign this issue to you once you accept.

The require approach sounds promising although the asynchronous nature of getting something from wzrd.in might make it more complicated. Have a go and see how it goes :)

geovanisouza92 commented 8 years ago

Could we include https://www.npmjs.com/package/detect-import-require allowing to require any module as well?

geovanisouza92 commented 8 years ago

Indeed, by the asynchronous nature of wzrd.in, I think that this custom require function should keep some cache, and the vm.runInNewContext step should occur after all modules be downloaded and cached.

Any thoughts?