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

babel-plugin-ember-modules-api-polyfill

Package Overview
Dependencies
Maintainers
3
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-ember-modules-api-polyfill - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0

2

package.json
{
"name": "babel-plugin-ember-modules-api-polyfill",
"version": "1.3.0",
"version": "1.4.0",
"description": "Polyfill for Ember JS API.",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -6,2 +6,12 @@ 'use strict';

function isBlacklisted(blacklist, importPath, exportName) {
if (Array.isArray(blacklist)) {
return blacklist.indexOf(importPath) > -1;
} else {
let blacklistedExports = blacklist[importPath];
return blacklistedExports.indexOf(exportName) > -1;
}
}
module.exports = function(babel) {

@@ -35,5 +45,6 @@ const t = babel.types;

let replacements = [];
let removals = [];
let importPath = node.source.value;
if (!reverseMapping[importPath] || blacklist.indexOf(importPath) > -1) {
if (!reverseMapping[importPath]) {
// not a module provided by emberjs/rfcs#176

@@ -48,3 +59,4 @@ // so we have nothing to do here

// Iterate all the specifiers and attempt to locate their mapping
node.specifiers.forEach(specifier => {
path.get('specifiers').forEach(specifierPath => {
let specifier = specifierPath.node;
let importName;

@@ -74,2 +86,6 @@

if (isBlacklisted(blacklist, importPath, importName)) {
return;
}
// Extract the global mapping

@@ -83,2 +99,4 @@ const global = mapping[importName];

removals.push(specifierPath);
// Repalce the node with a new `var name = Ember.something`

@@ -95,4 +113,7 @@ replacements.push(

if (replacements.length > 0) {
if (removals.length === node.specifiers.length) {
path.replaceWithMultiple(replacements);
} else if (replacements.length > 0) {
removals.forEach(specifierPath => specifierPath.remove());
path.insertAfter(replacements);
}

@@ -99,0 +120,0 @@ },

@@ -91,2 +91,16 @@ 'use strict';

// Ensure unknown exports are not removed
describe(`unknown imports from known module`, () => {
it(`allows blacklisting import paths`, assert => {
let input = `import { derp } from '@ember/object/computed';`;
assert.throws(() => {
transform(input, [
[Plugin],
]);
}, /@ember\/object\/computed does not have a derp import/);
});
});
describe('options', () => {

@@ -101,2 +115,11 @@ it(`allows blacklisting import paths`, assert => {

});
it(`allows blacklisting specific named imports`, assert => {
let input = `import { assert, inspect } from '@ember/debug';`;
let actual = transform(input, [
[Plugin, { blacklist: { '@ember/debug': ['assert', 'warn', 'deprecate'] } }],
]);
assert.equal(actual, `import { assert } from '@ember/debug';\nvar inspect = Ember.inspect;`);
});
});
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