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.0.0-beta.0 to 4.0.0-beta.1

24

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

@@ -139,3 +139,27 @@ import { join } from 'path';

});
it('should respect implicit references', () => {
const {
code,
metadata
} = keep(['a'])`
let _a;
exports.a = _a = {};
exports.b = _a;
`;
expect(code).toMatchSnapshot();
expect(metadata.imports.size).toBe(0);
});
it('should keep assigment even if export is marked for removing', () => {
const {
code,
metadata
} = keep(['b'])`
let _a;
exports.a = _a = {};
exports.b = _a;
`;
expect(code).toMatchSnapshot();
expect(metadata.imports.size).toBe(0);
});
});
//# sourceMappingURL=shaker-plugin.test.js.map

@@ -20,2 +20,10 @@ import { createCustomDebug } from '@linaria/logger';

if (exportPath.isAssignmentExpression()) {
const left = exportPath.get('left');
if (left.isIdentifier()) {
return exportPath.scope.getBinding(left.node.name);
}
}
return undefined;

@@ -81,3 +89,16 @@ }

const exports = rearrangeExports(babel, file.path, collected.exportRefs, collected.exports);
collected.exports.forEach(({
local
}) => {
if (local.isAssignmentExpression()) {
const left = local.get('left');
if (left.isIdentifier()) {
// For some reason babel does not mark id in AssignmentExpression as a reference
// So we need to do it manually
reference(left, left, true);
}
}
});
if (onlyExports.length === 1 && onlyExports[0] === '__linariaPreval' && !exports.find(i => i.exported === '__linariaPreval')) {

@@ -84,0 +105,0 @@ // Fast-lane: if only __linariaPreval is requested, and it's not exported,

@@ -150,3 +150,27 @@ "use strict";

});
it('should respect implicit references', () => {
const {
code,
metadata
} = keep(['a'])`
let _a;
exports.a = _a = {};
exports.b = _a;
`;
expect(code).toMatchSnapshot();
expect(metadata.imports.size).toBe(0);
});
it('should keep assigment even if export is marked for removing', () => {
const {
code,
metadata
} = keep(['b'])`
let _a;
exports.a = _a = {};
exports.b = _a;
`;
expect(code).toMatchSnapshot();
expect(metadata.imports.size).toBe(0);
});
});
//# sourceMappingURL=shaker-plugin.test.js.map

@@ -32,2 +32,10 @@ "use strict";

if (exportPath.isAssignmentExpression()) {
const left = exportPath.get('left');
if (left.isIdentifier()) {
return exportPath.scope.getBinding(left.node.name);
}
}
return undefined;

@@ -93,3 +101,16 @@ }

const exports = rearrangeExports(babel, file.path, collected.exportRefs, collected.exports);
collected.exports.forEach(({
local
}) => {
if (local.isAssignmentExpression()) {
const left = local.get('left');
if (left.isIdentifier()) {
// For some reason babel does not mark id in AssignmentExpression as a reference
// So we need to do it manually
(0, _utils.reference)(left, left, true);
}
}
});
if (onlyExports.length === 1 && onlyExports[0] === '__linariaPreval' && !exports.find(i => i.exported === '__linariaPreval')) {

@@ -96,0 +117,0 @@ // Fast-lane: if only __linariaPreval is requested, and it's not exported,

15

package.json
{
"name": "@linaria/shaker",
"description": "Blazing fast zero-runtime CSS in JS library",
"version": "4.0.0-beta.0",
"version": "4.0.0-beta.1",
"bugs": "https://github.com/callstack/linaria/issues",
"dependencies": {
"@babel/core": "^7.18.2",
"@babel/generator": ">=7",
"@babel/core": "^7.18.9",
"@babel/generator": "^7.18.9",
"@babel/plugin-transform-modules-commonjs": "^7.18.2",

@@ -13,4 +13,4 @@ "@babel/plugin-transform-runtime": ">=7",

"@babel/preset-env": ">=7",
"@linaria/logger": "^4.0.0-beta.0",
"@linaria/utils": "^4.0.0-beta.0",
"@linaria/logger": "^4.0.0-beta.1",
"@linaria/utils": "^4.0.0-beta.1",
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",

@@ -20,3 +20,3 @@ "ts-invariant": "^0.10.3"

"devDependencies": {
"@babel/types": "^7.18.4",
"@babel/types": "^7.18.9",
"@types/babel__core": "^7.1.19",

@@ -31,3 +31,3 @@ "@types/babel__generator": "^7.6.4",

"ts-jest": "^28.0.4",
"typescript": "^4.7.3"
"typescript": "^4.7.4"
},

@@ -65,2 +65,3 @@ "engines": {

"build:lib": "cross-env NODE_ENV=legacy babel src --out-dir lib --extensions '.js,.jsx,.ts,.tsx' --source-maps --delete-dir-on-start",
"test": "jest --config ./jest.config.js --rootDir src",
"typecheck": "tsc --noEmit --composite false",

@@ -67,0 +68,0 @@ "watch": "npm run build --watch"

@@ -28,3 +28,3 @@ <p align="center">

```sh
npm install @linaria/core @linaria/react @linaria/babel-preset @linaria/shaker
npm install @linaria/core @linaria/react @linaria/babel-preset
```

@@ -35,3 +35,3 @@

```sh
yarn add @linaria/core @linaria/react @linaria/babel-preset @linaria/shaker
yarn add @linaria/core @linaria/react @linaria/babel-preset
```

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