Closed kennknowles closed 11 years ago
It's being defined as contracts
not contracts.js
here. Are you running into problems trying to load just contracts
?
Oh! But node forces you to call it contracts.js
. Reading comprehension. Yeah, I see the problem now.
I guess renaming the npm package makes the most sense right? Maybe "contracts-js".
Yea, exactly. Works fine in each context, just not in both via the same code. I do think "contracts-js" will work.
Pushed "contracts-js" so it should work now.
Awesome, thanks!
Just took a shot at integrating this, and I'm afraid there's another snag: Coffee compiles to a named module, see https://github.com/disnet/contracts.js/blob/master/lib/contracts.js#L1566
So actually in RequireJS one must call it "contracts" but when using node+amdefine one must call it "contracts-js"
Hmm, the "paths" config may be able to sort this out; I'll try it. Unfortunately, I think the only workaround-free solution is to have the file, module, and npm package share a name.
Changed the module name, do we really need the filename to be the same?
Probably not, actually. I was imagining module systems that always base the module name on the file name, of which I thought RequireJS was one until I saw the named define in this code. Thanks! I'll try this out shortly.
I have a project that is tested both with node and with RequireJS. Unfortunately, the module name "contracts.js" for node makes RequireJS believe this is a relative import (see http://requirejs.org/docs/api.html#jsfiles) rather than an installed package.