
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
@kalxjs/compiler
Advanced tools
Compiler for KalxJS single-file components (.klx files). This compiler transforms .klx single-file components into JavaScript code that can be used with the KalxJS runtime.
npm install @kalxjs/compiler
import { compile } from '@kalxjs/compiler';
// Compile a single-file component
const source = `
<template>
<div>
<h1>{{ title }}</h1>
<button @click="increment">Count: {{ count }}</button>
</div>
</template>
<script>
export default {
data() {
return {
title: 'Hello KalxJS',
count: 0
};
},
methods: {
increment() {
this.count++;
}
}
}
</script>
<style>
h1 {
color: #42b883;
}
button {
background-color: #35495e;
color: white;
padding: 8px 16px;
border-radius: 4px;
border: none;
cursor: pointer;
}
</style>
`;
const result = compile(source, {
filename: 'MyComponent.klx',
sourceMap: true
});
console.log(result.code); // Compiled JavaScript code
console.log(result.map); // Source map
console.log(result.styles); // Extracted styles
Compiles a KalxJS single-file component.
filename
- The filename of the component (used for source maps and error messages)sourceMap
- Generate source maps (default: false
)optimize
- Enable optimizations (default: process.env.NODE_ENV === 'production'
)styleProcessor
- Custom function to process styles (default: null
)scriptProcessor
- Custom function to process scripts (default: null
)templateProcessor
- Custom function to process templates (default: null
)An object containing:
code
- The compiled JavaScript codemap
- The source map (if sourceMap
is enabled)styles
- The extracted stylestemplate
- The processed templatescript
- The processed scripterrors
- Array of compilation errors (if any)The compiler also includes a Vite plugin for seamless integration with Vite-based projects:
// vite.config.js
import { defineConfig } from 'vite';
import kalx from '@kalxjs/compiler/vite-plugin';
export default defineConfig({
plugins: [
kalx({
// Plugin options
include: /\.klx$/,
exclude: /node_modules/
})
]
});
KalxJS single-file components have three sections:
<template>
<!-- HTML template with KalxJS template syntax -->
<div>
<h1>{{ title }}</h1>
<button @click="increment">Count: {{ count }}</button>
<!-- Comments are properly handled and removed from the output -->
<p class="description">{{ description }}</p>
<!-- Hyphenated attributes are supported -->
<router-link :to="path" active-class="active">Home</router-link>
</div>
</template>
The template syntax supports:
{{ expression }}
@event="handler"
:attr="value"
active-class="active"
<script>
// Component definition
export default {
name: 'MyComponent',
components: {
RouterLink,
CustomButton
},
data() {
return {
title: 'Hello KalxJS',
count: 0,
description: 'A modern JavaScript framework',
path: '/'
};
},
methods: {
increment() {
this.count++;
}
}
}
</script>
<style>
/* CSS styles */
h1 {
color: #42b883;
}
button {
background-color: #35495e;
color: white;
padding: 8px 16px;
border-radius: 4px;
}
.description {
font-style: italic;
margin: 10px 0;
}
.active {
font-weight: bold;
}
</style>
You can also use scoped styles:
<style scoped>
/* These styles will only apply to this component */
.container {
padding: 20px;
}
</style>
MIT
FAQs
Compiler for KalxJS single-file components (.klx files)
We found that @kalxjs/compiler demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.