Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
@swc/core
Advanced tools
The @swc/core package is a super-fast compiler written in Rust that allows for transforming ECMAScript 2015+ code into a backwards compatible version of JavaScript that can be run in older browsers or environments. It is designed to be highly performant and offers features such as transpilation, minification, and source maps generation.
JavaScript/TypeScript Transpilation
Transpiles TypeScript or modern JavaScript to a specified ECMAScript target version. This example demonstrates transpiling TypeScript code to ES5.
require('@swc/core').transformSync('const x: number = 1;', { jsc: { parser: { syntax: 'typescript' }, target: 'es5' } });
Code Minification
Minifies JavaScript code to reduce file size, which is beneficial for production environments. This example shows how to minify a simple expression.
require('@swc/core').transformSync('const x = 1 + 2;', { minify: true });
Source Maps
Generates source maps for the transformed code, aiding in debugging by mapping the transformed code back to the original source code. This example demonstrates generating a source map for a file named 'input.js'.
require('@swc/core').transformFileSync('input.js', { sourceMaps: true });
Babel is a widely used JavaScript compiler that also allows for transforming modern JavaScript into backward compatible versions. Compared to @swc/core, Babel is more established with a larger ecosystem of plugins, but @swc/core is known for its superior performance due to being written in Rust.
The TypeScript compiler not only provides type checking but also has the capability to transpile TypeScript code to JavaScript, similar to the transpilation feature of @swc/core. However, TypeScript does not focus on minification or other optimizations that @swc/core offers.
Esbuild is a fast JavaScript bundler and minifier. It shares similar goals with @swc/core in terms of performance and efficiency. While both are focused on speed, esbuild emphasizes on bundling and has a different set of features compared to the more transpilation-focused @swc/core.
Make the web (development) faster.
SWC (stands for Speedy Web Compiler
) is a super-fast TypeScript / JavaScript compiler written in Rust. It's a library for Rust and JavaScript at the same time. If you are using SWC from Rust, see rustdoc and for most users, your entry point for using the library will be parser.
Also, SWC tries to ensure that
If you select the latest version of each crates, it will work
for rust users.
MSRV of crates is currently nightly, but we will support stable rustc again in the future.
If you are using SWC from JavaScript, please refer to docs on the website.
Check out the documentation in the website.
Please see comparison with babel.
Please see benchmark results on the website.
SWC is a community-driven project, and is maintained by a group of volunteers. If you'd like to help support the future of the project, please consider:
See CONTRIBUTING.md. You may also find the architecture documentation useful (ARCHITECTURE.md).
SWC is primarily distributed under the terms of the Apache License (Version 2.0).
See LICENSE for details.
FAQs
Super-fast alternative for babel
The npm package @swc/core receives a total of 3,159,886 weekly downloads. As such, @swc/core popularity was classified as popular.
We found that @swc/core 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
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.