Skip to content

build-scripts如何支持最新的javascript语法 #138

Open
@starsoul666

Description

@starsoul666

第三方依赖包使用了最新的javascript语法,例如?. 代码构建的时候会报错,如何更新corejs版本,支持最新的js语法

Activity

Osub

Osub commented on Jan 6, 2024

@Osub
image
Dogtiti

Dogtiti commented on Feb 2, 2024

@Dogtiti

+1

Dogtiti

Dogtiti commented on Feb 2, 2024

@Dogtiti

@starsoul666

module.exports = ({ onGetWebpackConfig }) => {
  onGetWebpackConfig((config) => {
    // 确保babel-loader配置存在,然后添加optional chaining插件
    config.module
      .rule('js')
      .test(/\.jsx?$/)
      .use('babel-loader')
      .loader('babel-loader')
      .options({
        presets: ['@babel/preset-env', '@babel/preset-react'],
        plugins: ['@babel/plugin-proposal-optional-chaining'],
      });
  });
};

研究了一下这样可以解决问题,看看你那适用不

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      build-scripts如何支持最新的javascript语法 · Issue #138 · ice-lab/build-scripts