Socket
Socket
Sign inDemoInstall

@linaria/shaker

Package Overview
Dependencies
Maintainers
4
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@linaria/shaker - npm Package Compare versions

Comparing version 4.2.3 to 4.2.4

18

esm/plugins/__tests__/shaker-plugin.test.js

@@ -182,3 +182,21 @@ import { join } from 'path';

});
it('should delete import', () => {
const {
code,
metadata
} = keep(['Alive'])`
import { A, B } from "ABC";
const AB = {
A,
B,
};
export const Alive = "";
export default AB;
`;
expect(code).toMatchSnapshot();
expect(metadata.imports.size).toBe(0);
});
});
//# sourceMappingURL=shaker-plugin.test.js.map

20

esm/plugins/shaker-plugin.js
import { createCustomDebug } from '@linaria/logger';
import { collectExportsAndImports, getFileIdx, isRemoved, removeWithRelated, sideEffectImport, reference, findParentForDelete, dereference } from '@linaria/utils';
import { collectExportsAndImports, getFileIdx, isRemoved, removeWithRelated, sideEffectImport, reference, findActionForNode, dereference, mutate } from '@linaria/utils';
export const hasShakerMetadata = metadata => metadata !== undefined && '__linariaShaker' in metadata;

@@ -171,3 +171,4 @@

const binding = getBindingForExport(path);
const parent = findParentForDelete(path);
const action = findActionForNode(path);
const parent = action?.[1];
const outerReferences = (binding?.referencePaths || []).filter(ref => ref !== parent && !parent?.isAncestor(ref));

@@ -182,3 +183,16 @@

if (!deleted.has(path) && (!binding || outerReferences.length === 0)) {
removeWithRelated([parent ?? path]);
if (action) {
mutate(action[1], p => {
if (isRemoved(p)) return;
if (action[0] === 'remove') {
p.remove();
} else if (action[0] === 'replace') {
p.replaceWith(action[2]);
}
});
} else {
removeWithRelated([path]);
}
deleted.add(path);

@@ -185,0 +199,0 @@ changed = true;

@@ -193,3 +193,21 @@ "use strict";

});
it('should delete import', () => {
const {
code,
metadata
} = keep(['Alive'])`
import { A, B } from "ABC";
const AB = {
A,
B,
};
export const Alive = "";
export default AB;
`;
expect(code).toMatchSnapshot();
expect(metadata.imports.size).toBe(0);
});
});
//# sourceMappingURL=shaker-plugin.test.js.map

@@ -183,3 +183,4 @@ "use strict";

const binding = getBindingForExport(path);
const parent = (0, _utils.findParentForDelete)(path);
const action = (0, _utils.findActionForNode)(path);
const parent = action === null || action === void 0 ? void 0 : action[1];
const outerReferences = ((binding === null || binding === void 0 ? void 0 : binding.referencePaths) || []).filter(ref => ref !== parent && !(parent !== null && parent !== void 0 && parent.isAncestor(ref)));

@@ -194,3 +195,16 @@

if (!deleted.has(path) && (!binding || outerReferences.length === 0)) {
(0, _utils.removeWithRelated)([parent !== null && parent !== void 0 ? parent : path]);
if (action) {
(0, _utils.mutate)(action[1], p => {
if ((0, _utils.isRemoved)(p)) return;
if (action[0] === 'remove') {
p.remove();
} else if (action[0] === 'replace') {
p.replaceWith(action[2]);
}
});
} else {
(0, _utils.removeWithRelated)([path]);
}
deleted.add(path);

@@ -197,0 +211,0 @@ changed = true;

4

package.json
{
"name": "@linaria/shaker",
"description": "Blazing fast zero-runtime CSS in JS library",
"version": "4.2.3",
"version": "4.2.4",
"bugs": "https://github.com/callstack/linaria/issues",

@@ -14,3 +14,3 @@ "dependencies": {

"@linaria/logger": "^4.0.0",
"@linaria/utils": "^4.2.3",
"@linaria/utils": "^4.2.4",
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",

@@ -17,0 +17,0 @@ "ts-invariant": "^0.10.3"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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