babel: Cannot read property 'join' of undefined ( preset-stage-0 )

Bug Report

Current Behavior When i try to run webpack I am getting the following error

Module build failed (from ./node_modules/babel-loader/lib/index.js):
  TypeError: [BABEL] SomeFile.js: Cannot read property 'join' of undefined (While processing: "informed/node_modules/@babel/preset-stage-0/lib/index.js")
      at "informed/node_modules/@babel/helper-plugin-utils/lib/index.js:19:12

Input Code

// webpack config snippit
  rules: [
      {
        test: /\.(js)$/,
        exclude: /node_modules/,
        use: {
          loader: 'babel-loader',
          options: {
            presets: [
              "@babel/preset-env",
              ["@babel/preset-stage-0", { "decoratorsLegacy": true }],
              "@babel/preset-react"
            ],
          }
        }
      },

Environment

  • Babel version(s): [e.g. v6.0.0, v7.0.0-beta.34]
  • Node/npm version: Node: 9.5.0 NPM: 5.8.0
  • OS: OSX 10.13.5
  • Monorepo NO
  • How you are using Babel: Webpack

Additional context/Screenshots My project uses storybook and after updating to the latest beta release i started to have issues with babel. I tracked it back to an issue where there latest version started to use @babel/core instead of the old V6. I have a seprate webpack config for my tests and for distribution/production and they are failing with the error above.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 17 (8 by maintainers)

Commits related to this issue

Most upvoted comments

https://github.com/babel/babel/releases/tag/v7.0.0-beta.54

I also removed the requirement to specify the decorators/pipline plugin options (default to true/“minimal”). We are going to remove the Stage presets next which will require them but at least now you won’t have to specify anything, especially if you aren’t using them. You can always pin to an older version or use beta.54.

On another note (I like this other notes I guess), I think Webpacks philosophy of “sane defaults that can be extended and overwritten” is a really nice approach for developer experience.

I generally agree; in this case, we can’t do that because there is no “default” for the pipeline operator that won’t be a breaking change when one of the three proposals becomes the actual default, accepted behavior.

Forcing people to spend way longer to get their applications operating

I think that the ideal developement cycle would be something like

     +-------------------------------------------+
     | Add @babel/preset-env to the babel config |
     +-------------------------------------------+
                         |
             +------------------------+
             | Write code as you wish | <---------------+
             +------------------------+                 |
                         |                              |
+----------------------------------------------------+  |
| Babel crashes with a nice error message:           |  |
| "You need to enable the @babel/plugin-proposal-foo |  |
|  plugin to use this new shiny syntax!"             |  |
+----------------------------------------------------+  |
                         |                              |
                         |                              |
   Do you really need that sytax? Are you 100% sure?    |
           |                            |               |
          YES                           NO              |
      Danger zone                   Safe zone           |
           |                            |               |
+----------------------+        +------------------+    |
| Copypaste the plugin |        | Rewrite the last |    |
| name from the error  |        | lines you wrote  |    |
| message to the       |        +------------------+    |
| babel config.        |                |               |
+----------------------+                |               |
           |                            |               |
           v                            v               |
           +----------------------------+---Repeat------+

It doesn’t take much more time than using the stage presets, since Babel helps the user by actually saying what to do.