Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'babel-core/register' vs 'babel-register'

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?

like image 218
Alexander Mills Avatar asked Jun 13 '16 02:06

Alexander Mills


People also ask

What is babel core?

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!

What is a babel register used for?

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.

Is babel deprecated?

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.

Can not find babel core?

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.


1 Answers

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.

like image 102
loganfsmyth Avatar answered Sep 24 '22 01:09

loganfsmyth



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!