Skip to content

Unable to support functions such as "optional chain" in QQ browser 10 or chrome 70 #5222

@yangdan8

Description

@yangdan8

Describe the bug

Invalid Babel configuration

// App.vue

const num = window?.num ?? 9;
console.log(num);

// babel.config.js

module.exports = {
  presets: [
    "@vue/cli-plugin-babel/preset",
    "@babel/plugin-proposal-optional-chaining"
  ]
};

// vite.config.ts

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import legacy from '@vitejs/plugin-legacy'
import babel from 'vite-babel-plugin'

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    (babel as any)(),
    // legacy({
    //   additionalLegacyPolyfills: ['@babel/plugin-proposal-optional-chaining'],
    //   targets: ['chrome 70']
    // })
  ],
  build: {
    target: ['es2015'],
    // target: ['chrome70']
  },
})

Reproduction

https://github.com/yangdan8/vite2-vue3-ts-demo

System Info

QQ browser 10
Chrome70

Used Package Manager

yarn

Logs

Uncaught SyntaxError: Unexpected token .

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions