Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@rollup/pluginutils

Package Overview
Dependencies
Maintainers
4
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rollup/pluginutils - npm Package Compare versions

Comparing version 4.0.0 to 4.1.0

16

CHANGELOG.md
# @rollup/pluginutils ChangeLog
## v4.1.0
_2020-10-27_
### Bugfixes
- fix: attach scope object to for-loop (#616)
### Features
- feat: normalizePath (#550)
### Updates
- refactor: improve readability of attachScopes test (#551)
## v4.0.0

@@ -4,0 +20,0 @@

41

dist/cjs/index.js

@@ -5,7 +5,9 @@ 'use strict';

function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var path = require('path');
var pm = _interopDefault(require('picomatch'));
var pm = require('picomatch');
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
var pm__default = /*#__PURE__*/_interopDefaultLegacy(pm);
const addExtension = function addExtension(filename, ext = '.js') {

@@ -235,9 +237,5 @@ let result = `${filename}`;

const isBlockDeclaration = blockDeclarations[kind];
// don't add const/let declarations in the body of a for loop #113
const parentType = parent ? parent.type : '';
if (!(isBlockDeclaration && /ForOfStatement/.test(parentType))) {
node.declarations.forEach((declaration) => {
scope.addDeclaration(declaration, isBlockDeclaration, true);
});
}
node.declarations.forEach((declaration) => {
scope.addDeclaration(declaration, isBlockDeclaration, true);
});
}

@@ -259,2 +257,9 @@ let newScope;

}
// create new for scope
if (/For(In|Of)?Statement/.test(node.type)) {
newScope = new Scope({
parent: scope,
block: true
});
}
// create new block scope

@@ -304,2 +309,6 @@ if (node.type === 'BlockStatement' && !/Function/.test(parent.type)) {

const normalizePath = function (filename) {
return filename.split(path.win32.sep).join(path.posix.sep);
};
function getMatcherString(id, resolutionBase) {

@@ -310,5 +319,3 @@ if (resolutionBase === false || path.isAbsolute(id) || id.startsWith('*')) {

// resolve('') is valid and will default to process.cwd()
const basePath = path.resolve(resolutionBase || '')
.split(path.sep)
.join('/')
const basePath = normalizePath(path.resolve(resolutionBase || ''))
// escape all possible (posix + win) path characters that might interfere with regex

@@ -330,3 +337,3 @@ .replace(/[-^$*+?.()|[\]{}]/g, '\\$&');

const pattern = getMatcherString(id, resolutionBase);
const fn = pm(pattern, { dot: true });
const fn = pm__default['default'](pattern, { dot: true });
const result = fn(what);

@@ -343,3 +350,3 @@ return result;

return false;
const pathId = id.split(path.sep).join('/');
const pathId = normalizePath(id);
for (let i = 0; i < excludeMatchers.length; ++i) {

@@ -456,3 +463,4 @@ const matcher = excludeMatchers[i];

extractAssignedNames,
makeLegalIdentifier
makeLegalIdentifier,
normalizePath
};

@@ -467,1 +475,2 @@

exports.makeLegalIdentifier = makeLegalIdentifier;
exports.normalizePath = normalizePath;

@@ -1,2 +0,2 @@

import { extname, sep, isAbsolute, resolve, posix } from 'path';
import { extname, win32, posix, isAbsolute, resolve } from 'path';
import pm from 'picomatch';

@@ -228,9 +228,5 @@

const isBlockDeclaration = blockDeclarations[kind];
// don't add const/let declarations in the body of a for loop #113
const parentType = parent ? parent.type : '';
if (!(isBlockDeclaration && /ForOfStatement/.test(parentType))) {
node.declarations.forEach((declaration) => {
scope.addDeclaration(declaration, isBlockDeclaration, true);
});
}
node.declarations.forEach((declaration) => {
scope.addDeclaration(declaration, isBlockDeclaration, true);
});
}

@@ -252,2 +248,9 @@ let newScope;

}
// create new for scope
if (/For(In|Of)?Statement/.test(node.type)) {
newScope = new Scope({
parent: scope,
block: true
});
}
// create new block scope

@@ -297,2 +300,6 @@ if (node.type === 'BlockStatement' && !/Function/.test(parent.type)) {

const normalizePath = function (filename) {
return filename.split(win32.sep).join(posix.sep);
};
function getMatcherString(id, resolutionBase) {

@@ -303,5 +310,3 @@ if (resolutionBase === false || isAbsolute(id) || id.startsWith('*')) {

// resolve('') is valid and will default to process.cwd()
const basePath = resolve(resolutionBase || '')
.split(sep)
.join('/')
const basePath = normalizePath(resolve(resolutionBase || ''))
// escape all possible (posix + win) path characters that might interfere with regex

@@ -335,3 +340,3 @@ .replace(/[-^$*+?.()|[\]{}]/g, '\\$&');

return false;
const pathId = id.split(sep).join('/');
const pathId = normalizePath(id);
for (let i = 0; i < excludeMatchers.length; ++i) {

@@ -448,6 +453,7 @@ const matcher = excludeMatchers[i];

extractAssignedNames,
makeLegalIdentifier
makeLegalIdentifier,
normalizePath
};
export default index;
export { addExtension, attachScopes, createFilter, dataToEsm, extractAssignedNames, makeLegalIdentifier };
export { addExtension, attachScopes, createFilter, dataToEsm, extractAssignedNames, makeLegalIdentifier, normalizePath };
{
"name": "@rollup/pluginutils",
"version": "4.0.0",
"version": "4.1.0",
"publishConfig": {

@@ -17,2 +17,7 @@ "access": "public"

"module": "./dist/es/index.js",
"type": "commonjs",
"exports": {
"require": "./dist/cjs/index.js",
"import": "./dist/es/index.js"
},
"engines": {

@@ -52,3 +57,2 @@ "node": ">= 8.0.0"

"dependencies": {
"@types/estree": "0.0.45",
"estree-walker": "^2.0.1",

@@ -61,4 +65,6 @@ "picomatch": "^2.2.2"

"@rollup/plugin-typescript": "^5.0.2",
"@types/estree": "0.0.45",
"@types/node": "^14.0.26",
"@types/picomatch": "^2.2.1",
"acorn": "^8.0.4",
"rollup": "^2.23.0"

@@ -84,6 +90,2 @@ },

},
"exports": {
"require": "./dist/cjs/index.js",
"import": "./dist/es/index.js"
},
"nyc": {

@@ -94,4 +96,3 @@ "extension": [

]
},
"type": "commonjs"
}
}

@@ -53,4 +53,4 @@ [npm]: https://img.shields.io/npm/v/@rollup/pluginutils

// only adds an extension if there isn't one already
id = addExtension(id); // `foo` -> `foo.js`, `foo.js -> foo.js`
id = addExtension(id, '.myext'); // `foo` -> `foo.myext`, `foo.js -> `foo.js`
id = addExtension(id); // `foo` -> `foo.js`, `foo.js` -> `foo.js`
id = addExtension(id, '.myext'); // `foo` -> `foo.myext`, `foo.js` -> `foo.js`
}

@@ -211,3 +211,3 @@ };

// do something with the declared names
// e.g. for `const {x, y: z} = ... => declaredNames = ['x', 'z']
// e.g. for `const {x, y: z} = ...` => declaredNames = ['x', 'z']
}

@@ -237,2 +237,18 @@ }

### normalizePath
Converts path separators to forward slash.
Parameters: `(filename: String)`<br>
Returns: `String`
#### Usage
```js
import { normalizePath } from '@rollup/pluginutils';
normalizePath('foo\\bar'); // 'foo/bar'
normalizePath('foo/bar'); // 'foo/bar'
```
## Meta

@@ -239,0 +255,0 @@

@@ -71,2 +71,7 @@ // eslint-disable-next-line import/no-unresolved

/**
* Converts path separators to forward slash.
*/
export function normalizePath(filename: string): string;
export type AddExtension = typeof addExtension;

@@ -77,2 +82,3 @@ export type AttachScopes = typeof attachScopes;

export type MakeLegalIdentifier = typeof makeLegalIdentifier;
export type NormalizePath = typeof normalizePath;
export type DataToEsm = typeof dataToEsm;

@@ -87,3 +93,4 @@

makeLegalIdentifier: MakeLegalIdentifier;
normalizePath: NormalizePath;
};
export default defaultExport;
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