Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@babel/plugin-transform-class-static-block
Advanced tools
The @babel/plugin-transform-class-static-block npm package allows developers to use the static class block syntax in JavaScript, enabling the definition of static initialization blocks within classes. This feature is particularly useful for performing tasks or initializing data that is related to the class itself, rather than instances of the class. The plugin transforms this modern syntax into a format that can be understood by JavaScript engines that do not yet support static class blocks.
Static Initialization Blocks
This feature allows for the execution of static blocks within a class, enabling complex initialization logic for static properties. The code sample demonstrates how a class can use a static block to fetch and assign data to a static property, with error handling.
class MyClass {
static x = 0;
static {
try {
const data = fetchData();
MyClass.x = data;
} catch (error) {
MyClass.x = defaultValue;
}
}
}
This package allows developers to use the class properties syntax, enabling more concise and readable class definitions. While it focuses on instance and static properties, it does not provide the specific functionality for static initialization blocks like @babel/plugin-transform-class-static-block does. However, it complements the static block feature by simplifying the declaration of class properties.
This package enables the use of private instance methods and accessors in classes. Similar to @babel/plugin-transform-class-static-block, it enhances class capabilities in JavaScript. However, its focus is on encapsulation and privacy of methods rather than initialization logic.
Transform class static blocks
See our website @babel/plugin-transform-class-static-block for more information.
Using npm:
npm install --save-dev @babel/plugin-transform-class-static-block
or using yarn:
yarn add @babel/plugin-transform-class-static-block --dev
v7.26.0 (2024-10-25)
babel-core
, babel-generator
, babel-parser
, babel-plugin-syntax-import-assertions
, babel-plugin-syntax-import-attributes
, babel-preset-env
, babel-standalone
, babel-types
babel-core
babel-compat-data
, babel-plugin-proposal-regexp-modifiers
, babel-plugin-transform-regexp-modifiers
, babel-preset-env
, babel-standalone
babel-parser
startIndex
parser option (@DylanPiercey)babel-generator
, babel-parser
, babel-plugin-syntax-flow
babel-helpers
, babel-preset-typescript
, babel-runtime-corejs3
import()
in rewriteImportExtensions
(@liuxingbaoyu)babel-generator
, babel-parser
@babel/generator
(@nicolo-ribaudo)babel-core
babel-plugin-proposal-json-modules
, babel-plugin-transform-json-modules
, babel-standalone
proposal-json-modules
to transform-json-modules
(@nicolo-ribaudo)babel-code-frame
, babel-highlight
@babel/highlight
in @babel/code-frame
(@nicolo-ribaudo)babel-generator
, babel-parser
, babel-types
kind
to TSModuleDeclaration
(@liuxingbaoyu)babel-helper-module-transforms
, babel-plugin-transform-modules-commonjs
FAQs
Transform class static blocks
The npm package @babel/plugin-transform-class-static-block receives a total of 8,381,922 weekly downloads. As such, @babel/plugin-transform-class-static-block popularity was classified as popular.
We found that @babel/plugin-transform-class-static-block demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 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 researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.