Parcel doesn't transpile the code without .babelrc configuration file

16 Views Asked by At

Just learned how to convert ES6 javascript code to ES5 using parcel. I tried to transpile this piece of code:

const greeting = () => {
  console.log("Hello, world!");
};

greeting();


class Person {
  greeting = "Hey"
  constructor(firstName){
    this.firstName = firstName;
    console.log(`${this.greeting}, ${this.firstName}`)
  }
}

new Person("Jack")

Parcel transpiled it just fine but it threw an warning message :

@parcel/transformer-babel: Parcel includes transpilation by default. Babel config babel.config.json contains only redundant presets. Deleting it may significantly improve build performance.

  D:\test\babel.config.json:2:15
    1 | {
  > 2 |   "presets": ["@parcel/babel-preset-env"]
  >   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^
    3 | }
    4 |

   Delete babel.config.json

I tried replacing @babel/preset-env with @parcel/babel-preset-env and it not only didn't transpile the code but also threw a similar message:

@parcel/transformer-babel: Parcel includes transpilation by default. Babel config .babelrc contains only redundant presets. Deleting it may significantly improve build performance.

  D:\test\.babelrc:2:15
    1 | {
  > 2 |   "presets": ["@parcel/babel-preset-env"]
  >   |               ^^^^^^^^^^^^^^^^^^^^^^^^^^
    3 | }
    4 |

   Delete .babelrc
   Learn more: https://parceljs.org/languages/javascript/#default-presets

Then I deleted the .babelrc file, now the warning is gone but it simply outputs the same ES6 code. What should I do? I used the 2.12.0 version of parcel.

0

There are 0 best solutions below