We can transpile sources on the fly using "babel-register"
https://babeljs.io/docs/usage/require/
but I am having trouble verifying which one is the one to use:
require('babel-core/register')
or
require('babel-register')
Does anyone know?
Babel is a JavaScript compilerPolyfill features that are missing in your target environment (through a third-party polyfill such as core-js) Source code transformations (codemods) And more!
The purpose of babel is to transpile your js current code to an understandable version of js for the given environment, tool, framework you're using.
This package has been deprecated in favor of separate inclusion of required parts of core-js and regenerator-runtime . See our website @babel/polyfill for more information. See our website @babel/polyfill for more information or the issues associated with this package.
To solve the error "Cannot find module '@babel/core'", make sure to install the @babe/core package by opening your terminal in your project's root directory and running the following command: npm i -D @babel/core and restart your IDE and development server.
They are the same. All babel-core/register
does is require('babel-register')
. https://github.com/babel/babel/blob/cb8c4172ef740aa562f0873d602d800c55e80c6d/packages/babel-core/register.js#L3
The recommended usage is babel-register
since that is the module where the code actually lives, and babel-core/register
has been removed in Babel 7.x. Better to depend specifically on the module you use, rather than load it as a side-effect of babel-core
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With