Questions tagged [babel-plugin]

76 questions
0
votes
0 answers

Necessity of emotion babel-plugin after version 8 of emotion

https://emotion.sh/docs/@emotion/babel-plugin The official documentation states that it is not required for emotion 8 or higher. This plugin seems to help with optimization, am I understanding it right? Why is it not needed in version 8 or higher?…
Hyeongrok
  • 31
  • 1
  • 5
0
votes
0 answers

How to properly use my own Babel plugin in Babel's config file?

How to properly use my own Babel plugin in Babel's config file? I am a beginner in writing Babel plugins and I have written a plugin as practice that can extract information from TypeScript files. And I can use it by parsing the code in my own…
Eric-Guo
  • 3
  • 2
0
votes
0 answers

How to hide fileName with vite-plugin-babel-macros?

I'm working on a React project with Vite and Styled components. For better class names, I use the plugin vite-plugin-babel-macros, which works. But it displays the file name inside the class, which I'd like to hide, so from:
JulSeb42
  • 157
  • 1
  • 9
0
votes
0 answers

SyntaxError: Unexpected token '?' node_modules\babel-plugin-twin\index.js:15

````your text ERROR in ./app/app.js Module build failed (from ./node_modules/babel-loader/lib/index.js): C:\Users\Projects\Multipayment\sample-browser-ui\src\node_modules\babel-plugin-twin\index.js:15 const matchedExclude = (state.opts.exclude ??…
0
votes
0 answers

Reactjs - babel remove console log. Should I use webpack?

I would like to add babel-plugin-transform-remove-console on a ReactJs project to use Babel am I required to install webpack? "react": "^18.2.0", "react-dom": "^18.2.0" i tried to configure babel I get this screen instead of the classic react…
fabio87
  • 65
  • 6
0
votes
2 answers

Writing Babel plugin, how to modify code after visitor?

export default function({ types: t }) { return { pre(state) { this.allString = ''; }, visitor: { StringLiteral(path) { this.allString += path.node.value; } }, post(state) { // It does not work …
HZ1
  • 1
0
votes
1 answer

Is there a way to know if Identifier node is a variable name when traversing AST?

I am writing a babel plugin and I would like to collect all the variables used in a particular expression. For this I am using path.traverse() with Identifier visitor. However, this approach is not ideal as things like property names are also…
0
votes
1 answer

Generating code with babel-plugin-codegen: Module not found: Can't resolve 'fs'

I'm trying to generate a component during the build based on some params using babel-plugin-codegen (https://github.com/kentcdodds/babel-plugin-codegen). I've spent hours and this is where I'm at now: it looks like my component is successfully…
Arman Bimatov
  • 1,789
  • 4
  • 24
  • 31
0
votes
1 answer

Errors under Jest in CRA using Yarn portal

I have a Create-React-App 5 project using Yarn 3 and TypeScript 4. The web app uses a library in the same repo through Yarn's portal: protocol (Yarn workspaces are not used). myRepo ├── myLib │   ├── package.json │   ├── yarn.lock │   └── src │  …
usethe4ce
  • 23,261
  • 4
  • 30
  • 30
0
votes
1 answer

`String.prototype.at` is not implemented in all browsers. Is there a @babel/plugin that will transform this down to ES5 javascript?

At the time of this question String.prototype.at is not implemented in all browsers. I would like to use the at function on the String prototype within a React app that uses babel to transform modern ecmascript into older more browser compatible…
skellertor
  • 916
  • 1
  • 9
  • 26
0
votes
1 answer

Create unique identifier in babel plugin

I want to create global variables and be sure that they don't conflict with existing global varibale names. Example with replacing all array declarations: let arrayDeclarations const customPlugin = () => { return { visitor: { …
Alexander Danilov
  • 3,038
  • 1
  • 30
  • 35
0
votes
2 answers

Babel plugin error: Don't use `path.replaceWith()` with a source string, use `path.replaceWithSourceString()`

EDIT / UPDATE: I have taken loganfsmyth's advice and pulled out babel as the first argument to the sveltify function and I can access / console log babel.template.statement.ast however, if I try to call that function my app hangs indefinitely. Thie…
cbutler
  • 833
  • 13
  • 36
0
votes
0 answers

Babel-js transform block statement into arrow function

I would like to write a Babel plugin that translates a block-statement as first argument to function foo into an arrow function body. I would like to transform foo({var a = 1;}) into foo(() => {var a = 1;}) I tried the following: visitor: { …
Edmund Moshammer
  • 688
  • 7
  • 19
0
votes
1 answer

Duplicate helper functions generated when building bundle with babel and webpack

I'm trying to build bundle as small as possible using webpack and babel. I know that in order to skip duplication of extends, classCallCheck, etc. I should use @babel/plugin-transform-runtime and this works as expected. Unfortunately, there are…
Antoan Elenkov
  • 711
  • 1
  • 5
  • 20
0
votes
1 answer

Babel traverse to the first JSXElement

I need to add a custom attribute to components of a ReactJS app, for testing purposes. I have tried to use 2 different plugins, however, they apply the attribute to all JSXElements within that component and I want to apply it to just the first,…
Dave Clissold
  • 143
  • 3
  • 7