I’m trying to get more familiar with modern javascript and am following a tutorial. Early setup includes running a file from another file. I have a server.js file with a simple ‘import ‘./config’; command. As a test that repo setup is correct, I should be able to run ‘babel serve…
Tag: babeljs
Babel command line all jsx files in a directory, output as js files
I have been running a command to turn .jsx files into .js files one at a time: I want to do it for everything in a directory. I read through the help command’s options and it seems like I should be able to do this But that says it requires filenames, despite providing a directory. What’s the right…
Babel 7.18 doesn’t transpile components outside the project root directory
I have a component sharedlib outside the babel root directory of project1. I used to use webpack to package this project without problems, but when I configured babel, I got the following error: The demo project to reproduce the problem is on github https://github.com/xybei/test_babel My project directory is …
Could not find/install babel plugin ‘proposal-decorators’ on CodeSandbox with Firebase
I’m trying to use Codesandbox in React project, but I’m stuck with error: Could not find/install babel plugin ‘proposal-decorators’: Cannot find plugin ‘proposal-decorators’ or ‘babel-plugin-proposal-decorators’. Error happens when I adding firebase utility in t…
Instagram embed: React’s JSX doesn’t support namespace tags
I was trying to embed an Instagram post on my React website but I encountered the error “Namespace tags are not supported by default. React’s JSX doesn’t support namespace tags. You can set throwIfNamespace: false to bypass this warning.” Where am I supposed to set throwIfNamespace: fa…
How do I persuade babel to let me define a Javascript array of consts?
I’m building my first expo/react app. I keep getting an “Unexpected token” error message in App.js: the error being in the [ of the line beginning const. As best I can tell, this is a babel issue: this syntax was introduced in ES2015. AFAICS, this should be resolvable by adding @babel/preset…
MUI5 not working with jest – SyntaxError: Cannot use import statement outside a module
Reproducible repo: https://github.com/hutber/cannotusestatement What is more worrying is: https://codesandbox.io/s/vigilant-bartik-bmz8x in the sandbox the tests pass. However if you checkout the above repo, which was imported into this sandbox it will not pass locally. I have no doubt that the issue is my je…
Getting compilation errors regarding loaders when running React app
Hi I’m having an issue when trying to run my react app. I’ve installed a couple of packages to from a tutorial using the ceramic and 3id networks. This error has only shown up recently and I’ve looked online but still not too sure what be causing the issue. The version of node I am using is …
Migrating from Babel to SWC with React
TL;DR How to translate a node script like this: to use SWC instead of Babel? Context We recently upgraded our Next.js version. Next.js now supports SWC instead of Babel. The unit tests for React in our project are written with RITEway. The test command is: It transforms the files with Babel first because othe…
What is @babel/plugin-transform-classes?
I run Google PageSpeed Insights on my site, and it reports an issue that is “Avoid serving legacy JavaScript to modern browsers”, as below: I have no idea of what is @babel/plugin-transform-classes, so I search online and it seems babel is a JavaScript compiler and @babel/plugin-transform-classes …