Comparing version 0.0.8 to 0.1.0
/** vim: et:ts=4:sw=4:sts=4 | ||
* @license amdefine 0.0.8 Copyright (c) 2011, The Dojo Foundation All Rights Reserved. | ||
* @license amdefine 0.1.0 Copyright (c) 2011, The Dojo Foundation All Rights Reserved. | ||
* Available via the MIT or new BSD license. | ||
@@ -4,0 +4,0 @@ * see: http://github.com/jrburke/amdefine for details |
{ | ||
"name": "amdefine", | ||
"description": "Provide AMD's define() API for declaring modules in the AMD format", | ||
"version": "0.0.8", | ||
"version": "0.1.0", | ||
"homepage": "http://github.com/jrburke/amdefine", | ||
@@ -6,0 +6,0 @@ "author": "James Burke <jrburke@gmail.com> (http://github.com/jrburke)", |
@@ -13,3 +13,3 @@ # amdefine | ||
"dependencies": { | ||
"amdefine": ">=0.0.8" | ||
"amdefine": ">=0.1.0" | ||
} | ||
@@ -43,2 +43,53 @@ ``` | ||
### amdefine/intercept | ||
Consider this very experimental. | ||
Instead of pasting the piece of text for the amdefine setup of a `define` | ||
variable in each module you create or consume, you can use `amdefine/intercept` | ||
instead. It will automatically insert the above snippet in each .js file loaded | ||
by Node. | ||
**Warning**: you should only use this if you are creating an application that | ||
is consuming AMD style defined()'d modules that are distributed via npm and want | ||
to run that code in Node. | ||
For library code where you are not sure if it will be used by others in Node or | ||
in the browser, then explicitly depending on amdefine and placing the code | ||
snippet above is suggested path, instead of using `amdefine/intercept`. The | ||
intercept module affects all .js files loaded in the Node app, and it is | ||
inconsiderate to modify global state like that unless you are also controlling | ||
the top level app. | ||
#### Why distribute AMD-style nodes via npm? | ||
npm has a lot of weaknesses for front-end use (installed layout is not great, | ||
should have better support for the `baseUrl + moduleID + '.js' style of loading, | ||
single file JS installs), but some people want a JS package manager and are | ||
willing to live with those constraints. If that is you, but still want to author | ||
in AMD style modules to get dynamic require([]), better direct source usage and | ||
powerful loader plugin support in the browser, then this tool can help. | ||
#### amdefine/intercept usage | ||
Just require it in your top level app module (for example index.js, server.js): | ||
```javascript | ||
require('amdefine/intercept'); | ||
``` | ||
The module does not return a value, so no need to assign the result to a local | ||
variable. | ||
Then just require() code as you normally would with Node's require(). Any .js | ||
loaded after the intercept require will have the amdefine check injected in | ||
the .js source as it is loaded. It does not modify the source on disk, just | ||
prepends some content to the text of the module as it is loaded by Node. | ||
#### How amdefine/intercept works | ||
It overrides the `Module._extensions['.js']` in Node to automatically prepend | ||
the amdefine snippet above. So, it will affect any .js file loaded by your | ||
app. | ||
## define() usage | ||
@@ -117,2 +168,3 @@ | ||
node all.js | ||
node all-intercept.js | ||
``` | ||
@@ -119,0 +171,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20599
5
290
172
2