question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

🐛 Can't add more presets to .babelrc (Merge defaults with babelrc file problem)

See original GitHub issue

From 1.5.1 to 1.62 I cannot get rid of “Missing class properties transform” when using stage-2 preset. It seems that under some situations the babelrc gets ignored (or that “env”, “react” presets are locked)

🎛 Configuration (.babelrc, package.json, cli command)

I am using --no-cache all the time so deleting the cache is not an applicable workaround for my case.

babel

{
  "presets": ["env", "react", "stage-2"]
}

package

{
  "name": "ui",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "scripts": {
    "start": "parcel src/index.html --no-cache",
    "build": "parcel build src/index.html --no-cache"
  },
  "dependencies": {
    "react": "^16.2.0",
    "react-dom": "^16.2.0",
    "react-redux": "^5.0.7",
    "react-router-dom": "^4.2.2"
  },
  "devDependencies": {
    "babel-preset-env": "^1.6.1",///with or without it
    "babel-preset-react": "^6.24.1",///with or without it
    "babel-preset-stage-2": "^6.24.1",
    "parcel-bundler": "^1.6.2"
  }
}

🤔 Expected Behavior

Babel should respect my babel config and include all the transformations that this preset should add.

😯 Current Behavior

Babel seems to ignore my config and still errors with “Missing class properties”

💁 Possible Solution

I tried to read the codebase, but i don’t know it too well. However I suspect it related to a pkg constructor param which seems to block the reading of the babel file under some circusntamces.

🔦 Context

I just want to use transform class properties syntax

💻 Code Sample

import React from 'react'

class Root extends React.Component {
    state = { time: 0 }//errors here

    render() {
        return 'hi from react ' + this.state
    }
}

export default Root

🌍 Your Environment

Software Version(s)
Parcel from 1.5.1 to 1.6.2
Node 8.9.2
npm/Yarn 1.2.1
Operating System windows 10 (and ubuntu 16.04 only parcel 1.6.2)

I think this is related to https://github.com/parcel-bundler/parcel/issues/824 and https://github.com/parcel-bundler/parcel/issues/824

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:4
  • Comments:25 (8 by maintainers)

github_iconTop GitHub Comments

8reactions
coder-laynecommented, Mar 6, 2018

I’ve run into the same problem with .babelrc:

{
  "presets": ["env", "stage-2", "react"],
}

and compiled success after adding "plugins": ["transform-class-properties"] .babelrc:

{
  "presets": ["env", "stage-2", "react"],
  "plugins": ["transform-class-properties"]
}
7reactions
devongovettcommented, Jan 6, 2019

Parcel 2 will no longer merge .babelrc with a default config for babel-preset-env. Instead, .babelrc will override the default config.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configure Babel
Create a file called babel.config.json with the following content at the root of ... Check out the .babelrc documentation to see more configuration...
Read more >
why do I have to put babel-presets inside .babelrc and ...
babelrc configuration is different from the configuration in the webpack config. The culprit is "passPerPreset": true .
Read more >
babel-loader - npm
npm install -D babel-loader @babel/core @babel/preset-env webpack ... the babel-loader 's version, the contents of .babelrc file if it ...
Read more >
How to Bundle JavaScript With Rollup — Step-by-Step Tutorial
Next, create a new file called rollup.config.js in the learn-rollup folder. ... If you can't update npm, see this issue for an alternative...
Read more >
ECMAScript 6 in WebStorm: Transpiling - The JetBrains Blog
ECMAScript 6+ is set as the default JavaScript version in Preferences ... Install Babel and its presets; Set up Babel File Watcher ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found