async-define
Advanced tools
Comparing version 2.0.0 to 2.1.0
@@ -1,2 +0,2 @@ | ||
(function (w){ | ||
(function (w, cb){ | ||
@@ -71,3 +71,3 @@ var queue = this._async_define_queue = '_async_define_queue' in this ? this._async_define_queue : []; | ||
function asyncDefine() { | ||
function ad() { | ||
var item = { | ||
@@ -87,9 +87,12 @@ name: typeof arguments[0] === 'string' ? arguments[0] : undefined, | ||
} | ||
cb.call(w, ad); | ||
}(this, function (asyncDefine) { | ||
if (typeof exports === 'object'){ | ||
module.exports = asyncDefine; | ||
} | ||
else{ | ||
w.asyncDefine = asyncDefine; | ||
} | ||
if (typeof exports === 'object'){ | ||
module.exports = asyncDefine; | ||
} | ||
else{ | ||
w.asyncDefine = asyncDefine; | ||
} | ||
}(this)); | ||
})); | ||
{ | ||
"name": "async-define", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "Coordinate the execution of asynchronous scripts", | ||
"main": "lib/asyncDefine.js", | ||
"scripts": { | ||
"test": "mocha tests/*.js", | ||
"prepublish": "npm run build", | ||
"test": "npm run build && mocha tests/*.js", | ||
"serve": "http-server -p 9090 demo", | ||
"build": "uglifyjs templates/main.hbs -m -r asyncDefine -c -o templates/main-min.hbs && bin/async-define-bundle.js -f=templates/umd.hbs > lib/asyncDefine.js", | ||
"build:jquery": "browserify demo/jquery.js -o demo/dist/jquery.js", | ||
@@ -13,4 +15,10 @@ "build:react": "browserify demo/react.js -o demo/dist/react.js", | ||
"build:main": "browserify demo/main.js -o demo/dist/main.js", | ||
"build": "npm run build:jquery && npm run build:react && npm run build:react-dom && npm run build:main" | ||
"build:demo": "npm run build && npm run build:jquery && npm run build:react && npm run build:react-dom && npm run build:main", | ||
"release:major": "./node_modules/.bin/npm-release major", | ||
"release:minor": "./node_modules/.bin/npm-release minor", | ||
"release:patch": "./node_modules/.bin/npm-release patch" | ||
}, | ||
"bin": { | ||
"async-define-bundle": "bin/async-define-bundle.js" | ||
}, | ||
"repository": "git@github.com:tes/async-define.git", | ||
@@ -26,4 +34,10 @@ "author": "Maurizio Lupo <maurizio.lupo@gmail.com>", | ||
"react": "^0.14.3", | ||
"react-dom": "^0.14.3" | ||
"react-dom": "^0.14.3", | ||
"uglifyjs": "^2.4.10", | ||
"npm-release": "^1.0.0" | ||
}, | ||
"dependencies": { | ||
"handlebars": "^4.0.5", | ||
"minimist": "^1.2.0" | ||
} | ||
} |
@@ -143,2 +143,46 @@ asyncDefine | ||
All will be downloaded asynchronously with the maximum performances! | ||
There is also a transformer available https://github.com/tes/browserify-async-define | ||
There is also a transformer available https://github.com/tes/browserify-async-define | ||
asyncDefineBundle | ||
================= | ||
This is a command line/API available to wrap scripts into asyncDefine. Can be used as additional build steps in webpack/browserify/xyz, and allows to load bundles asynchronously. | ||
Here are the options: | ||
* -name (-n): name of this bundle (optional) | ||
* -import (-i): symbols to import (optional) | ||
* -export (-e): symbols to export (optional) | ||
* -minified (-m): use this if you want to use a minified version of async-define | ||
* -fragment (-f): (advanced) the fragment to use (default to asyncDefine wrapper) | ||
* -script (-s): the path of the script to wrap into asyncDefine | ||
Example: | ||
``` | ||
async-define-bundle.js -n bundle3 -s hello.js -i bundle1.x,bundle1.y,bundle2.z -e j | ||
``` | ||
will produce: | ||
```js | ||
// ... async define bundle | ||
asyncDefine("bundle3", ["bundle1" ,"bundle2"], function (___bundle1 ,___bundle2) { | ||
var x = ___bundle1.x; | ||
var y = ___bundle1.y; | ||
var z = ___bundle2.z; | ||
console.log('hello world'); // this is the script | ||
return { | ||
j: j, | ||
}; | ||
}); | ||
``` | ||
There is an equivalent module: | ||
```js | ||
var asyncDefineBundle = require('async-define/src/async-define-bundle'); | ||
console.log(asyncDefineBundle({ | ||
fragmentPath: fragmentPath, // (advanced) the fragment to use (default to asyncDefine wrapper) | ||
bundleName: bundleName, // name of this bundle (optional) | ||
importVar: importVar, // an object like {bundle1: ['x', 'y'], bundle2: ['z']} | ||
exportVar: exportVar, // a list of exported symbols ['j'] | ||
script: script, // the script to wrap into asyncDefine (a string) | ||
minified: minified, // use this if you want to use a minified version of async-define | ||
})); | ||
``` |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
19961
18
267
188
2
9
3
+ Addedhandlebars@^4.0.5
+ Addedminimist@^1.2.0
+ Addedhandlebars@4.7.8(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedneo-async@2.6.2(transitive)
+ Addedsource-map@0.6.1(transitive)
+ Addeduglify-js@3.19.3(transitive)
+ Addedwordwrap@1.0.0(transitive)