You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# amdefine
A module that can be used to implement AMD's define() in Node. This allows you
to code to the AMD API and have the module work in node programs without
requiring those other programs to use AMD.
## Usage**1)** Update your package.json to indicate amdefine as a dependency:
```javascript"dependencies": {
"amdefine":">=0.1.0"
}
Then run npm install to get amdefine into your project.
2) At the top of each module that uses define(), place this code:
Only use these snippets when loading amdefine. If you preserve the basic structure,
with the braces, it will be stripped out when using the RequireJS optimizer.
You can add spaces, line breaks and even require amdefine with a local path, but
keep the rest of the structure to get the stripping behavior.
As you may know, because if statements in JavaScript don't have their own scope, the var
declaration in the above snippet is made whether the if expression is truthy or not. If
RequireJS is loaded then the declaration is superfluous because define is already already
declared in the same scope in RequireJS. Fortunately JavaScript handles multiple var
declarations of the same variable in the same scope gracefully.
The text was updated successfully, but these errors were encountered:
Refs: #7945
The markdown content is:
Then run
npm install
to get amdefine into your project.2) At the top of each module that uses define(), place this code:
Only use these snippets when loading amdefine. If you preserve the basic structure,
with the braces, it will be stripped out when using the RequireJS optimizer.
You can add spaces, line breaks and even require amdefine with a local path, but
keep the rest of the structure to get the stripping behavior.
As you may know, because
if
statements in JavaScript don't have their own scope, the vardeclaration in the above snippet is made whether the
if
expression is truthy or not. IfRequireJS is loaded then the declaration is superfluous because
define
is already alreadydeclared in the same scope in RequireJS. Fortunately JavaScript handles multiple
var
declarations of the same variable in the same scope gracefully.
The text was updated successfully, but these errors were encountered: