
Research
/Security News
Contagious Interview Campaign Escalates With 67 Malicious npm Packages and New Malware Loader
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.
ts-vue-loader
Advanced tools
VueJS Typescript loader to enable HMR and VirtualDom when using Typescript
The goal of this loader is to enable HMR and Virtual Dom for VueJS Component written using .ts and vue-property-decorator
If you write your components like this
import { Vue, Component } from 'vue-property-decorator'
@Component({
template: `<div>Counter : {{ i }}</div>`
})
export default class Count1 extends Vue {
i: number = 0
timer?: number
mounted () {
this.timer = window.setInterval(() => {
this.i++
}, 1000)
}
destroyed () {
if (this.timer) {
window.clearInterval(this.timer)
}
}
}
This loader is for you !
First you have to install the loader
npm i -D ts-vue-loader
Then add the loader in your webpack configuration
// webpack.config.json
{
test: /\.tsx?$/,
use: ['ts-vue-loader', 'ts-loader']
},
And it should work. A demo project is available in the example directory.
There are two transformations done by this loader :
template: `<div>Counter : {{ i }}</div>`
is converted into :
render: function () { var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',[_vm._v("Increment : "+_vm._s(_vm.i))])}
and this code is added at the end of your module
App.options.__file = '/home/john-doe/vue-ts-loader/example/src/components/App.ts'
if (module.hot) {(function () {
var hotApi = require('vue-hot-reload-api')
hotApi.install(require('vue'), false)
if (!hotApi.compatible) return
module.hot.accept()
if (!module.hot.data) {
hotApi.createRecord('data-v-27f0d292', App)
} else {
hotApi.rerender('data-v-27f0d292', App)
}
})()}
The original Vue-loader is able to rerender components without loosing his state. Since it is quite tricky to detect what changed in your code, this loader will reload the whole component on every change. A good improvment could be to only trigger a rerender based what changed.
FAQs
VueJS Typescript loader to enable HMR and VirtualDom when using Typescript
We found that ts-vue-loader demonstrated a not healthy version release cadence and project activity because the last version was released 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
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.