Skip to content

vue-request 从2.0.0-rc.4版本更新到 2.0.1之后 webpack打包出现错误。 #199

@hihumiW

Description

@hihumiW

问题描述 Problem Description

首先很感谢作者提供library!
vue-request 从2.0.0-rc.4版本更新到 2.0.1之后 webpack打包出现错误。

项目环境:项目是用vue-cli-service搭建的, 项目携带的webpack版本是4.46.0。
安装2.0.1打包时报错信息:

Failed to compile with 1 error                                                                                                                12:15:31 PM

 error  in ./node_modules/vue-request/dist/index.es.js

Module parse failed: Unexpected token (23:40)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
| const isServer = typeof window === 'undefined';
| const isDocumentVisibility = () => {
>   if (isServer || isNil(window.document?.visibilityState)) return true;
|   return window.document.visibilityState === 'visible';
| };

 @ ./src/main.js 12:18-40
 @ multi (webpack)-dev-server/client?http://192.168.0.78:1024&sockPath=/sockjs-node (webpack)/hot/dev-server.js ./src/main.js

如果使用2.0.0-rc.4则不会报错。
我对比了一下2个版本的同一行代码,问题应该出现在webpack无法解析 optional chaining: ?.
请问一下是因为我的webpack版本太老导致的吗?

其他信息 Other information

Metadata

Metadata

Assignees

No one assigned

    Labels

    2.x2.xbugSomething isn't workingquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions