gulp-rollup
Advanced tools
Comparing version 2.2.0 to 2.3.0
74
index.js
@@ -18,7 +18,17 @@ 'use strict'; | ||
options = options || {}; | ||
var options0 = options || {}; | ||
options = {}; | ||
for (var key in options0) { | ||
if (key !== 'rollup' && key !== 'allowRealFiles' && key !== 'impliedExtensions') { | ||
options[key] = options0[key]; | ||
} | ||
} | ||
var wonderland = {}; | ||
var entries = [], haveSourcemaps; | ||
var rollup = options0.rollup || require('rollup'); | ||
var allowRealFiles = options0.allowRealFiles; | ||
var impliedExtensions = options0.impliedExtensions; | ||
var wonderland = {}, vinylFiles = {}; | ||
var haveSourcemaps; | ||
var entryFiles = Promise.resolve(options.entry).then(function(entryFiles) { | ||
@@ -60,17 +70,4 @@ if (typeof entryFiles === 'string') { | ||
} | ||
vinylFiles[file.path] = file; | ||
// taking advantage of hypothetical's state-of-the-art resolving capabilities. | ||
var onederland = {}; // ohoho, funny pun. I laugh. | ||
onederland[file.path] = ''; | ||
var finder = hypothetical({ files: onederland, allowRealFiles: true }); | ||
// now let's see if this is an entry file. | ||
entryFiles = entryFiles.then(function(entryFiles) { | ||
entryFiles.forEach(function(entryFile, i) { | ||
if (finder.resolveId(entryFile)) { | ||
entries[i] = file; | ||
} | ||
}); | ||
return entryFiles; | ||
}); | ||
cb(); | ||
@@ -80,34 +77,27 @@ }; | ||
self._flush = function(cb) { | ||
entryFiles.then(function(entryFiles) { | ||
var rollup = options.rollup || require('rollup'); | ||
if (!options.plugins) { | ||
options.plugins = []; | ||
} else if (!Array.isArray(options.plugins)) { | ||
options.plugins = [options.plugins]; | ||
} | ||
options.plugins = options.plugins.concat(hypothetical({ | ||
files: wonderland, | ||
allowRealFiles: allowRealFiles, | ||
impliedExtensions: impliedExtensions | ||
})); | ||
return Promise.all(entryFiles.map(function(entryFile, i) { | ||
// don't tamper with the original options. copy them over instead. | ||
var adjustedOptions = {}; | ||
for (var key in options) { | ||
if (key !== 'rollup' && key !== 'allowRealFiles') { | ||
adjustedOptions[key] = options[key]; | ||
} | ||
} | ||
var vinylSystem = hypothetical({ files: vinylFiles, allowRealFiles: true, impliedExtensions: impliedExtensions }); | ||
if (!adjustedOptions.plugins) { | ||
adjustedOptions.plugins = []; | ||
} else if (!Array.isArray(adjustedOptions.plugins)) { | ||
adjustedOptions.plugins = [adjustedOptions.plugins]; | ||
} | ||
adjustedOptions.plugins = adjustedOptions.plugins.concat(hypothetical({ | ||
files: wonderland, | ||
allowRealFiles: options.allowRealFiles | ||
})); | ||
entryFiles.then(function(entryFiles) { | ||
return Promise.all(entryFiles.map(function(entryFile) { | ||
options.entry = entryFile; | ||
adjustedOptions.entry = entryFile; | ||
options.sourceMap = haveSourcemaps; | ||
adjustedOptions.sourceMap = haveSourcemaps; | ||
return rollup.rollup(options).then(function(bundle) { | ||
var result = bundle.generate(options); | ||
return rollup.rollup(adjustedOptions).then(function(bundle) { | ||
var result = bundle.generate(adjustedOptions); | ||
// get the corresponding entry Vinyl file to output with. | ||
// this makes file.history work. maybe expando properties too if you use them. | ||
var file = entries[i]; | ||
var file = vinylSystem.load(vinylSystem.resolveId(entryFile)); | ||
if (file === undefined) { // possible if options.allowRealFiles is true | ||
@@ -114,0 +104,0 @@ file = new File({ |
{ | ||
"name": "gulp-rollup", | ||
"version": "2.2.0", | ||
"version": "2.3.0", | ||
"description": "gulp plugin for Rollup ES6 module bundler", | ||
@@ -28,4 +28,4 @@ "main": "index.js", | ||
"readable-stream": "^2.1.4", | ||
"rollup": "^0.33.0", | ||
"rollup-plugin-hypothetical": "^1.0.0" | ||
"rollup": "^0.34.1", | ||
"rollup-plugin-hypothetical": "^1.1.0" | ||
}, | ||
@@ -32,0 +32,0 @@ "devDependencies": { |
@@ -70,2 +70,4 @@ # gulp-rollup [![npm][npm-image]][npm-url] [![Dependency Status][david-image]][david-url] [![Build Status][travis-image]][travis-url] | ||
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. | ||
[npm-url]: https://npmjs.org/package/gulp-rollup | ||
@@ -72,0 +74,0 @@ [npm-image]: https://img.shields.io/npm/v/gulp-rollup.svg |
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
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
78
10974
119
+ Addedrollup@0.34.13(transitive)
- Removedrollup@0.33.2(transitive)
Updatedrollup@^0.34.1