【问题标题】:Webpack doesn't recognize Bluebird PromiseWebpack 无法识别 Bluebird Promise
【发布时间】:2018-04-18 22:33:46
【问题描述】:

Visual Studio intellisense 正确识别出 Promise 来自 Bluebird,但似乎 webpack 被混淆了,当我在浏览器中调试主包时,我发现 Promise 不是“bluebird”Promise。

我正在为 reactJS 使用 Asp.net 核心模板。我有: "webpack": "2.5.1", “蓝鸟”:“3.5.1”, "@types/bluebird": "2.0.33"

这是我的 ts.config:

{ 
  "compilerOptions": {
    "baseUrl": "./ClientApp",
    "module": "commonjs",
    "moduleResolution": "node",
    "target": "es5",
    "jsx": "react",
    "sourceMap": true,
    "noImplicitAny": true,
    "skipDefaultLibCheck": true,
    //"strict": true,
    "lib": [ "dom", "es5", "es2015.iterable", "scripthost", "es2015.promise" ],
    "types": [ "webpack-env" ],
    "experimentalDecorators": true
 },
  "exclude": [
      "bin",
      "node_modules"
  ]
}

如何将 webpack 配置为始终使用 'bluebird' Promise?

【问题讨论】:

    标签: typescript promise bluebird webpack-2 typescript-typings


    【解决方案1】:

    在你的 webpack 配置的顶部

    global.Promise = require('bluebird')
    

    【讨论】:

    • 感谢您的回答,但这没有帮助。
    猜你喜欢
    • 1970-01-01
    • 2019-01-16
    • 2018-11-03
    • 2020-05-28
    • 2022-01-14
    • 2020-09-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多