define v1.0.1
DefineJS
DefineJS is an Asynchronous Module Definition wrapper for Node. Writing modules in AMD style is convenient when code is shared between Node and a browser. The client needs to use an AMD loader like RequireJS.
Installation
Add a "define": "1.0"
dependency to your project's package.json
and run npm install
, or use npm install define
to install
manually.
How To Use
In your app's main script, require('define')
. This will add define
as a global
so it's available everywhere else in the application
automatically. See examples/shared-code
for a working example web
server.
DefineJS is Global
DefineJS installs define
as a global when it's loaded. The makes
define
available everywhere else in the application without any
special workarounds in each file.
If you don't want a global definition, do the following in your app's main script:
require('define').noConflict();
then, for individual modules that need define
:
if (typeof define === 'undefined') {
var define = require('define');
}
However, if you prefer this approach and you're using RequireJS for the client-side loader anyway, you should probably just use the similar amdefine convention because the RequireJS optimizer strips it away.
See Also
Refer to the AMD Wiki for more information about AMD.
11 years ago
12 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago
13 years ago