disnet / contracts.js

Contract library for JavaScript
http://www.contractsjs.org
MIT License
149 stars 8 forks source link

Provide noop version of library w/out Harmony dependencies #15

Closed kennknowles closed 11 years ago

kennknowles commented 11 years ago

In Contracts.coffee, it is easy to omit all contracts from the resulting Javascript by removing the --contracts flag in the build process.

In Javascript, I am not certain of the best way to do this. In particular, I can only have contracts enabled during testing, since they require e.g. Chrome to have experimental flags enabled.

In the browser, I include contracts.js via this RequireJS configuration excerpt:

  packages: [{ name: 'contracts-js', main: 'contracts.js', location: 'path/to/contracts-js/lib' }]

In a finished app, this could be replaced by

  packages: [{ name: 'contracts-js', main: 'noop.js', location: 'path/to/contracts-js/lib' }]

Does this make sense? I'm obviously probably capable of forking & creating this myself, but was unsure of the relationship between Contracts.coffee and contracts.js and whether one repo or the other might be the place to do it, etc.

Thoughts?

kennknowles commented 11 years ago

Alternatively, if contracts.enabled(false) were able to prevent references to WeakMap and proxies I believe this would be solved.

disnet commented 11 years ago

Feature detecting the harmony objects. Should work now.