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

modify-babel-preset

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

modify-babel-preset - npm Package Compare versions

Comparing version 1.1.3 to 1.2.0

test/fixtures/one.js

9

index.js

@@ -20,5 +20,6 @@ var path = require('path'),

modifications = modifications || {};
var nameDrops = modifications.nameDrops!==false;
if (typeof preset==='string') {
if (!preset.match(/^babel-preset-/)) {
if (!preset.match(/(^babel-preset-|\/)/)) {
try {

@@ -78,2 +79,4 @@ preset = relative.resolve('babel-preset-'+preset);

Object.keys(modifications).forEach(function(key) {
if (key==='nameDrops') return;
var value = modifications[key],

@@ -89,3 +92,5 @@ index = indexOf(plugins, key);

var p = getPlugin(key);
plugin._original_name = key;
if (nameDrops) {
p._original_name = key;
}
if (value!==true) {

@@ -92,0 +97,0 @@ p = [p].concat(value);

{
"name": "modify-babel-preset",
"version": "1.1.3",
"version": "1.2.0",
"description": "Create a modified babel preset based on an an existing preset.",
"main": "index.js",
"scripts": {
"prepublish": "NODE_ENV=development npm test",
"test": "mocha test/**"

@@ -8,0 +9,0 @@ },

@@ -27,2 +27,3 @@ var expect = require('chai').expect,

var out = modifyBabelPreset('es2015', {
nameDrops: false,
'transform-react-jsx': true

@@ -35,2 +36,3 @@ });

var out = modifyBabelPreset('es2015', {
nameDrops: false,
'transform-react-jsx': { jsxPragma:'h' }

@@ -42,2 +44,30 @@ });

});
it('should work recursively', function() {
var one = require('./fixtures/one');
expect(one.plugins).to.deep.equal( es2015Preset.plugins.concat([
[jsx, { jsxPragma:'h' }]
]).map(function(p) {
if (p===transform || p[0]===transform) {
return [transform, { loose:true }];
}
return p;
}) );
var two = require('./fixtures/two');
two.plugins.forEach(function(p) {
var f = Array.isArray(p) ? p[0] : p;
delete p._original_name;
});
delete transform._original_name;
delete jsx._original_name;
var target = es2015Preset.plugins.concat([
[jsx, { jsxPragma:'z' }]
]);
target.splice(17, 1);
expect(two.plugins).to.deep.equal(target);
});
});
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