Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
amd-optimize
Advanced tools
Readme
This project is no longer actively maintained. Mostly, because we use Webpack in our projects now. I am happy to review incoming PRs, though. If you would like to become maintainer, please contact me. – @normanrz
An AMD (RequireJS) optimizer that's stream-friendly. Made for gulp. (WIP)
var gulp = require("gulp");
var amdOptimize = require("amd-optimize");
var concat = require('gulp-concat');
gulp.task("scripts:index", function () {
return gulp.src("src/scripts/**/*.js")
// Traces all modules and outputs them in the correct order.
.pipe(amdOptimize("main"))
.pipe(concat("index.js"))
.pipe(gulp.dest("dist/scripts"));
});
This aims to be an alternative to the powerful r.js optimizer, but made for a streaming environment like gulp. This implementation doesn't operate on the file system directly. So, there's no need for complicated setups when dealing with precompiled files. Also, this module only focuses on tracing modules and does not intend replace a full-fletched build system. Therefore, there might be tons of use cases where r.js is a better fit.
$ npm install amd-optimize
Type: String
paths : {
"backbone" : "../bower_components/backbone/backbone",
"jquery" : "../bower_components/jquery/jquery"
}
map : {
// Replace underscore with lodash for the backbone module
"backbone" : {
"underscore" : "lodash"
}
}
shim : {
// Shimmed export. Specify the variable name that is being exported.
"three" : {
exports : "THREE"
},
// Shimmed dependecies and export
"three.color" : {
deps : ["three"],
exports : "THREE.ColorConverter"
},
// Shimmed dependencies
"bootstrap" : ["jquery"]
}
Type: Stream
or String
Supply a filepath (can be a glob) or a gulp stream to your config file that lists all your paths, shims and maps.
amdOptimize.src("index", {
configFile : "src/scripts/require_config.js"
});
amdOptimize.src("index", {
configFile : gulp.src("src/scripts/require_config.coffee").pipe(coffee())
});
Type: Boolean
Default: false
If true
it will trace require()
dependencies inside of top-level require()
or define()
calls. Usually, these nested dependencies are considered dynamic or runtime calls, so it's disabled by default.
Would trace both router
and controllers/home
:
define("router", [], function () {
return {
"/home" : function () {
require(["controllers/home"]);
},
...
}
})
Type: Boolean
Default: false
If true
all files that you have declared a shim for and don't have a proper define()
call will be wrapped in a define()
call.
// Original
var test = "Test";
// Output
define("test", [], function () {
var test = "Test";
return test;
});
// Shim config
shim : {
test : {
exports : "test"
}
}
Type: Boolean
Default: false
If true
all files that you combine will not be altered from the source, should be used for outputted files to match the original source file, good for debugging and inline sourcemaps. A good code minifier or uglify will remove comments and strip new lines anyway.
WIP. Subject to change.
amdOptimize.src(
"index",
loader : amdOptimize.loader(
// Used for turning a moduleName into a filepath glob.
function (moduleName) { return "src/scripts/" + moduleName + ".coffee" },
// Returns a transform stream.
function () { return coffee(); }
)
)
Same as amdOptimize()
, but won't accept an input stream. Instead it will rely on loading the files by itself.
baseUrl
.var concat = require("gulp-concat");
gulp.src("src/scripts/**/*.js")
.pipe(amdOptimize("index"))
.pipe(concat("index.js"))
.pipe(gulp.dest("dist"));
var uglify = require("gulp-uglify");
gulp.src("src/scripts/**/*.js")
.pipe(amdOptimize("index"))
.pipe(concat("index.js"))
.pipe(uglify())
.pipe(gulp.dest("dist"));
var coffee = require("gulp-coffee");
gulp.src("src/scripts/**/*.coffee")
.pipe(coffee())
.pipe(amdOptimize("index"))
.pipe(concat("index.js"))
.pipe(gulp.dest("dist"));
var gif = require("gulp-if");
gulp.src("src/scripts/**/*.{coffee,js}")
.pipe(gif(function (file) { return path.extname(file) == ".coffee"; }, coffee()))
.pipe(amdOptimize("index"))
.pipe(concat("index.js"))
.pipe(gulp.dest("dist"));
var eventStream = require("event-stream");
var order = require("gulp-order");
eventStream.merge(
gulp.src("bower_components/almond/almond.js"),
gulp.src(amdOptimize("index"))
.pipe(concat("index.js"))
)
.pipe(order(["**/almond.js", "**/index.js"]))
.pipe(concat("index.js"))
.pipe(gulp.dest("dist"));
text
plugin.exclude
or include
configuration.npm install
npm install -g gulp
gulp test
MIT © scalable minds 2014
FAQs
An AMD (i.e. RequireJS) optimizer that's stream-friendly. Made for gulp. (WIP)
The npm package amd-optimize receives a total of 399 weekly downloads. As such, amd-optimize popularity was classified as not popular.
We found that amd-optimize demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.