Socket
Socket
Sign inDemoInstall

gulp-rollup

Package Overview
Dependencies
Maintainers
2
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gulp-rollup - npm Package Compare versions

Comparing version 2.10.0 to 2.11.0

85

index.js

@@ -14,2 +14,36 @@ 'use strict';

function cloneWithBlacklist(obj) {
var out = {};
outer:
for (var key in obj) {
for (var i = 1; i < arguments.length; ++i) {
if (arguments[i] === key) {
continue outer;
}
}
out[key] = obj[key];
}
return out;
}
function deepEqual(a, b) {
if (typeof a !== 'object' || typeof b !== 'object') {
return a === b;
}
var key;
for (key in a) {
if (!(key in b) || !deepEqual(a[key], b[key])) {
return false;
}
}
for (key in b) {
if (!(key in a)) {
return false;
}
}
return true;
}
function GulpRollup(options) {

@@ -21,8 +55,8 @@ var self = this;

var options0 = options || {};
options = {};
for (var key in options0) {
if (key !== 'rollup' && key !== 'allowRealFiles' && key !== 'impliedExtensions') {
options[key] = options0[key];
}
}
options = cloneWithBlacklist(options0,
'rollup',
'allowRealFiles',
'impliedExtensions',
'separateCaches',
'generateUnifiedCache');

@@ -32,3 +66,9 @@ var rollup = options0.rollup || require('rollup');

var impliedExtensions = options0.impliedExtensions;
var unifiedCachedModules = options0.generateUnifiedCache && {};
var separateCaches = options0.separateCaches;
if (separateCaches) {
separateCaches = cloneWithBlacklist(separateCaches);
}
var wonderland = {}, vinylFiles = {};

@@ -90,11 +130,33 @@ var haveSourcemaps;

options.sourceMap = haveSourcemaps;
var vinylSystem = hypothetical({ files: vinylFiles, allowRealFiles: true, impliedExtensions: impliedExtensions });
var options1 = options;
entryFiles.then(function(entryFiles) {
return Promise.all(entryFiles.map(function(entryFile) {
var options = cloneWithBlacklist(options1);
options.entry = entryFile;
if (separateCaches && Object.prototype.hasOwnProperty.call(separateCaches, entryFile)) {
options.cache = separateCaches[entryFile];
}
options.sourceMap = haveSourcemaps;
return rollup.rollup(options).then(function(bundle) {
self.emit('bundle', bundle, entryFile);
return rollup.rollup(options).then(function(bundle) {
if (unifiedCachedModules) {
var modules = bundle.modules;
for (var i = 0; i < modules.length; ++i) {
var module = modules[i], id = module.id;
if (Object.prototype.hasOwnProperty.call(unifiedCachedModules, id)) {
if (!deepEqual(module, unifiedCachedModules[id])) {
throw new Error('Conflicting caches for module "' + id + '"!');
}
} else {
unifiedCachedModules[id] = module;
}
}
}
var result = bundle.generate(options);

@@ -132,2 +194,9 @@

}).then(function() {
if (unifiedCachedModules) {
var modules = [];
for (var id in unifiedCachedModules) {
modules.push(unifiedCachedModules[id]);
}
self.emit('unifiedcache', { modules: modules });
}
cb(); // it's over!

@@ -134,0 +203,0 @@ }).catch(function(err) {

2

package.json
{
"name": "gulp-rollup",
"version": "2.10.0",
"version": "2.11.0",
"description": "gulp plugin for Rollup ES6 module bundler",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -57,2 +57,4 @@ # gulp-rollup [![npm][npm-image]][npm-url] [![Dependency Status][david-image]][david-url] [![Build Status][travis-image]][travis-url]

### `options.rollup`
In addition to [the standard Rollup options](https://github.com/rollup/rollup/wiki/JavaScript-API), gulp-rollup supports `options.rollup`, allowing you to use an older, newer, or custom version of Rollup by passing in the module like so:

@@ -69,6 +71,57 @@

### `options.allowRealFiles`
If `options.allowRealFiles` is set to true, gulp-rollup will break the gulp plugin guidelines just for you and allow Rollup to read files directly from the filesystem when a file with a matching name isn't found in the gulp stream. You could use this to weasel your way out of having to use rollup-stream, but that would make you a terrible person.
### `options.impliedExtensions`
By default, gulp-rollup will mimic Rollup by adding a .js extension to imports if necessary. You can customize this behavior by setting `options.impliedExtensions` to an array of extensions, like `['.js', '.es', '.jsx']`. If `options.impliedExtensions` is set to `false` or an empty array, file extensions in imports will be treated as mandatory.
### `options.separateCaches`
If `options.separateCaches` is supplied, it should be an object with property names corresponding to entry files. For each of those entry files, `options.cache` will be overridden with the corresponding property value. This is most useful in conjunction with the `'bundle'` event:
```js
var gulp = require('gulp'),
rollup = require('gulp-rollup');
var caches = {};
gulp.task('bundle', function() {
gulp.src('./src/**/*.js')
.pipe(rollup({
entry: ['./src/main1.js', './src/main2.js'],
separateCaches: caches
}))
.on('bundle', function(bundle, name) {
caches[name] = bundle;
})
.pipe(gulp.dest('./dist'));
});
```
### `options.generateUnifiedCache`
If `options.generateUnifiedCache` is set to true, gulp-rollup will try to construct a cache representing every file imported by any entry point, to be passed into future Rollup invocations (thus obviating the need for `options.separateCaches`) and deliver it via the `'unifiedcache'` event. This should always work as long as all of the plugins you use have deterministic output. Since the internal structure of Rollup's cache objects can't be expected to remain stable, this option isn't guaranteed to work if you specify an `options.rollup`.
tl;dr: It works like this:
```js
var gulp = require('gulp'),
rollup = require('gulp-rollup');
var cache;
gulp.task('bundle', function() {
gulp.src('./src/**/*.js')
.pipe(rollup({
entry: ['./src/main1.js', './src/main2.js'],
cache: cache,
generateUnifiedCache: true
}))
.on('unifiedcache', function(unifiedCache) {
cache = unifiedCache;
})
.pipe(gulp.dest('./dist'));
});
```
[npm-url]: https://npmjs.org/package/gulp-rollup

@@ -75,0 +128,0 @@ [npm-image]: https://img.shields.io/npm/v/gulp-rollup.svg

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc