Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@swc/helpers
Advanced tools
The @swc/helpers package provides a set of helper functions designed to be used with the SWC compiler. These helpers are primarily used to polyfill or transform code in a way that makes newer JavaScript features compatible with older environments. This includes handling classes, async functions, spread operators, and more, ensuring that code utilizing modern JavaScript syntax can be transpiled for compatibility with environments that do not natively support these features.
Class handling
This feature allows for the transformation of ES6 classes into a format that can be understood by older JavaScript engines. The code sample demonstrates how a class with a method is transformed using the @swc/helpers package.
"use strict";
var _createClass = require("@swc/helpers/lib/_create_class.js").default;
var MyClass = /*#__PURE__*/function () {
function MyClass() {}
_createClass(MyClass, [{
key: "method",
value: function method() {}
}]);
return MyClass;
}();
Async/Await handling
This feature transforms async functions into generator functions with a regenerator runtime, making it possible to use async/await syntax in environments that do not support it natively. The code sample shows how an async function is transformed using @swc/helpers.
"use strict";
var _asyncToGenerator = require("@swc/helpers/lib/_async_to_generator.js").default;
function exampleFunction() {
return _asyncToGenerator(function* () {
var data = yield fetchData();
console.log(data);
})();
}
Spread operator handling
This feature provides a way to transform the spread operator in arrays and function calls into equivalent ES5 code. The code sample demonstrates how an array is concatenated with another array using the spread operator, transformed by @swc/helpers.
"use strict";
var _toConsumableArray = require("@swc/helpers/lib/_to_consumable_array.js").default;
var arr1 = [1, 2, 3];
var arr2 = [4, 5].concat(_toConsumableArray(arr1));
Similar to @swc/helpers, @babel/runtime provides a collection of helper functions and polyfills to support the transformation of modern JavaScript code into backwards-compatible versions. It is part of the Babel toolchain. While both packages serve similar purposes, @babel/runtime is typically used with Babel, whereas @swc/helpers is used with the SWC compiler.
Core-js is a modular standard library for JavaScript, providing polyfills for many new JavaScript features, including ECMAScript 2015+ features. Unlike @swc/helpers, which focuses on syntactic transformations, core-js focuses more on providing polyfills for new standard library features and built-ins. It can be used alongside transpilers like Babel or SWC to ensure full compatibility with older environments.
FAQs
External helpers for the swc project.
The npm package @swc/helpers receives a total of 11,588,151 weekly downloads. As such, @swc/helpers popularity was classified as popular.
We found that @swc/helpers demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.