vitejs / vite

Next generation frontend tooling. It's fast!
http://vite.dev
MIT License
68.09k stars 6.13k forks source link

when i use yarn build, i got something wrong #4301

Closed rocketsbigfan closed 3 years ago

rocketsbigfan commented 3 years ago

Describe the bug

my package.json

"dependencies": {
    "@types/react-router-dom": "^5.1.8",
    "antd": "^4.16.6",
    "axios": "^0.21.1",
    "classnames": "^2.3.1",
    "dayjs": "^1.10.6",
    "querystring": "^0.2.1",
    "react": "^17.0.0",
    "react-activation": "^0.9.4",
    "react-dom": "^17.0.0",
    "react-helmet-async": "^1.0.9",
    "react-router": "^5.2.0",
    "react-router-dom": "^5.2.0",
    "vite-plugin-imp": "^2.0.7",
    "vite-plugin-importer": "^0.2.5"
  },
  "devDependencies": {
    "@types/react": "^17.0.0",
    "@types/react-dom": "^17.0.0",
    "@umijs/fabric": "^2.6.2",
    "@vitejs/plugin-react-refresh": "^1.3.1",
    "eslint": "^7.30.0",
    "husky": "^4.0.7",
    "less": "^4.1.1",
    "lint-staged": "^11.0.1",
    "stylelint": "^13.13.1",
    "typescript": "^3.9.7",
    "vite": "^2.4.2"
  },

vite.config.ts

{
  plugins: [
    reactRefresh(),
    vitePluginImp({
      libList: [
        {
          libName: 'antd',
          style: (name) => `antd/es/${name}/style`
        }
      ]
    })
  ],

  resolve: {
    alias: [
      { find: /^~/, replacement: '' },
      { find: '@', replacement: resolve('src') }
    ]
  },

  server: {
    open: true, // 是否自动打开浏览器
    proxy: {
      '/api/todos': {
        target: 'http://localhost:3364'
        // rewrite: (path) => path.replace(API_LOCATION, '')
      }

    }
  },
  css: {
    preprocessorOptions: {
      less: {
        javascriptEnabled: true
      }
    }
  },
  build: {
    sourcemap: true,
    manifest: true
  }
}

Reproduction

my github: https://github.com/rocketsbigfan/management-system.git

System Info

System:
    OS: macOS 11.4
    CPU: (8) x64 Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz
    Memory: 223.66 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.4.0 - /usr/local/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 6.14.5 - /usr/local/bin/npm
  Browsers:
    Chrome: 91.0.4472.114
    Safari: 14.1.1
  npmPackages:
    vite: ^2.4.2 => 2.4.2

Used Package Manager

yarn

Logs

yarn run v1.22.4
$ tsc && vite build --debug
node_modules/vite/types/customEvent.d.ts:2:60 - error TS1110: Type expected.

2 export type CustomEventName<T extends string> = (T extends `vite:${T}`
                                                             ~~~~~~~~

node_modules/vite/types/customEvent.d.ts:4:6 - error TS1005: ';' expected.

4   : T) &
       ~

node_modules/vite/types/customEvent.d.ts:4:8 - error TS1109: Expression expected.

4   : T) &
         ~

node_modules/vite/types/customEvent.d.ts:5:16 - error TS1005: ')' expected.

5   (`vite:${T}` extends T ? never : T)
                 ~~~~~~~

node_modules/vite/types/customEvent.d.ts:5:37 - error TS1005: ';' expected.

5   (`vite:${T}` extends T ? never : T)
                                      ~

Found 5 errors.

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Validations

haoqunjiang commented 3 years ago

Your TypeScript version is too old. Please update to the latest.