Giter Club home page Giter Club logo

Comments (19)

aulisius avatar aulisius commented on May 14, 2024 6

@jeffscottward, the current behaviour of babel-upgrade is to not write by default. Did you try with the --write flag?

from babel-upgrade.

ericf89 avatar ericf89 commented on May 14, 2024 6

Yea, if there's more than one package.json, it won't upgrade the babelrc. Not sure if that's intentional or not

from babel-upgrade.

ericf89 avatar ericf89 commented on May 14, 2024 4

I dug down a little bit, and at least in my project it was due to this line that checks for number of package.jsons. My project's not a monorepo, but I did have a random package.json nested deep down that meant that the writeBabelRC never got called.

I deleted the package.json, ran the upgrade, and then restored it from git. ✅

from babel-upgrade.

mnpenner avatar mnpenner commented on May 14, 2024 2

@aulisius No errors.

❯ npx babel-upgrade
npx: installed 217 in 7.539s
🙌  Thanks for trying out https://github.com/babel/babel-upgrade!

Updating closest package.json dependencies

VCS diff shows only package.json was modified.

from babel-upgrade.

aulisius avatar aulisius commented on May 14, 2024 1

@gknapp, there's minor error in your .babelrc

"env": {
    "production": {
      "plugins": [
        "transform-react-remove-prop-types",
        { "removeImport": true }
      ]
    }
  }

should be

"env": {
    "production": {
      "plugins": [
         ["transform-react-remove-prop-types", { "removeImport": true }]
      ]
    }
  }

Notice that if a plugin needs options, the plugin is added as an array.

from babel-upgrade.

gknapp avatar gknapp commented on May 14, 2024 1

@aulisius Thanks, that fixed the error. I upgraded the config by hand in the end. I had to remove babel-preset-airbnb.

Updating .babelrc config at .babelrc
Index: .babelrc
===================================================================
--- .babelrc    Before Upgrade
+++ .babelrc    After Upgrade

Current .babelrc:

{
  "presets": [
    "@babel/preset-env",
    "@babel/preset-react"
  ],
  "plugins": [
    "lodash",
    "react-hot-loader/babel",
    "@babel/plugin-proposal-class-properties",
    "@babel/plugin-transform-runtime",
    "@babel/plugin-syntax-dynamic-import"
  ],
  "env": {
    "production": {
      "plugins": [
        ["transform-react-remove-prop-types", { "removeImport": true }]
      ]
    }
  }
}

from babel-upgrade.

aulisius avatar aulisius commented on May 14, 2024

But if you see here, they are indeed parsing the file as JSON5. Maybe some other error while reading? Was there anything printed in the console?

from babel-upgrade.

hzoo avatar hzoo commented on May 14, 2024

aside: This issue reminds me that we should also make a website for this where you can copy paste or even drag/drop your config/package.json and it does the same thing as this tool. Maybe that could be useful too

from babel-upgrade.

hzoo avatar hzoo commented on May 14, 2024

Well for one thing, there isn't an easy way to handle comments other than my "idea" to parse as js and then output as js/json #8 (comment)

from babel-upgrade.

hzoo avatar hzoo commented on May 14, 2024

Actually it updated fine for me if the babelrc is at the root. I don't think you specified where the location of the babelrc was? I'm assuming you are using a monorepo which we don't support yet - it's in the readme https://github.com/babel/babel-upgrade

but there is a wip pr #35

from babel-upgrade.

mnpenner avatar mnpenner commented on May 14, 2024

My .babelrc actually is at the root, next to package.json. I don't mind if the comments are stripped if that helps.

A copy-paste website would be nice. I didn't realize it was going to just modify those files without asking any questions. It's a good thing I had committed recently.

from babel-upgrade.

jeffscottward avatar jeffscottward commented on May 14, 2024

Can verify the same issue. .babelrc remains unchaged even at the root.

from babel-upgrade.

kevinSuttle avatar kevinSuttle commented on May 14, 2024

@aulisius I did ✋ and got the same result. .babelc remains unchanged. I wonder if it's a permissions thing?

In the meantime, is there a tool like @hzoo mentioned for the babelrc?

from babel-upgrade.

kevinSuttle avatar kevinSuttle commented on May 14, 2024

Mine's a monorepo, but it also didn't upgrade the .babelrc in the root.

from babel-upgrade.

gknapp avatar gknapp commented on May 14, 2024

v0.0.23: package.json upgraded fine. Saw this error with my .babelrc:

λ yarn run babel-upgrade
yarn run v1.9.4
🙌  Thanks for trying out https://github.com/babel/babel-upgrade!

Updating .babelrc config at .babelrc
(node:14496) UnhandledPromiseRejectionWarning: TypeError: name.indexOf is not a function
    at changeName (C:\Apps\Manager\node_modules\babel-upgrade\src\upgradeConfig.js:8:12)
    at changePlugins (C:\Apps\Manager\node_modules\babel-upgrade\src\upgradeConfig.js:85:20)
    at Object.keys.forEach (C:\Apps\Manager\node_modules\babel-upgrade\src\upgradeConfig.js:108:7)
    at Array.forEach (<anonymous>)
    at upgradeConfig (C:\Apps\Manager\node_modules\babel-upgrade\src\upgradeConfig.js:106:29)
    at writeBabelRC (C:\Apps\Manager\node_modules\babel-upgrade\src\index.js:142:12)
    at <anonymous>
(node:14496) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:14496) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

My .babelrc:

{
  "presets": [
    ["env", {
      "targets": { "browsers": [">1%", "not ie < 12", "edge 16"] },
      "useBuiltIns": true
    }],
    "airbnb",
    "stage-2",
    "react"
  ],
  "plugins": [
    "lodash",
    "react-hot-loader/babel",
    "transform-class-properties",
    "transform-runtime",
    "syntax-dynamic-import"
  ],
  "env": {
    "production": {
      "plugins": [
        "transform-react-remove-prop-types",
        { "removeImport": true }
      ]
    }
  }
}

from babel-upgrade.

kevinSuttle avatar kevinSuttle commented on May 14, 2024

I counted 15 package.jsons in my current repo 🤣

from babel-upgrade.

jhoffmcd avatar jhoffmcd commented on May 14, 2024

Currently having this same issue in a Lerna monorepo, did #35 go stale?

from babel-upgrade.

Sundin avatar Sundin commented on May 14, 2024

Same for me, this is how my .babelrc looked initially:

{
  "plugins": [
    "react-hot-loader/babel",
    "transform-class-properties",
    "transform-object-rest-spread"
  ],
  "presets": ["env", "react"],
  "env": {
    "start": {
      "presets": ["react-hmre"]
    }
  }
}

from babel-upgrade.

kkoomen avatar kkoomen commented on May 14, 2024

I confirm the solution of @ericf89. I had some node_modules from NPM with package.json and the composer-generated vendor folder that also did contain some package.json. After removing these, the .babelrc was detecting successfully.

from babel-upgrade.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.