Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@swc/core-darwin-arm64
Advanced tools
The @swc/core-darwin-arm64 npm package is a precompiled binary of SWC (Speedy Web Compiler) specifically for macOS on ARM64 architecture. SWC is a super-fast compiler written in Rust that compiles JavaScript/TypeScript down to efficient, optimized JavaScript code. It is designed to be used as a faster alternative to Babel and can perform tasks such as transpilation, minification, and bundling.
Transpilation
Transpiles TypeScript or modern JavaScript to a specified ECMAScript target version. The code sample demonstrates how to transpile TypeScript code to ES5.
const { transformSync } = require('@swc/core-darwin-arm64');
const sourceCode = `const x: number = 1;`;
const output = transformSync(sourceCode, {
filename: 'example.ts',
jsc: {
parser: {
syntax: 'typescript',
},
target: 'es5',
},
});
console.log(output.code);
Minification
Minifies JavaScript code to reduce file size by removing unnecessary characters and renaming variables. The code sample shows how to minify a simple function.
const { minifySync } = require('@swc/core-darwin-arm64');
const sourceCode = `function add(a, b) { return a + b; }`;
const minified = minifySync(sourceCode, {
compress: true,
mangle: true
});
console.log(minified.code);
Source Maps
Generates source maps to help with debugging by mapping the transformed code back to the original source code. The code sample demonstrates generating a source map for a file.
const { transformFileSync } = require('@swc/core-darwin-arm64');
const result = transformFileSync('input.js', {
sourceMaps: true,
filename: 'input.js',
jsc: {
target: 'es5'
}
});
console.log(result.map);
Babel is a widely-used JavaScript compiler that allows you to use next-generation JavaScript, today. It is similar to SWC in that it can transpile ES6 and beyond into backwards compatible JavaScript. Babel is highly configurable but generally slower than SWC due to being written in JavaScript.
The TypeScript compiler is similar to SWC when it comes to transpiling TypeScript code to JavaScript. However, TypeScript does not include a bundler or minifier and is focused solely on type-checking and transpilation.
Esbuild is an extremely fast JavaScript bundler and minifier. Like SWC, it is written in a compiled language (Go) and focuses on speed. It provides similar functionalities in terms of transpilation and minification but also includes a bundling feature.
Terser is a JavaScript parser, mangler, and compressor toolkit for ES6+. It is similar to the minification aspect of SWC but does not handle transpilation or bundling.
@swc/core-darwin-arm64
This is the aarch64-apple-darwin binary for @swc/core
FAQs
Super-fast alternative for babel
The npm package @swc/core-darwin-arm64 receives a total of 1,778,140 weekly downloads. As such, @swc/core-darwin-arm64 popularity was classified as popular.
We found that @swc/core-darwin-arm64 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.