Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: getting `value.ensureFunctionName is not a function" with preset-env 7.25.0 #16682

Closed
1 task
rahearn opened this issue Jul 27, 2024 · 5 comments · Fixed by #16683
Closed
1 task

[Bug]: getting `value.ensureFunctionName is not a function" with preset-env 7.25.0 #16682

rahearn opened this issue Jul 27, 2024 · 5 comments · Fixed by #16683

Comments

@rahearn
Copy link

rahearn commented Jul 27, 2024

💻

  • Would you like to work on a fix?

How are you using Babel?

babel-loader (webpack)

Input code

webpack --config webpack.config.js is the command that triggers this. I have no idea what part of the code is actually involved. The error message tells me which source file is the problem, but not which line so I don't know how to give you any input code.

Configuration file name

babel.config.js

Configuration

module.exports = function(api) {
  var validEnv = ['development', 'test', 'production']
  var currentEnv = api.env()
  var isDevelopmentEnv = api.env('development')
  var isProductionEnv = api.env('production')
  var isTestEnv = api.env('test')

  if (!validEnv.includes(currentEnv)) {
    throw new Error(
      'Please specify a valid `NODE_ENV` or '  
        '`BABEL_ENV` environment variables. Valid values are "development", '  
        '"test", and "production". Instead, received: '  
        JSON.stringify(currentEnv)  
        '.'
    )
  }

  return {
    presets: [
      isTestEnv && [
        '@babel/preset-env',
        {
          targets: {
            node: 'current'
          },
          modules: 'commonjs'
        },
        '@babel/preset-react',
        {
          runtime: "automatic"
        }
      ],
      (isProductionEnv || isDevelopmentEnv) && [
        '@babel/preset-env',
        {
          forceAllTransforms: true,
          useBuiltIns: 'entry',
          corejs: 3,
          modules: false,
          exclude: ['transform-typeof-symbol']
        }
      ],
      [
        '@babel/preset-react',
        {
          development: isDevelopmentEnv || isTestEnv,
          useBuiltIns: true,
          runtime: "automatic"
        }
      ]
    ].filter(Boolean),
    plugins: [
      '@babel/plugin-syntax-dynamic-import',
      isTestEnv && 'babel-plugin-dynamic-import-node',
      '@babel/plugin-transform-destructuring',
      '@babel/plugin-transform-class-properties',
      [
        '@babel/plugin-transform-object-rest-spread',
        {
          useBuiltIns: true
        }
      ],
      [
        '@babel/plugin-transform-runtime',
        {
          helpers: false,
          regenerator: true,
          corejs: false
        }
      ],
      [
        '@babel/plugin-transform-regenerator',
        {
          async: false
        }
      ],
      isProductionEnv && [
        'babel-plugin-transform-react-remove-prop-types',
        {
          removeImport: true
        }
      ]
    ].filter(Boolean)
  }
}

Current and expected behavior

webpack builds started failing on updating to preset-env 7.25.0. I would expect them to continue building properly.

Environment

System:
OS: macOS 14.5
Binaries:
Node: 20.14.0 - ~/.nvm/versions/node/v20.14.0/bin/node
Yarn: 1.22.22 - /opt/homebrew/bin/yarn
npm: 10.7.0 - ~/.nvm/versions/node/v20.14.0/bin/npm
npmPackages:
@babel/core: ^7.24.9 => 7.24.9
@babel/plugin-transform-runtime: ^7.23.9 => 7.24.7
@babel/preset-env: ^7.25.0 => 7.25.0
@babel/preset-react: ^7.18.6 => 7.24.7
babel-loader: ^9.1.3 => 9.1.3
babel-plugin-transform-react-remove-prop-types: ^0.4.24 => 0.4.24
webpack: ^5.92.1 => 5.93.0

Possible solution

Changing

so that it polyfills value.ensureFuctionName instead of path.ensureFunctionName seems to do the trick, but I don't know enough about the full build pipeline to be sure that's what is intended.

Additional context

No response

@babel-bot
Copy link
Collaborator

Hey @rahearn! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite.

@enepgkatnudieaimta
Copy link

1, also getting the same error after upgrading to 7.25.0

@liuxingbaoyu
Copy link
Member

Thanks for the report and suggested fix, that's helpful!

@JLHwung
Copy link
Contributor

JLHwung commented Jul 28, 2024

As a workaround, you can remove @babel/traverse from your lockfile and run install again, the package manager should pick up the latest update. This is happening because there are multiple copies of @babel/traverse in the node modules.

@JLHwung
Copy link
Contributor

JLHwung commented Jul 28, 2024

Fixed in @babel/plugin-transform-function-name 7.25.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants