lila
lila

Reputation: 463

how to apply babel plugin on code in js file

I am trying to apply babel plugin on code source something like this

code = require('babel-core').transform(code, {
      plugins: ['some plugin']
    })

above code is var that contains actual code as a string, what is the right way to do above?

Upvotes: 1

Views: 161

Answers (1)

Anand Gupta
Anand Gupta

Reputation: 366

This example shows how you can transform your code according to different babel plugins.

Using babel-core transform method (you already doing).

enter image description here

Output will be transpiled code according to babel-plugin.

enter image description here

You can refer to this link for more babel methods.

Hope it helps you :)

Upvotes: 3

Related Questions