![Maven Central Adds Sigstore Signature Validation](https://cdn.sanity.io/images/cgdhsj6q/production/7da3bc8a946cfb5df15d7fcf49767faedc72b483-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
gulp-sort-amd
Advanced tools
Sorts files in stream by dependencies defined according to AMD/requirejs spec.
Sorts files in stream by dependencies defined according to the AMD/require.js specification. Used in conjunction with gulp-concat to combine files in the correct order, so dependent files execute first when loaded.
This plugin allows you to use your modules without adding the weight of requirejs to your website. Instead, you can use a stupid simple define/require shim (found in /shim
). In order to use it though, you must name all your modules, or it can't be retrieved from the hash map. It will work with most any AMD/UMD libraries, as long as they set a global object if define.amd
is false
.
The greatest benefit of this is the ability to require modules from outside the bundle itself, thereby allowing you to split bundles up per page (or even within a single page app) and still allow modules across bundles to communicate with each other without requirejs.
This assumes you are concatenating all of your scripts into various bundles, as this method prevents dynamic loading of individual modules (which I saw as a plus since it's best to bundle anyway). But because you can access modules in one bundle from another, you can dynamically load that bundle with a single, simple XHR call. This is ideal for single page apps that have large sections of content that you only want to load if the user accesses them, which is exactly the use case I built this for.
$ npm install --save-dev gulp-sort-amd
var gulp = require('gulp');
var sortAmd = require('gulp-sort-amd');
var sourcemaps = require('gulp-sourcemaps');
var concat = require('gulp-concat');
gulp.task('default', function () {
return gulp.src('src/**/*.js')
.pipe(sortAmd())
.pipe(sourcemaps.init())
.pipe(concat('scripts.js'))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('dist'));
});
Named modules with dependencies as a parameter:
define('a', ['sub/b', '../c'], function(b, c) {
// hot sauce
});
Unnamed modules in the commonJS style:
define(function() {
var b = require('b');
var c = require('c');
});
And everything else amdetective supports.
gulp-sort-amd is MIT licensed. Feel free to use it, contribute or spread the word. Created by Corey Birnbaum. Based off of gulp-deps-order by Petr Nevyhoštěný (Twitter).
FAQs
Sorts files in stream by dependencies defined according to AMD/requirejs spec.
We found that gulp-sort-amd 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
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.