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

rollup-pluginutils

Package Overview
Dependencies
Maintainers
3
Versions
29
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 2.1.1 to 2.2.0

4

CHANGELOG.md
# rollup-pluginutils changelog
## 2.2.0
*2017-05-11*
* Improve white-space handling in `dataToEsm` and add `prepare` script ([#31](https://github.com/rollup/rollup-pluginutils/issues/31))
## 2.1.0

@@ -4,0 +8,0 @@ *2017-05-07*

83

dist/pluginutils.cjs.js

@@ -10,3 +10,2 @@ 'use strict';

var mm = _interopDefault(require('micromatch'));
var tosource = _interopDefault(require('tosource'));

@@ -226,27 +225,65 @@ function addExtension ( filename, ext ) {

function serializeArray (arr, indent, baseIndent) {
var output = '[';
var separator = indent ? '\n' + baseIndent + indent : '';
for (var i = 0; i < arr.length; i++) {
var key = arr[i];
output += "" + (i > 0 ? ',' : '') + separator + (serialize(key, indent, baseIndent + indent));
}
return output + (indent ? '\n' + baseIndent : '') + "]";
}
function serializeObject (obj, indent, baseIndent) {
var output = '{';
var separator = indent ? '\n' + baseIndent + indent : '';
var keys = Object.keys(obj);
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
var stringKey = makeLegalIdentifier(key) === key ? key : JSON.stringify(key);
output += "" + (i > 0 ? ',' : '') + separator + stringKey + ":" + (indent ? ' ' : '') + (serialize(obj[key], indent, baseIndent + indent));
}
return output + (indent ? '\n' + baseIndent : '') + "}";
}
function serialize (obj, indent, baseIndent) {
if (obj === Infinity)
{ return 'Infinity'; }
if (obj instanceof Date)
{ return 'new Date(' + obj.getTime() + ')'; }
if (obj instanceof RegExp)
{ return obj.toString(); }
if (typeof obj === 'number' && isNaN(obj))
{ return 'NaN'; }
if (Array.isArray(obj))
{ return serializeArray(obj, indent, baseIndent); }
if (typeof obj === 'object')
{ return serializeObject(obj, indent, baseIndent); }
return JSON.stringify(obj);
}
// convert data object into separate named exports (and default)
function dataToNamedExports ( data, options ) {
if ( options === void 0 ) options = {};
function dataToNamedExports (data, options) {
if ( options === void 0 ) options = {};
var t = options.compact ? '' : 'indent' in options ? options.indent : '\t';
var _ = options.compact ? '' : ' ';
var n = options.compact ? '' : '\n';
var declarationType = options.preferConst ? 'const' : 'var';
var t = options.compact ? '' : 'indent' in options ? options.indent : '\t';
var _ = options.compact ? '' : ' ';
var n = options.compact ? '' : '\n';
var declarationType = options.preferConst ? 'const' : 'var';
var namedExportCode = '';
var defaultExportRows = [];
var dataKeys = Object.keys( data );
for (var i = 0; i < dataKeys.length; i++) {
var key = dataKeys[i];
if (key === makeLegalIdentifier( key )) {
if ( options.objectShorthand )
{ defaultExportRows.push(key); }
else
{ defaultExportRows.push( (key + ":" + _ + key) ); }
namedExportCode += "export " + declarationType + " " + key + _ + "=" + _ + (tosource( data[key], null, options.compact ? false : t )) + ";" + n;
} else {
defaultExportRows.push( ((JSON.stringify(key)) + ": " + (tosource( data[key], null, options.compact ? false : t ))) );
}
}
return namedExportCode + "export default" + _ + "{" + n + t + (defaultExportRows.join(("," + n + t))) + n + "};" + n;
var namedExportCode = '';
var defaultExportRows = [];
var dataKeys = Object.keys(data);
for (var i = 0; i < dataKeys.length; i++) {
var key = dataKeys[i];
if (key === makeLegalIdentifier(key)) {
if (options.objectShorthand)
{ defaultExportRows.push(key); }
else
{ defaultExportRows.push((key + ":" + _ + key)); }
namedExportCode += "export " + declarationType + " " + key + _ + "=" + _ + (serialize(data[key], options.compact ? null : t, '')) + ";" + n;
} else {
defaultExportRows.push(((JSON.stringify(key)) + ": " + (serialize(data[key], options.compact ? null : t, ''))));
}
}
return namedExportCode + "export default" + _ + "{" + n + t + (defaultExportRows.join(("," + n + t))) + n + "};" + n;
}

@@ -253,0 +290,0 @@

import { extname, resolve, sep } from 'path';
import { walk } from 'estree-walker';
import mm from 'micromatch';
import tosource from 'tosource';

@@ -219,29 +218,67 @@ function addExtension ( filename, ext ) {

function serializeArray (arr, indent, baseIndent) {
var output = '[';
var separator = indent ? '\n' + baseIndent + indent : '';
for (var i = 0; i < arr.length; i++) {
var key = arr[i];
output += "" + (i > 0 ? ',' : '') + separator + (serialize(key, indent, baseIndent + indent));
}
return output + (indent ? '\n' + baseIndent : '') + "]";
}
function serializeObject (obj, indent, baseIndent) {
var output = '{';
var separator = indent ? '\n' + baseIndent + indent : '';
var keys = Object.keys(obj);
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
var stringKey = makeLegalIdentifier(key) === key ? key : JSON.stringify(key);
output += "" + (i > 0 ? ',' : '') + separator + stringKey + ":" + (indent ? ' ' : '') + (serialize(obj[key], indent, baseIndent + indent));
}
return output + (indent ? '\n' + baseIndent : '') + "}";
}
function serialize (obj, indent, baseIndent) {
if (obj === Infinity)
{ return 'Infinity'; }
if (obj instanceof Date)
{ return 'new Date(' + obj.getTime() + ')'; }
if (obj instanceof RegExp)
{ return obj.toString(); }
if (typeof obj === 'number' && isNaN(obj))
{ return 'NaN'; }
if (Array.isArray(obj))
{ return serializeArray(obj, indent, baseIndent); }
if (typeof obj === 'object')
{ return serializeObject(obj, indent, baseIndent); }
return JSON.stringify(obj);
}
// convert data object into separate named exports (and default)
function dataToNamedExports ( data, options ) {
if ( options === void 0 ) options = {};
function dataToNamedExports (data, options) {
if ( options === void 0 ) options = {};
var t = options.compact ? '' : 'indent' in options ? options.indent : '\t';
var _ = options.compact ? '' : ' ';
var n = options.compact ? '' : '\n';
var declarationType = options.preferConst ? 'const' : 'var';
var t = options.compact ? '' : 'indent' in options ? options.indent : '\t';
var _ = options.compact ? '' : ' ';
var n = options.compact ? '' : '\n';
var declarationType = options.preferConst ? 'const' : 'var';
var namedExportCode = '';
var defaultExportRows = [];
var dataKeys = Object.keys( data );
for (var i = 0; i < dataKeys.length; i++) {
var key = dataKeys[i];
if (key === makeLegalIdentifier( key )) {
if ( options.objectShorthand )
{ defaultExportRows.push(key); }
else
{ defaultExportRows.push( (key + ":" + _ + key) ); }
namedExportCode += "export " + declarationType + " " + key + _ + "=" + _ + (tosource( data[key], null, options.compact ? false : t )) + ";" + n;
} else {
defaultExportRows.push( ((JSON.stringify(key)) + ": " + (tosource( data[key], null, options.compact ? false : t ))) );
}
}
return namedExportCode + "export default" + _ + "{" + n + t + (defaultExportRows.join(("," + n + t))) + n + "};" + n;
var namedExportCode = '';
var defaultExportRows = [];
var dataKeys = Object.keys(data);
for (var i = 0; i < dataKeys.length; i++) {
var key = dataKeys[i];
if (key === makeLegalIdentifier(key)) {
if (options.objectShorthand)
{ defaultExportRows.push(key); }
else
{ defaultExportRows.push((key + ":" + _ + key)); }
namedExportCode += "export " + declarationType + " " + key + _ + "=" + _ + (serialize(data[key], options.compact ? null : t, '')) + ";" + n;
} else {
defaultExportRows.push(((JSON.stringify(key)) + ": " + (serialize(data[key], options.compact ? null : t, ''))));
}
}
return namedExportCode + "export default" + _ + "{" + n + t + (defaultExportRows.join(("," + n + t))) + n + "};" + n;
}
export { addExtension, attachScopes, createFilter, makeLegalIdentifier, dataToNamedExports as dataToEsm };
{
"name": "rollup-pluginutils",
"description": "Functionality commonly needed by Rollup plugins",
"version": "2.1.1",
"version": "2.2.0",
"main": "dist/pluginutils.cjs.js",

@@ -15,2 +15,4 @@ "module": "dist/pluginutils.es.js",

"eslint": "^4.19.1",
"husky": "^0.14.3",
"lint-staged": "^7.1.0",
"mocha": "^5.1.1",

@@ -23,9 +25,12 @@ "rollup": "^0.58.2",

"build": "rollup -c",
"lint": "eslint --fix src test",
"pretest": "npm run build",
"prepublish": "npm test"
"prepublishOnly": "npm test",
"prepare": "npm run build",
"precommit": "lint-staged",
"postcommit": "git reset"
},
"dependencies": {
"estree-walker": "^0.5.2",
"micromatch": "^2.3.11",
"tosource": "^1.0.0"
"micromatch": "^2.3.11"
},

@@ -32,0 +37,0 @@ "repository": "rollup/rollup-pluginutils",

@@ -0,0 +0,0 @@ # rollup-pluginutils

@@ -0,0 +0,0 @@ import { extname } from 'path';

@@ -0,0 +0,0 @@ import { walk } from 'estree-walker';

@@ -0,0 +0,0 @@ import { resolve, sep } from 'path';

import makeLegalIdentifier from './makeLegalIdentifier';
import tosource from 'tosource';
function serializeArray (arr, indent, baseIndent) {
let output = '[';
const separator = indent ? '\n' + baseIndent + indent : '';
for (let i = 0; i < arr.length; i++) {
const key = arr[i];
output += `${ i > 0 ? ',' : '' }${ separator }${ serialize(key, indent, baseIndent + indent) }`;
}
return output + `${ indent ? '\n' + baseIndent : '' }]`;
}
function serializeObject (obj, indent, baseIndent) {
let output = '{';
const separator = indent ? '\n' + baseIndent + indent : '';
const keys = Object.keys(obj);
for (let i = 0; i < keys.length; i++) {
const key = keys[i];
const stringKey = makeLegalIdentifier(key) === key ? key : JSON.stringify(key);
output += `${ i > 0 ? ',' : '' }${ separator }${ stringKey }:${ indent ? ' ' : '' }${ serialize(obj[key], indent, baseIndent + indent) }`;
}
return output + `${ indent ? '\n' + baseIndent : '' }}`;
}
function serialize (obj, indent, baseIndent) {
if (obj === Infinity)
return 'Infinity';
if (obj instanceof Date)
return 'new Date(' + obj.getTime() + ')';
if (obj instanceof RegExp)
return obj.toString();
if (typeof obj === 'number' && isNaN(obj))
return 'NaN';
if (Array.isArray(obj))
return serializeArray(obj, indent, baseIndent);
if (typeof obj === 'object')
return serializeObject(obj, indent, baseIndent);
return JSON.stringify(obj);
}
// convert data object into separate named exports (and default)
export default function dataToNamedExports ( data, options = {} ) {
const t = options.compact ? '' : 'indent' in options ? options.indent : '\t';
const _ = options.compact ? '' : ' ';
const n = options.compact ? '' : '\n';
const declarationType = options.preferConst ? 'const' : 'var';
export default function dataToNamedExports (data, options = {}) {
const t = options.compact ? '' : 'indent' in options ? options.indent : '\t';
const _ = options.compact ? '' : ' ';
const n = options.compact ? '' : '\n';
const declarationType = options.preferConst ? 'const' : 'var';
let namedExportCode = '';
const defaultExportRows = [];
const dataKeys = Object.keys( data );
for (let i = 0; i < dataKeys.length; i++) {
const key = dataKeys[i];
if (key === makeLegalIdentifier( key )) {
if ( options.objectShorthand )
defaultExportRows.push(key);
else
defaultExportRows.push( `${ key }:${ _ }${ key }` );
namedExportCode += `export ${declarationType} ${key}${ _ }=${ _ }${ tosource( data[key], null, options.compact ? false : t ) };${ n }`;
} else {
defaultExportRows.push( `${ JSON.stringify(key) }: ${ tosource( data[key], null, options.compact ? false : t )}` );
}
}
return namedExportCode + `export default${ _ }{${ n }${ t }${ defaultExportRows.join(`,${ n }${ t }`) }${ n }};${ n }`;
};
let namedExportCode = '';
const defaultExportRows = [];
const dataKeys = Object.keys(data);
for (let i = 0; i < dataKeys.length; i++) {
const key = dataKeys[i];
if (key === makeLegalIdentifier(key)) {
if (options.objectShorthand)
defaultExportRows.push(key);
else
defaultExportRows.push(`${ key }:${ _ }${ key }`);
namedExportCode += `export ${declarationType} ${key}${ _ }=${ _ }${ serialize(data[key], options.compact ? null : t, '') };${ n }`;
} else {
defaultExportRows.push(`${ JSON.stringify(key) }: ${ serialize(data[key], options.compact ? null : t, '')}`);
}
}
return namedExportCode + `export default${ _ }{${ n }${ t }${ defaultExportRows.join(`,${ n }${ t }`) }${ n }};${ n }`;
}

@@ -0,0 +0,0 @@ export { default as addExtension } from './addExtension';

@@ -0,0 +0,0 @@ const reservedWords = 'break case class catch const continue debugger default delete do else export extends finally for function if import in instanceof let new return super switch this throw try typeof var void while with yield enum await implements package protected static interface private public'.split( ' ' );

@@ -0,0 +0,0 @@ export default function ensureArray ( thing ) {

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