Better common.js support #96

Closed
3rd-Eden opened this Issue Dec 17, 2012 · 1 comment

Comments

Projects
None yet
2 participants
Owner

3rd-Eden commented Dec 17, 2012

Currently we do a common.js check that includes testing the existence of module.exports but this property is node specific and does follow the common.js modules specification.

This prevents common.js compliant environments such as Wakanda to use plates. An easy fix would be changing:

var Plates = (typeof module !== 'undefined' && typeof module.exports !== 'undefined' && typeof exports !== 'undefined') ? exports : {};

In to:

var Plates = (typeof module !== 'undefined' && typeof module.id !== 'undefined' && typeof exports !== 'undefined') ? exports : {};

The change here is to check against module.id instead of module.exports. The module.id is required by the common.js specification and exists in Node.js and other common.js environments.

edit Testing against a require.paths would not work either, as support for that has been removed in the current node versions.

Just tested you modification in Wakanda and it is working !
Thank you very much !

3rd-Eden closed this in 0d1638e Dec 17, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment