Questions tagged [babel-plugin]

76 questions
0
votes
0 answers

Babel custom plugin - plugins order

I have a custom babel plugin. In case a project includes multiple plugins (and possibly loaders from vue/angular), this means if, for example, two transforms both visit the "Program" node, the transforms will run in the first to last plugin order…
David Zaba
  • 67
  • 1
  • 9
0
votes
1 answer

Babel plugin - How to transform JSX without react

I have wrote my own module which takes a JSX string as a parameter and turns it into a javascript object, so I call it like so: import parser from 'own-parser' console.log(parser("

Hello world

")) This works, but what I actually need is to…
0
votes
0 answers

How to know if bable/webpack initial compilation finished

I am making my first bable plugin that transforms codes during the development. This plugin will be used with webpack and should handle multiple files. I need a way to know when babel or webpack has finished the first compilation and starts the…
cyrus-d
  • 749
  • 1
  • 12
  • 29
0
votes
1 answer

How to remove the surround IIFE from @babel/template?

I'm trying to convert some Ember codes to React. Here is what I want to transform. From export default Ember.Component.extend(({ didInsertElement() { } }); To export default class MyComponent extends React.Component { componentDidMount() {…
shijistar
  • 111
  • 4
0
votes
1 answer

VueJS and antdesign vue - Error: Cannot find module 'babel-plugin-import' from

I came across a problem installing vueJS with ant-design and after reboot of serve it gave below error: Error: Cannot find module 'babel-plugin-import' from xxx My steps were: Install vueJS project via vue ui Install dependencies for ant-design via…
Cyber
  • 2,194
  • 4
  • 22
  • 41
0
votes
1 answer

How to import multiple ui libraries using fixBabelImports in ReactJS

I'm trying to use two ant design ui libraries together with fixBabelImports namely Ant Design(for desktop browser) and Ant Design Mobile(for mobile browser). I tried the following methods, both works without console error, but i'm not sure which…
kaizen
  • 1,580
  • 4
  • 26
  • 50
0
votes
1 answer

Jest not picking latest plugin from babel.config.js

I have my own babel plugin mentioned in babel.config.js and when I change the plugin, jest doesn't pick the updated plugin code and breaks tests. When I run npx jest --no-cache, updated changes are picked up. I do not want to run with --no-cache…
edify17
  • 71
  • 2
  • 8
0
votes
1 answer

Is the path.scope.bindings only contains variables that in source code but not dynamic insert at babel transforming?

I'm trying to insert an import statement when transpiling my code with babel plugin. The statement might be dynamically inserted multiple times, so I have to make sure it don't be inserted before. I used to path.scope.hasOwnBinding and…
wolf
  • 93
  • 1
  • 5
0
votes
1 answer

Prevent babel class properties plugin from overwriting my generated constructor

Overview I have written a babel plugin that adds a custom constructor to classes. I also use the @babel/plugin-proposal-class-properties plugin to support class properties. My .babelrc looks like this: { "plugins": [ "./plugins/my-plugin.js", …
goodforenergy
  • 520
  • 1
  • 4
  • 18
0
votes
1 answer

@babel/preset-env loaded with wrong babel version after upgrade babel 6 to 7

I tried to upgrade my babel from 6 to 7, but I encounter this issue. /Users/darryl/Documents/Github/apps/node_modules/babel-register/node_modules/babel-core/lib/transformation/file/options/option-manager.js:328 throw e; ^ Error:…
Darryl RN
  • 7,432
  • 4
  • 26
  • 46
0
votes
1 answer

Replacing different kinds of function nodes on babel

I already asked this on babel slack channel a couple of days ago, but I never got an answer. I've created a plugin to transform functions to curried functions (npm). Despite my success building the plugins, I have a couple of issues that I found a…
Danielo515
  • 5,996
  • 4
  • 32
  • 66
0
votes
1 answer

How to use babel-plugin-rewire with React?

I'm seeing this error: ✖ should dispatch profileAction PhantomJS 1.9.8 (Linux 0.0.0) TypeError: 'undefined' is not a function (evaluating '_Header2.default.__Rewire__('profileAction', function (a) { a(); })') at…
0
votes
1 answer

How to transpile VariableDeclarator to AssignmentExpression?

I'm trying to take something like var a = 5; and transpile it to something like thing.a = 5. Using this code below in my visitor, it tells me unexpected token . VariableDeclarator: { enter: function (path, state) { path.replaceWith( …
realisation
  • 634
  • 6
  • 18
-1
votes
1 answer

check parameters of a function with Babel

I want to check parameters of a function to be in a range with babel. I mean I want to change the following code: function(arg1, arg2) { body of function } to this code: function checkRange(argument) { some checking } function(arg1,…
saha
  • 23
  • 5
-1
votes
2 answers

If object.assign is built-in why using bable-plugin for it?

I found this plugins in .babelrc file "plugins": [ ["transform-replace-object-assign", "object.assign"] ] and as i know Object.assign() is built-in method in all modern browsers. So why using it as plugins inside .babelrc? Thanks.
Jalal
  • 3,308
  • 4
  • 35
  • 43