Socket
Socket
Sign inDemoInstall

rollup-plugin-node-resolve

Package Overview
Dependencies
14
Maintainers
4
Versions
34
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.2.3 to 4.2.4

6

CHANGELOG.md
# rollup-plugin-node-resolve changelog
## 4.2.4 (2019-05-11)
* Add note on builtins to Readme ([#215](https://github.com/rollup/rollup-plugin-node-resolve/pull/215) by @keithamus)
* Add issue templates ([#217](https://github.com/rollup/rollup-plugin-node-resolve/pull/217) by @mecurc)
* Improve performance by caching `isDir` ([#218](https://github.com/rollup/rollup-plugin-node-resolve/pull/218) by @keithamus)
## 4.2.3 (2019-04-11)

@@ -4,0 +10,0 @@

56

dist/rollup-plugin-node-resolve.cjs.js

@@ -16,30 +16,26 @@ 'use strict';

var readFileCache = {};
var readFileAsync = function (file) { return new Promise(function (fulfil, reject) { return fs.readFile(file, function (err, contents) { return err ? reject(err) : fulfil(contents); }); }); };
var statAsync = function (file) { return new Promise(function (fulfil, reject) { return fs.stat(file, function (err, contents) { return err ? reject(err) : fulfil(contents); }); }); };
function cachedReadFile (file, cb) {
if (file in readFileCache === false) {
readFileCache[file] = readFileAsync(file).catch(function (err) {
delete readFileCache[file];
throw err;
});
}
readFileCache[file].then(function (contents) { return cb(null, contents); }, cb);
}
var cache = function (fn) {
var cache = new Map();
var wrapped = function (param, done) {
if (cache.has(param) === false) {
cache.set(param, fn(param).catch(function (err) {
cache.delete(param);
throw err;
}));
}
return cache.get(param).then(function (result) { return done(null, result); }, done);
};
wrapped.clear = function () { return cache.clear(); };
return wrapped;
};
var ignoreENOENT = function (err) {
if (err.code === 'ENOENT') { return false; }
throw err;
};
var readFileCached = cache(readFileAsync);
var isDirCached = cache(function (file) { return statAsync(file).then(function (stat) { return stat.isDirectory(); }, ignoreENOENT); });
var isFileCached = cache(function (file) { return statAsync(file).then(function (stat) { return stat.isFile(); }, ignoreENOENT); });
var isFileCache = {};
function cachedIsFile (file, cb) {
if (file in isFileCache === false) {
isFileCache[file] = statAsync(file)
.then(
function (stat) { return stat.isFile(); },
function (err) {
if (err.code === 'ENOENT') { return false; }
delete isFileCache[file];
throw err;
});
}
isFileCache[file].then(function (contents) { return cb(null, contents); }, cb);
}
function getMainFields (options) {

@@ -113,4 +109,5 @@ var mainFields;

generateBundle: function generateBundle () {
isFileCache = {};
readFileCache = {};
readFileCached.clear();
isFileCached.clear();
isDirCached.clear();
},

@@ -197,4 +194,5 @@

},
readFile: cachedReadFile,
isFile: cachedIsFile,
readFile: readFileCached,
isFile: isFileCached,
isDirectory: isDirCached,
extensions: extensions

@@ -201,0 +199,0 @@ };

@@ -12,30 +12,26 @@ import { dirname, join, resolve, normalize, sep, extname } from 'path';

var readFileCache = {};
var readFileAsync = function (file) { return new Promise(function (fulfil, reject) { return fs.readFile(file, function (err, contents) { return err ? reject(err) : fulfil(contents); }); }); };
var statAsync = function (file) { return new Promise(function (fulfil, reject) { return fs.stat(file, function (err, contents) { return err ? reject(err) : fulfil(contents); }); }); };
function cachedReadFile (file, cb) {
if (file in readFileCache === false) {
readFileCache[file] = readFileAsync(file).catch(function (err) {
delete readFileCache[file];
throw err;
});
}
readFileCache[file].then(function (contents) { return cb(null, contents); }, cb);
}
var cache = function (fn) {
var cache = new Map();
var wrapped = function (param, done) {
if (cache.has(param) === false) {
cache.set(param, fn(param).catch(function (err) {
cache.delete(param);
throw err;
}));
}
return cache.get(param).then(function (result) { return done(null, result); }, done);
};
wrapped.clear = function () { return cache.clear(); };
return wrapped;
};
var ignoreENOENT = function (err) {
if (err.code === 'ENOENT') { return false; }
throw err;
};
var readFileCached = cache(readFileAsync);
var isDirCached = cache(function (file) { return statAsync(file).then(function (stat) { return stat.isDirectory(); }, ignoreENOENT); });
var isFileCached = cache(function (file) { return statAsync(file).then(function (stat) { return stat.isFile(); }, ignoreENOENT); });
var isFileCache = {};
function cachedIsFile (file, cb) {
if (file in isFileCache === false) {
isFileCache[file] = statAsync(file)
.then(
function (stat) { return stat.isFile(); },
function (err) {
if (err.code === 'ENOENT') { return false; }
delete isFileCache[file];
throw err;
});
}
isFileCache[file].then(function (contents) { return cb(null, contents); }, cb);
}
function getMainFields (options) {

@@ -109,4 +105,5 @@ var mainFields;

generateBundle: function generateBundle () {
isFileCache = {};
readFileCache = {};
readFileCached.clear();
isFileCached.clear();
isDirCached.clear();
},

@@ -193,4 +190,5 @@

},
readFile: cachedReadFile,
isFile: cachedIsFile,
readFile: readFileCached,
isFile: isFileCached,
isDirectory: isDirCached,
extensions: extensions

@@ -197,0 +195,0 @@ };

{
"name": "rollup-plugin-node-resolve",
"description": "Bundle third-party dependencies in node_modules",
"version": "4.2.3",
"version": "4.2.4",
"devDependencies": {

@@ -6,0 +6,0 @@ "buble": "^0.19.7",

@@ -115,5 +115,22 @@ # rollup-plugin-node-resolve

## Resolving Built-Ins (like `fs`)
This plugin won't resolve any builtins (e.g. `fs`). If you need to resolve builtins you can install local modules and set `preferBuiltins` to `false`, or install a plugin like [rollup-plugin-node-builtins](https://github.com/calvinmetcalf/rollup-plugin-node-builtins) which provides stubbed versions of these methods.
If you want to silence warnings about builtins, you can add the list of builtins to the `externals` option; like so:
```js
import resolve from 'rollup-plugin-node-resolve';
import builtins from 'builtin-modules'
export default ({
input: ...,
plugins: [resolve()],
externals: builtins,
output: ...
})
```
## License
MIT

@@ -12,30 +12,26 @@ import {dirname, extname, join, normalize, resolve, sep} from 'path';

let readFileCache = {};
const readFileAsync = file => new Promise((fulfil, reject) => fs.readFile(file, (err, contents) => err ? reject(err) : fulfil(contents)));
const statAsync = file => new Promise((fulfil, reject) => fs.stat(file, (err, contents) => err ? reject(err) : fulfil(contents)));
function cachedReadFile (file, cb) {
if (file in readFileCache === false) {
readFileCache[file] = readFileAsync(file).catch(err => {
delete readFileCache[file];
throw err;
});
}
readFileCache[file].then(contents => cb(null, contents), cb);
}
const cache = fn => {
const cache = new Map();
const wrapped = (param, done) => {
if (cache.has(param) === false) {
cache.set(param, fn(param).catch(err => {
cache.delete(param);
throw err;
}));
}
return cache.get(param).then(result => done(null, result), done);
};
wrapped.clear = () => cache.clear();
return wrapped;
};
const ignoreENOENT = err => {
if (err.code === 'ENOENT') return false;
throw err;
};
const readFileCached = cache(readFileAsync);
const isDirCached = cache(file => statAsync(file).then(stat => stat.isDirectory(), ignoreENOENT));
const isFileCached = cache(file => statAsync(file).then(stat => stat.isFile(), ignoreENOENT));
let isFileCache = {};
function cachedIsFile (file, cb) {
if (file in isFileCache === false) {
isFileCache[file] = statAsync(file)
.then(
stat => stat.isFile(),
err => {
if (err.code === 'ENOENT') return false;
delete isFileCache[file];
throw err;
});
}
isFileCache[file].then(contents => cb(null, contents), cb);
}
function getMainFields (options) {

@@ -103,4 +99,5 @@ let mainFields;

generateBundle () {
isFileCache = {};
readFileCache = {};
readFileCached.clear();
isFileCached.clear();
isDirCached.clear();
},

@@ -185,4 +182,5 @@

},
readFile: cachedReadFile,
isFile: cachedIsFile,
readFile: readFileCached,
isFile: isFileCached,
isDirectory: isDirCached,
extensions: extensions

@@ -189,0 +187,0 @@ };

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc